diff options
author | glx <glx@openttd.org> | 2019-12-16 18:51:20 +0100 |
---|---|---|
committer | Niels Martin Hansen <nielsm@indvikleren.dk> | 2019-12-21 20:13:03 +0100 |
commit | 00c2a98cf395d6e2a85290048e7be7a7f6ce0d04 (patch) | |
tree | 78cc73b1290a8076f3a1b7d6bbfad9aef1acba8d /src/saveload | |
parent | 4ae829cb272225c7e07e233a94c2d945077f432a (diff) | |
download | openttd-00c2a98cf395d6e2a85290048e7be7a7f6ce0d04.tar.xz |
Codechange: Replace FOR_ALL_INDUSTRIES with range-based for loops
Diffstat (limited to 'src/saveload')
-rw-r--r-- | src/saveload/afterload.cpp | 25 | ||||
-rw-r--r-- | src/saveload/industry_sl.cpp | 8 |
2 files changed, 10 insertions, 23 deletions
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index fb3b1ecf2..ec701f67a 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -259,8 +259,7 @@ static void InitializeWindowsAndCaches() } /* Identify owners of persistent storage arrays */ - Industry *i; - FOR_ALL_INDUSTRIES(i) { + for (Industry *i : Industry::Iterate()) { if (i->psa != nullptr) { i->psa->feature = GSF_INDUSTRIES; i->psa->tile = i->location.tile; @@ -1413,7 +1412,6 @@ bool AfterLoadGame() /* Time starts at 0 instead of 1920. * Account for this in older games by adding an offset */ if (IsSavegameVersionBefore(SLV_31)) { - Industry *i; Vehicle *v; _date += DAYS_TILL_ORIGINAL_BASE_YEAR; @@ -1423,7 +1421,7 @@ bool AfterLoadGame() for (Waypoint *wp : Waypoint::Iterate()) wp->build_date += DAYS_TILL_ORIGINAL_BASE_YEAR; for (Engine *e : Engine::Iterate()) e->intro_date += DAYS_TILL_ORIGINAL_BASE_YEAR; for (Company *c : Company::Iterate()) c->inaugurated_year += ORIGINAL_BASE_YEAR; - FOR_ALL_INDUSTRIES(i) i->last_prod_year += ORIGINAL_BASE_YEAR; + for (Industry *i : Industry::Iterate()) i->last_prod_year += ORIGINAL_BASE_YEAR; FOR_ALL_VEHICLES(v) { v->date_of_last_service += DAYS_TILL_ORIGINAL_BASE_YEAR; @@ -1435,8 +1433,6 @@ bool AfterLoadGame() * To give this prettiness to old savegames, we remove all farmfields and * plant new ones. */ if (IsSavegameVersionBefore(SLV_32)) { - Industry *i; - for (TileIndex t = 0; t < map_size; t++) { if (IsTileType(t, MP_CLEAR) && IsClearGround(t, CLEAR_FIELDS)) { /* remove fields */ @@ -1444,7 +1440,7 @@ bool AfterLoadGame() } } - FOR_ALL_INDUSTRIES(i) { + for (Industry *i : Industry::Iterate()) { uint j; if (GetIndustrySpec(i->type)->behaviour & INDUSTRYBEH_PLANT_ON_BUILT) { @@ -1660,8 +1656,7 @@ bool AfterLoadGame() if (IsSavegameVersionBefore(SLV_70)) { /* Added variables to support newindustries */ - Industry *i; - FOR_ALL_INDUSTRIES(i) i->founder = OWNER_NONE; + for (Industry *i : Industry::Iterate()) i->founder = OWNER_NONE; } /* From version 82, old style canals (above sealevel (0), WATER owner) are no longer supported. @@ -1701,9 +1696,8 @@ bool AfterLoadGame() } if (IsSavegameVersionBefore(SLV_78)) { - Industry *i; uint j; - FOR_ALL_INDUSTRIES(i) { + for (Industry * i : Industry::Iterate()) { const IndustrySpec *indsp = GetIndustrySpec(i->type); for (j = 0; j < lengthof(i->produced_cargo); j++) { i->produced_cargo[j] = indsp->produced_cargo[j]; @@ -2760,8 +2754,7 @@ bool AfterLoadGame() /* Before savegame version 161, persistent storages were not stored in a pool. */ if (!IsSavegameVersionBefore(SLV_76)) { - Industry *ind; - FOR_ALL_INDUSTRIES(ind) { + for (Industry *ind : Industry::Iterate()) { assert(ind->psa != nullptr); /* Check if the old storage was empty. */ @@ -3044,8 +3037,7 @@ bool AfterLoadGame() if (IsSavegameVersionBefore(SLV_EXTEND_INDUSTRY_CARGO_SLOTS)) { /* Make sure added industry cargo slots are cleared */ - Industry *i; - FOR_ALL_INDUSTRIES(i) { + for (Industry *i : Industry::Iterate()) { for (size_t ci = 2; ci < lengthof(i->produced_cargo); ci++) { i->produced_cargo[ci] = CT_INVALID; i->produced_cargo_waiting[ci] = 0; @@ -3127,8 +3119,7 @@ bool AfterLoadGame() } } else { /* Link neutral station back to industry, as this is not saved. */ - Industry *ind; - FOR_ALL_INDUSTRIES(ind) if (ind->neutral_station != nullptr) ind->neutral_station->industry = ind; + for (Industry *ind : Industry::Iterate()) if (ind->neutral_station != nullptr) ind->neutral_station->industry = ind; } if (IsSavegameVersionBefore(SLV_TREES_WATER_CLASS)) { diff --git a/src/saveload/industry_sl.cpp b/src/saveload/industry_sl.cpp index 00ffbd431..f5b1464c1 100644 --- a/src/saveload/industry_sl.cpp +++ b/src/saveload/industry_sl.cpp @@ -77,10 +77,8 @@ static const SaveLoad _industry_desc[] = { static void Save_INDY() { - Industry *ind; - /* Write the industries */ - FOR_ALL_INDUSTRIES(ind) { + for (Industry *ind : Industry::Iterate()) { SlSetArrayIndex(ind->index); SlObject(ind, _industry_desc); } @@ -129,9 +127,7 @@ static void Load_TIDS() static void Ptrs_INDY() { - Industry *i; - - FOR_ALL_INDUSTRIES(i) { + for (Industry *i : Industry::Iterate()) { SlObject(i, _industry_desc); } } |