summaryrefslogtreecommitdiff
path: root/src/saveload
diff options
context:
space:
mode:
Diffstat (limited to 'src/saveload')
-rw-r--r--src/saveload/afterload.cpp33
-rw-r--r--src/saveload/oldloader_sl.cpp4
-rw-r--r--src/saveload/town_sl.cpp14
3 files changed, 16 insertions, 35 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) {
diff --git a/src/saveload/oldloader_sl.cpp b/src/saveload/oldloader_sl.cpp
index 830d300b6..659216c0c 100644
--- a/src/saveload/oldloader_sl.cpp
+++ b/src/saveload/oldloader_sl.cpp
@@ -152,10 +152,8 @@ static uint32 RemapOldTownName(uint32 townnameparts, byte old_town_name_type)
static void FixOldTowns()
{
- Town *town;
-
/* Convert town-names if needed */
- FOR_ALL_TOWNS(town) {
+ for (Town *town : Town::Iterate()) {
if (IsInsideMM(town->townnametype, 0x20C1, 0x20C3)) {
town->townnametype = SPECSTR_TOWNNAME_ENGLISH + _settings_game.game_creation.town_name;
town->townnameparts = RemapOldTownName(town->townnameparts, _settings_game.game_creation.town_name);
diff --git a/src/saveload/town_sl.cpp b/src/saveload/town_sl.cpp
index 549a86cad..6fe1439b4 100644
--- a/src/saveload/town_sl.cpp
+++ b/src/saveload/town_sl.cpp
@@ -24,12 +24,11 @@
*/
void RebuildTownCaches()
{
- Town *town;
InitializeBuildingCounts();
RebuildTownKdtree();
/* Reset town population and num_houses */
- FOR_ALL_TOWNS(town) {
+ for (Town *town : Town::Iterate()) {
town->cache.population = 0;
town->cache.num_houses = 0;
}
@@ -38,7 +37,7 @@ void RebuildTownCaches()
if (!IsTileType(t, MP_HOUSE)) continue;
HouseID house_id = GetHouseType(t);
- town = Town::GetByTile(t);
+ Town *town = Town::GetByTile(t);
IncreaseBuildingCount(town, house_id);
if (IsHouseCompleted(t)) town->cache.population += HouseSpec::Get(house_id)->population;
@@ -47,7 +46,7 @@ void RebuildTownCaches()
}
/* Update the population and num_house dependent values */
- FOR_ALL_TOWNS(town) {
+ for (Town *town : Town::Iterate()) {
UpdateTownRadius(town);
UpdateTownCargoes(town);
}
@@ -263,9 +262,7 @@ static void RealSave_Town(Town *t)
static void Save_TOWN()
{
- Town *t;
-
- FOR_ALL_TOWNS(t) {
+ for (Town *t : Town::Iterate()) {
SlSetArrayIndex(t->index);
SlAutolength((AutolengthProc*)RealSave_Town, t);
}
@@ -311,8 +308,7 @@ static void Ptrs_TOWN()
/* Don't run when savegame version lower than 161. */
if (IsSavegameVersionBefore(SLV_161)) return;
- Town *t;
- FOR_ALL_TOWNS(t) {
+ for (Town *t : Town::Iterate()) {
SlObject(t, _town_desc);
}
}