mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Replace FOR_ALL_CARGOPACKETS with range-based for loops
parent
60e3cf8aff
commit
5fce5fa300
|
@ -126,8 +126,7 @@ void CargoPacket::Reduce(uint count)
|
||||||
*/
|
*/
|
||||||
/* static */ void CargoPacket::InvalidateAllFrom(SourceType src_type, SourceID src)
|
/* static */ void CargoPacket::InvalidateAllFrom(SourceType src_type, SourceID src)
|
||||||
{
|
{
|
||||||
CargoPacket *cp;
|
for (CargoPacket *cp : CargoPacket::Iterate()) {
|
||||||
FOR_ALL_CARGOPACKETS(cp) {
|
|
||||||
if (cp->source_type == src_type && cp->source_id == src) cp->source_id = INVALID_SOURCE;
|
if (cp->source_type == src_type && cp->source_id == src) cp->source_id = INVALID_SOURCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -138,8 +137,7 @@ void CargoPacket::Reduce(uint count)
|
||||||
*/
|
*/
|
||||||
/* static */ void CargoPacket::InvalidateAllFrom(StationID sid)
|
/* static */ void CargoPacket::InvalidateAllFrom(StationID sid)
|
||||||
{
|
{
|
||||||
CargoPacket *cp;
|
for (CargoPacket *cp : CargoPacket::Iterate()) {
|
||||||
FOR_ALL_CARGOPACKETS(cp) {
|
|
||||||
if (cp->source == sid) cp->source = INVALID_STATION;
|
if (cp->source == sid) cp->source = INVALID_STATION;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -192,19 +192,6 @@ public:
|
||||||
static void AfterLoad();
|
static void AfterLoad();
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Iterate over all _valid_ cargo packets from the given start.
|
|
||||||
* @param var Variable used as "iterator".
|
|
||||||
* @param start Cargo packet ID of the first packet to iterate over.
|
|
||||||
*/
|
|
||||||
#define FOR_ALL_CARGOPACKETS_FROM(var, start) FOR_ALL_ITEMS_FROM(CargoPacket, cargopacket_index, var, start)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Iterate over all _valid_ cargo packets from the begin of the pool.
|
|
||||||
* @param var Variable used as "iterator".
|
|
||||||
*/
|
|
||||||
#define FOR_ALL_CARGOPACKETS(var) FOR_ALL_CARGOPACKETS_FROM(var, 0)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple collection class for a list of cargo packets.
|
* Simple collection class for a list of cargo packets.
|
||||||
* @tparam Tinst Actual instantiation of this cargo list.
|
* @tparam Tinst Actual instantiation of this cargo list.
|
||||||
|
|
|
@ -58,8 +58,7 @@
|
||||||
|
|
||||||
if (IsSavegameVersionBefore(SLV_120)) {
|
if (IsSavegameVersionBefore(SLV_120)) {
|
||||||
/* CargoPacket's source should be either INVALID_STATION or a valid station */
|
/* CargoPacket's source should be either INVALID_STATION or a valid station */
|
||||||
CargoPacket *cp;
|
for (CargoPacket *cp : CargoPacket::Iterate()) {
|
||||||
FOR_ALL_CARGOPACKETS(cp) {
|
|
||||||
if (!Station::IsValidID(cp->source)) cp->source = INVALID_STATION;
|
if (!Station::IsValidID(cp->source)) cp->source = INVALID_STATION;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,9 +111,7 @@ const SaveLoad *GetCargoPacketDesc()
|
||||||
*/
|
*/
|
||||||
static void Save_CAPA()
|
static void Save_CAPA()
|
||||||
{
|
{
|
||||||
CargoPacket *cp;
|
for (CargoPacket *cp : CargoPacket::Iterate()) {
|
||||||
|
|
||||||
FOR_ALL_CARGOPACKETS(cp) {
|
|
||||||
SlSetArrayIndex(cp->index);
|
SlSetArrayIndex(cp->index);
|
||||||
SlObject(cp, GetCargoPacketDesc());
|
SlObject(cp, GetCargoPacketDesc());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue