summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorglx <glx@openttd.org>2019-12-15 18:14:51 +0100
committerNiels Martin Hansen <nielsm@indvikleren.dk>2019-12-21 20:13:03 +0100
commit1c92ba8ebed55e5455d6f57508db8ce55071d6eb (patch)
tree4236ec3880c3b2b40a0a67aac5c1f87682ef5d48 /src
parentfa9769f81a0f96324a7a72f272626c395e002ece (diff)
downloadopenttd-1c92ba8ebed55e5455d6f57508db8ce55071d6eb.tar.xz
Codechange: Replace FOR_ALL_CARGO_PAYMENTS with range-based for loops
Diffstat (limited to 'src')
-rw-r--r--src/economy_base.h13
-rw-r--r--src/saveload/afterload.cpp3
-rw-r--r--src/saveload/economy_sl.cpp6
3 files changed, 3 insertions, 19 deletions
diff --git a/src/economy_base.h b/src/economy_base.h
index 3bafb8d7e..5c9d79b8c 100644
--- a/src/economy_base.h
+++ b/src/economy_base.h
@@ -47,17 +47,4 @@ struct CargoPayment : CargoPaymentPool::PoolItem<&_cargo_payment_pool> {
void SetCargo(CargoID ct) { this->ct = ct; }
};
-/**
- * Iterate over all cargo payments from a given start position.
- * @param var The variable used for iterating.
- * @param start The start of the iteration.
- */
-#define FOR_ALL_CARGO_PAYMENTS_FROM(var, start) FOR_ALL_ITEMS_FROM(CargoPayment, cargo_payment_index, var, start)
-
-/**
- * Iterate over all cargo payments.
- * @param var The variable used for iterating.
- */
-#define FOR_ALL_CARGO_PAYMENTS(var) FOR_ALL_CARGO_PAYMENTS_FROM(var, 0)
-
#endif /* ECONOMY_BASE_H */
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp
index f979552be..eb438515b 100644
--- a/src/saveload/afterload.cpp
+++ b/src/saveload/afterload.cpp
@@ -822,8 +822,7 @@ bool AfterLoadGame()
}
/* Fix the cache for cargo payments. */
- CargoPayment *cp;
- FOR_ALL_CARGO_PAYMENTS(cp) {
+ for (CargoPayment *cp : CargoPayment::Iterate()) {
cp->front->cargo_payment = cp;
cp->current_station = cp->front->last_station_visited;
}
diff --git a/src/saveload/economy_sl.cpp b/src/saveload/economy_sl.cpp
index 6737ac2f3..637d2529c 100644
--- a/src/saveload/economy_sl.cpp
+++ b/src/saveload/economy_sl.cpp
@@ -72,8 +72,7 @@ static const SaveLoad _cargopayment_desc[] = {
static void Save_CAPY()
{
- CargoPayment *cp;
- FOR_ALL_CARGO_PAYMENTS(cp) {
+ for (CargoPayment *cp : CargoPayment::Iterate()) {
SlSetArrayIndex(cp->index);
SlObject(cp, _cargopayment_desc);
}
@@ -91,8 +90,7 @@ static void Load_CAPY()
static void Ptrs_CAPY()
{
- CargoPayment *cp;
- FOR_ALL_CARGO_PAYMENTS(cp) {
+ for (CargoPayment *cp : CargoPayment::Iterate()) {
SlObject(cp, _cargopayment_desc);
}
}