diff options
author | glx <glx@openttd.org> | 2019-12-17 22:04:09 +0100 |
---|---|---|
committer | Niels Martin Hansen <nielsm@indvikleren.dk> | 2019-12-21 20:13:03 +0100 |
commit | ee7a8eebca774666cd3625431a86dd05113b5e88 (patch) | |
tree | 7a7843a2ffae14db6e15933eb1bb29923945ddb0 /src/saveload/afterload.cpp | |
parent | 0b489f99249a8c62ee3826e490ed17f29377581c (diff) | |
download | openttd-ee7a8eebca774666cd3625431a86dd05113b5e88.tar.xz |
Codechange: Replace FOR_ALL_TOWNS with range-based for loops
Diffstat (limited to 'src/saveload/afterload.cpp')
-rw-r--r-- | src/saveload/afterload.cpp | 33 |
1 files changed, 10 insertions, 23 deletions
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index 519e4d46e..dd9fcd534 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -169,9 +169,7 @@ static void ConvertTownOwner() /* since savegame version 4.1, exclusive transport rights are stored at towns */ static void UpdateExclusiveRights() { - Town *t; - - FOR_ALL_TOWNS(t) { + for (Town *t : Town::Iterate()) { t->exclusivity = INVALID_COMPANY; } @@ -270,8 +268,7 @@ static void InitializeWindowsAndCaches() s->airport.psa->tile = s->airport.tile; } } - Town *t; - FOR_ALL_TOWNS(t) { + for (Town *t : Town::Iterate()) { for (std::list<PersistentStorage *>::iterator it = t->psa_list.begin(); it != t->psa_list.end(); ++it) { (*it)->feature = GSF_FAKE_TOWNS; (*it)->tile = t->xy; @@ -651,8 +648,7 @@ bool AfterLoadGame() if (st->name != nullptr) st->string_id = STR_SV_STNAME_FALLBACK; } - Town *t; - FOR_ALL_TOWNS(t) { + for (Town *t : Town::Iterate()) { t->name = CopyFromOldName(t->townnametype); if (t->name != nullptr) t->townnametype = SPECSTR_TOWNNAME_START + _settings_game.game_creation.town_name; } @@ -980,8 +976,7 @@ bool AfterLoadGame() /* From version 9.0, we update the max passengers of a town (was sometimes negative * before that. */ if (IsSavegameVersionBefore(SLV_9)) { - Town *t; - FOR_ALL_TOWNS(t) UpdateTownMaxPass(t); + for (Town *t : Town::Iterate()) UpdateTownMaxPass(t); } /* From version 16.0, we included autorenew on engines, which are now saved, but @@ -1570,9 +1565,7 @@ bool AfterLoadGame() * fast was added in version 54. From version 56 this is now saved in the * town as cities can be built specifically in the scenario editor. */ if (IsSavegameVersionBefore(SLV_56)) { - Town *t; - - FOR_ALL_TOWNS(t) { + for (Town *t : Town::Iterate()) { if (_settings_game.economy.larger_towns != 0 && (t->index % _settings_game.economy.larger_towns) == 0) { t->larger_town = true; } @@ -2018,8 +2011,7 @@ bool AfterLoadGame() if (e->company_avail == 0xFF) e->company_avail = 0xFFFF; } - Town *t; - FOR_ALL_TOWNS(t) { + for (Town *t : Town::Iterate()) { if (t->have_ratings == 0xFF) t->have_ratings = 0xFFFF; for (uint i = 8; i != MAX_COMPANIES; i++) t->ratings[i] = RATING_INITIAL; } @@ -2108,8 +2100,7 @@ bool AfterLoadGame() /* Initialize layout of all towns. Older versions were using different * generator for random town layout, use it if needed. */ - Town *t; - FOR_ALL_TOWNS(t) { + for (Town *t : Town::Iterate()) { if (_settings_game.economy.town_layout != TL_RANDOM) { t->layout = _settings_game.economy.town_layout; continue; @@ -2791,9 +2782,7 @@ bool AfterLoadGame() if (IsSavegameVersionBefore(SLV_164)) FixupTrainLengths(); if (IsSavegameVersionBefore(SLV_165)) { - Town *t; - - FOR_ALL_TOWNS(t) { + for (Town *t : Town::Iterate()) { /* Set the default cargo requirement for town growth */ switch (_settings_game.game_creation.landscape) { case LT_ARCTIC: @@ -2827,8 +2816,7 @@ bool AfterLoadGame() Town::Get(GetTownIndex(t))->cargo_accepted.Add(t); } - Town *town; - FOR_ALL_TOWNS(town) { + for (Town *town : Town::Iterate()) { UpdateTownCargoes(town); } } @@ -2984,8 +2972,7 @@ bool AfterLoadGame() if (IsSavegameVersionBefore(SLV_198)) { /* Convert towns growth_rate and grow_counter to ticks */ - Town *t; - FOR_ALL_TOWNS(t) { + for (Town *t : Town::Iterate()) { /* 0x8000 = TOWN_GROWTH_RATE_CUSTOM previously */ if (t->growth_rate & 0x8000) SetBit(t->flags, TOWN_CUSTOM_GROWTH); if (t->growth_rate != TOWN_GROWTH_RATE_NONE) { |