diff options
author | glx <glx@openttd.org> | 2019-12-15 22:45:18 +0100 |
---|---|---|
committer | Niels Martin Hansen <nielsm@indvikleren.dk> | 2019-12-21 20:13:03 +0100 |
commit | 1f6b3a37f9c39adb22eb61d3153b0c62bfa20551 (patch) | |
tree | 15486a7d6bb1445f3d6f1cbf40f98c1552368c08 /src/saveload | |
parent | 1c92ba8ebed55e5455d6f57508db8ce55071d6eb (diff) | |
download | openttd-1f6b3a37f9c39adb22eb61d3153b0c62bfa20551.tar.xz |
Codechange: Replace FOR_ALL_ENGINES with range-based for loops
Diffstat (limited to 'src/saveload')
-rw-r--r-- | src/saveload/afterload.cpp | 6 | ||||
-rw-r--r-- | src/saveload/engine_sl.cpp | 6 | ||||
-rw-r--r-- | src/saveload/vehicle_sl.cpp | 9 |
3 files changed, 8 insertions, 13 deletions
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index eb438515b..fb3b1ecf2 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -1413,7 +1413,6 @@ bool AfterLoadGame() /* Time starts at 0 instead of 1920. * Account for this in older games by adding an offset */ if (IsSavegameVersionBefore(SLV_31)) { - Engine *e; Industry *i; Vehicle *v; @@ -1422,7 +1421,7 @@ bool AfterLoadGame() for (Station *st : Station::Iterate()) st->build_date += DAYS_TILL_ORIGINAL_BASE_YEAR; for (Waypoint *wp : Waypoint::Iterate()) wp->build_date += DAYS_TILL_ORIGINAL_BASE_YEAR; - FOR_ALL_ENGINES(e) e->intro_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; @@ -2044,8 +2043,7 @@ bool AfterLoadGame() if (c->bankrupt_asked == 0xFF) c->bankrupt_asked = 0xFFFF; } - Engine *e; - FOR_ALL_ENGINES(e) { + for (Engine *e : Engine::Iterate()) { if (e->company_avail == 0xFF) e->company_avail = 0xFFFF; } diff --git a/src/saveload/engine_sl.cpp b/src/saveload/engine_sl.cpp index 98cb4d0a3..4ba38d04b 100644 --- a/src/saveload/engine_sl.cpp +++ b/src/saveload/engine_sl.cpp @@ -86,8 +86,7 @@ Engine *GetTempDataEngine(EngineID index) static void Save_ENGN() { - Engine *e; - FOR_ALL_ENGINES(e) { + for (Engine *e : Engine::Iterate()) { SlSetArrayIndex(e->index); SlObject(e, _engine_desc); } @@ -118,8 +117,7 @@ static void Load_ENGN() */ void CopyTempEngineData() { - Engine *e; - FOR_ALL_ENGINES(e) { + for (Engine *e : Engine::Iterate()) { if (e->index >= _temp_engine.size()) break; const Engine *se = GetTempDataEngine(e->index); diff --git a/src/saveload/vehicle_sl.cpp b/src/saveload/vehicle_sl.cpp index 3529c84eb..74a01616b 100644 --- a/src/saveload/vehicle_sl.cpp +++ b/src/saveload/vehicle_sl.cpp @@ -215,11 +215,10 @@ static void CheckValidVehicles() size_t total_engines = Engine::GetPoolSize(); EngineID first_engine[4] = { INVALID_ENGINE, INVALID_ENGINE, INVALID_ENGINE, INVALID_ENGINE }; - Engine *e; - FOR_ALL_ENGINES_OF_TYPE(e, VEH_TRAIN) { first_engine[VEH_TRAIN] = e->index; break; } - FOR_ALL_ENGINES_OF_TYPE(e, VEH_ROAD) { first_engine[VEH_ROAD] = e->index; break; } - FOR_ALL_ENGINES_OF_TYPE(e, VEH_SHIP) { first_engine[VEH_SHIP] = e->index; break; } - FOR_ALL_ENGINES_OF_TYPE(e, VEH_AIRCRAFT) { first_engine[VEH_AIRCRAFT] = e->index; break; } + for (const Engine *e : Engine::IterateType(VEH_TRAIN)) { first_engine[VEH_TRAIN] = e->index; break; } + for (const Engine *e : Engine::IterateType(VEH_ROAD)) { first_engine[VEH_ROAD] = e->index; break; } + for (const Engine *e : Engine::IterateType(VEH_SHIP)) { first_engine[VEH_SHIP] = e->index; break; } + for (const Engine *e : Engine::IterateType(VEH_AIRCRAFT)) { first_engine[VEH_AIRCRAFT] = e->index; break; } Vehicle *v; FOR_ALL_VEHICLES(v) { |