Codechange: Replace order related FOR_ALL with range-based for loops
This commit is contained in:
@@ -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
|
||||
|
@@ -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());
|
||||
}
|
||||
}
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user