summaryrefslogtreecommitdiff
path: root/src/saveload
diff options
context:
space:
mode:
authorglx <glx@openttd.org>2019-12-17 01:35:29 +0100
committerNiels Martin Hansen <nielsm@indvikleren.dk>2019-12-21 20:13:03 +0100
commit9892d90b26db4dfe97ec7baeb89e43acb53a178e (patch)
treec4cbee86584e50e85c419aed6aa912fe1b6ebf37 /src/saveload
parent41232f18c18c9ca444282a9e959b7dfd6c93eff5 (diff)
downloadopenttd-9892d90b26db4dfe97ec7baeb89e43acb53a178e.tar.xz
Codechange: Replace order related FOR_ALL with range-based for loops
Diffstat (limited to 'src/saveload')
-rw-r--r--src/saveload/afterload.cpp16
-rw-r--r--src/saveload/order_sl.cpp26
-rw-r--r--src/saveload/station_sl.cpp3
-rw-r--r--src/saveload/waypoint_sl.cpp3
4 files changed, 16 insertions, 32 deletions
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp
index ec701f67a..39ee5b845 100644
--- a/src/saveload/afterload.cpp
+++ b/src/saveload/afterload.cpp
@@ -1451,10 +1451,9 @@ bool AfterLoadGame()
/* Setting no refit flags to all orders in savegames from before refit in orders were added */
if (IsSavegameVersionBefore(SLV_36)) {
- Order *order;
Vehicle *v;
- FOR_ALL_ORDERS(order) {
+ for (Order *order : Order::Iterate()) {
order->SetRefit(CT_NO_REFIT);
}
@@ -1724,8 +1723,7 @@ bool AfterLoadGame()
if (IsSavegameVersionBefore(SLV_93)) {
/* Rework of orders. */
- Order *order;
- FOR_ALL_ORDERS(order) order->ConvertFromOldSavegame();
+ for (Order *order : Order::Iterate()) order->ConvertFromOldSavegame();
Vehicle *v;
FOR_ALL_VEHICLES(v) {
@@ -1736,13 +1734,13 @@ bool AfterLoadGame()
v->current_order.ConvertFromOldSavegame();
if (v->type == VEH_ROAD && v->IsPrimaryVehicle() && v->FirstShared() == v) {
+ Order* order;
FOR_VEHICLE_ORDERS(v, order) order->SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
}
}
} else if (IsSavegameVersionBefore(SLV_94)) {
/* Unload and transfer are now mutual exclusive. */
- Order *order;
- FOR_ALL_ORDERS(order) {
+ for (Order *order : Order::Iterate()) {
if ((order->GetUnloadType() & (OUFB_UNLOAD | OUFB_TRANSFER)) == (OUFB_UNLOAD | OUFB_TRANSFER)) {
order->SetUnloadType(OUFB_TRANSFER);
order->SetLoadType(OLFB_NO_LOAD);
@@ -2160,8 +2158,7 @@ bool AfterLoadGame()
/* Trains could now stop in a specific location. */
if (IsSavegameVersionBefore(SLV_117)) {
- Order *o;
- FOR_ALL_ORDERS(o) {
+ for (Order *o : Order::Iterate()) {
if (o->IsType(OT_GOTO_STATION)) o->SetStopLocation(OSL_PLATFORM_FAR_END);
}
}
@@ -3014,8 +3011,7 @@ bool AfterLoadGame()
#ifndef DEBUG_DUMP_COMMANDS
/* Note: We cannot use CleanPool since that skips part of the destructor
* and then leaks un-reachable Orders in the order pool. */
- OrderBackup *ob;
- FOR_ALL_ORDER_BACKUPS(ob) {
+ for (OrderBackup *ob : OrderBackup::Iterate()) {
delete ob;
}
#endif
diff --git a/src/saveload/order_sl.cpp b/src/saveload/order_sl.cpp
index 80b0aa871..0a9fa2a8c 100644
--- a/src/saveload/order_sl.cpp
+++ b/src/saveload/order_sl.cpp
@@ -123,9 +123,7 @@ const SaveLoad *GetOrderDescription()
static void Save_ORDR()
{
- Order *order;
-
- FOR_ALL_ORDERS(order) {
+ for (Order *order : Order::Iterate()) {
SlSetArrayIndex(order->index);
SlObject(order, GetOrderDescription());
}
@@ -166,8 +164,8 @@ static void Load_ORDR()
}
/* Update all the next pointer */
- Order *o;
- FOR_ALL_ORDERS(o) {
+ for (Order *o : Order::Iterate()) {
+ size_t order_index = o->index;
/* Delete invalid orders */
if (o->IsType(OT_NOTHING)) {
delete o;
@@ -197,9 +195,7 @@ static void Ptrs_ORDR()
/* Orders from old savegames have pointers corrected in Load_ORDR */
if (IsSavegameVersionBefore(SLV_5, 2)) return;
- Order *o;
-
- FOR_ALL_ORDERS(o) {
+ for (Order *o : Order::Iterate()) {
SlObject(o, GetOrderDescription());
}
}
@@ -216,9 +212,7 @@ const SaveLoad *GetOrderListDescription()
static void Save_ORDL()
{
- OrderList *list;
-
- FOR_ALL_ORDER_LISTS(list) {
+ for (OrderList *list : OrderList::Iterate()) {
SlSetArrayIndex(list->index);
SlObject(list, GetOrderListDescription());
}
@@ -238,9 +232,7 @@ static void Load_ORDL()
static void Ptrs_ORDL()
{
- OrderList *list;
-
- FOR_ALL_ORDER_LISTS(list) {
+ for (OrderList *list : OrderList::Iterate()) {
SlObject(list, GetOrderListDescription());
}
}
@@ -277,8 +269,7 @@ static void Save_BKOR()
* normal games this information isn't needed. */
if (!_networking || !_network_server) return;
- OrderBackup *ob;
- FOR_ALL_ORDER_BACKUPS(ob) {
+ for (OrderBackup *ob : OrderBackup::Iterate()) {
SlSetArrayIndex(ob->index);
SlObject(ob, GetOrderBackupDescription());
}
@@ -297,8 +288,7 @@ void Load_BKOR()
static void Ptrs_BKOR()
{
- OrderBackup *ob;
- FOR_ALL_ORDER_BACKUPS(ob) {
+ for (OrderBackup *ob : OrderBackup::Iterate()) {
SlObject(ob, GetOrderBackupDescription());
}
}
diff --git a/src/saveload/station_sl.cpp b/src/saveload/station_sl.cpp
index 7b091e2f1..08fc07157 100644
--- a/src/saveload/station_sl.cpp
+++ b/src/saveload/station_sl.cpp
@@ -40,8 +40,7 @@ static void UpdateWaypointOrder(Order *o)
void MoveBuoysToWaypoints()
{
/* Buoy orders become waypoint orders */
- OrderList *ol;
- FOR_ALL_ORDER_LISTS(ol) {
+ for (OrderList *ol : OrderList::Iterate()) {
VehicleType vt = ol->GetFirstSharedVehicle()->type;
if (vt != VEH_SHIP && vt != VEH_TRAIN) continue;
diff --git a/src/saveload/waypoint_sl.cpp b/src/saveload/waypoint_sl.cpp
index 37b221e32..ddb11082e 100644
--- a/src/saveload/waypoint_sl.cpp
+++ b/src/saveload/waypoint_sl.cpp
@@ -130,8 +130,7 @@ void MoveWaypointsToBaseStations()
}
/* Update the orders of vehicles */
- OrderList *ol;
- FOR_ALL_ORDER_LISTS(ol) {
+ for (OrderList *ol : OrderList::Iterate()) {
if (ol->GetFirstSharedVehicle()->type != VEH_TRAIN) continue;
for (Order *o = ol->GetFirstOrder(); o != nullptr; o = o->next) UpdateWaypointOrder(o);