summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorglx <glx@openttd.org>2019-12-15 17:37:35 +0100
committerNiels Martin Hansen <nielsm@indvikleren.dk>2019-12-21 20:13:03 +0100
commit5fce5fa300318db4e87849c2269a0e013d6f89e1 (patch)
treee2c5128a259e6e7ce70144cb7cb86929d4d35f05 /src
parent60e3cf8aff9a7b98a0365ab734bebf70607160a1 (diff)
downloadopenttd-5fce5fa300318db4e87849c2269a0e013d6f89e1.tar.xz
Codechange: Replace FOR_ALL_CARGOPACKETS with range-based for loops
Diffstat (limited to 'src')
-rw-r--r--src/cargopacket.cpp6
-rw-r--r--src/cargopacket.h13
-rw-r--r--src/saveload/cargopacket_sl.cpp7
3 files changed, 4 insertions, 22 deletions
diff --git a/src/cargopacket.cpp b/src/cargopacket.cpp
index e1af2bc8f..f5f7c0c03 100644
--- a/src/cargopacket.cpp
+++ b/src/cargopacket.cpp
@@ -126,8 +126,7 @@ void CargoPacket::Reduce(uint count)
*/
/* static */ void CargoPacket::InvalidateAllFrom(SourceType src_type, SourceID src)
{
- CargoPacket *cp;
- FOR_ALL_CARGOPACKETS(cp) {
+ for (CargoPacket *cp : CargoPacket::Iterate()) {
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)
{
- CargoPacket *cp;
- FOR_ALL_CARGOPACKETS(cp) {
+ for (CargoPacket *cp : CargoPacket::Iterate()) {
if (cp->source == sid) cp->source = INVALID_STATION;
}
}
diff --git a/src/cargopacket.h b/src/cargopacket.h
index a38d46a22..c058bafdb 100644
--- a/src/cargopacket.h
+++ b/src/cargopacket.h
@@ -193,19 +193,6 @@ public:
};
/**
- * 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.
* @tparam Tinst Actual instantiation of this cargo list.
*/
diff --git a/src/saveload/cargopacket_sl.cpp b/src/saveload/cargopacket_sl.cpp
index 90aa33cf9..bb44c663f 100644
--- a/src/saveload/cargopacket_sl.cpp
+++ b/src/saveload/cargopacket_sl.cpp
@@ -58,8 +58,7 @@
if (IsSavegameVersionBefore(SLV_120)) {
/* CargoPacket's source should be either INVALID_STATION or a valid station */
- CargoPacket *cp;
- FOR_ALL_CARGOPACKETS(cp) {
+ for (CargoPacket *cp : CargoPacket::Iterate()) {
if (!Station::IsValidID(cp->source)) cp->source = INVALID_STATION;
}
}
@@ -112,9 +111,7 @@ const SaveLoad *GetCargoPacketDesc()
*/
static void Save_CAPA()
{
- CargoPacket *cp;
-
- FOR_ALL_CARGOPACKETS(cp) {
+ for (CargoPacket *cp : CargoPacket::Iterate()) {
SlSetArrayIndex(cp->index);
SlObject(cp, GetCargoPacketDesc());
}