diff options
Diffstat (limited to 'src/saveload')
-rw-r--r-- | src/saveload/afterload.cpp | 46 | ||||
-rw-r--r-- | src/saveload/company_sl.cpp | 10 | ||||
-rw-r--r-- | src/saveload/oldloader_sl.cpp | 3 | ||||
-rw-r--r-- | src/saveload/saveload.cpp | 3 |
4 files changed, 23 insertions, 39 deletions
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index 943885473..c10904c8a 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -243,8 +243,7 @@ static void InitializeWindowsAndCaches() UpdateAllVirtCoords(); ResetViewportAfterLoadGame(); - Company *c; - FOR_ALL_COMPANIES(c) { + for (Company *c : Company::Iterate()) { /* For each company, verify (while loading a scenario) that the inauguration date is the current year and set it * accordingly if it is not the case. No need to set it on companies that are not been used already, * thus the MIN_YEAR (which is really nothing more than Zero, initialized value) test */ @@ -644,8 +643,7 @@ bool AfterLoadGame() } if (IsSavegameVersionBefore(SLV_84)) { - Company *c; - FOR_ALL_COMPANIES(c) { + for (Company *c : Company::Iterate()) { c->name = CopyFromOldName(c->name_1); if (c->name != nullptr) c->name_1 = STR_SV_UNNAMED; c->president_name = CopyFromOldName(c->president_name_1); @@ -678,8 +676,7 @@ bool AfterLoadGame() } /* the same applies to Company::location_of_HQ */ - Company *c; - FOR_ALL_COMPANIES(c) { + for (Company *c : Company::Iterate()) { if (c->location_of_HQ == 0 || (IsSavegameVersionBefore(SLV_4) && c->location_of_HQ == 0xFFFF)) { c->location_of_HQ = INVALID_TILE; } @@ -800,8 +797,7 @@ bool AfterLoadGame() /* Make sure there is an AI attached to an AI company */ { - Company *c; - FOR_ALL_COMPANIES(c) { + for (const Company *c : Company::Iterate()) { if (c->is_ai && c->ai_instance == nullptr) AI::StartNew(c->index); } } @@ -1000,8 +996,7 @@ bool AfterLoadGame() /* From version 16.0, we included autorenew on engines, which are now saved, but * of course, we do need to initialize them for older savegames. */ if (IsSavegameVersionBefore(SLV_16)) { - Company *c; - FOR_ALL_COMPANIES(c) { + for (Company *c : Company::Iterate()) { c->engine_renew_list = nullptr; c->settings.engine_renew = false; c->settings.engine_renew_months = 6; @@ -1014,7 +1009,7 @@ bool AfterLoadGame() * becomes company 0, unless we are in the scenario editor where all the * companies are 'invalid'. */ - c = Company::GetIfValid(COMPANY_FIRST); + Company *c = Company::GetIfValid(COMPANY_FIRST); if (!_network_dedicated && c != nullptr) { c->settings = _settings_client.company; } @@ -1349,8 +1344,7 @@ bool AfterLoadGame() * replaced, shall keep their old length. In all prior versions, just default * to false */ if (IsSavegameVersionBefore(SLV_16, 1)) { - Company *c; - FOR_ALL_COMPANIES(c) c->settings.renew_keep_length = false; + for (Company *c : Company::Iterate()) c->settings.renew_keep_length = false; } if (IsSavegameVersionBefore(SLV_123)) { @@ -1413,12 +1407,10 @@ bool AfterLoadGame() YapfNotifyTrackLayoutChange(INVALID_TILE, INVALID_TRACK); if (IsSavegameVersionBefore(SLV_34)) { - Company *c; - FOR_ALL_COMPANIES(c) ResetCompanyLivery(c); + for (Company *c : Company::Iterate()) ResetCompanyLivery(c); } - Company *c; - FOR_ALL_COMPANIES(c) { + for (Company *c : Company::Iterate()) { c->avail_railtypes = GetCompanyRailtypes(c->index); c->avail_roadtypes = GetCompanyRoadTypes(c->index); } @@ -1440,7 +1432,7 @@ bool AfterLoadGame() FOR_ALL_STATIONS(st) st->build_date += DAYS_TILL_ORIGINAL_BASE_YEAR; FOR_ALL_WAYPOINTS(wp) wp->build_date += DAYS_TILL_ORIGINAL_BASE_YEAR; FOR_ALL_ENGINES(e) e->intro_date += DAYS_TILL_ORIGINAL_BASE_YEAR; - FOR_ALL_COMPANIES(c) c->inaugurated_year += 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_ALL_VEHICLES(v) { @@ -1592,7 +1584,7 @@ bool AfterLoadGame() } } - if (IsSavegameVersionBefore(SLV_49)) FOR_ALL_COMPANIES(c) c->face = ConvertFromOldCompanyManagerFace(c->face); + if (IsSavegameVersionBefore(SLV_49)) for (Company *c : Company::Iterate()) c->face = ConvertFromOldCompanyManagerFace(c->face); if (IsSavegameVersionBefore(SLV_52)) { for (TileIndex t = 0; t < map_size; t++) { @@ -1792,7 +1784,7 @@ bool AfterLoadGame() * *really* old revisions of OTTD; else it is already set in InitializeCompanies()) * 2) shares that are owned by inactive companies or self * (caused by cheating clients in earlier revisions) */ - FOR_ALL_COMPANIES(c) { + for (Company *c : Company::Iterate()) { for (uint i = 0; i < 4; i++) { CompanyID company = c->share_owners[i]; if (company == INVALID_COMPANY) continue; @@ -2061,8 +2053,7 @@ bool AfterLoadGame() } /* More companies ... */ - Company *c; - FOR_ALL_COMPANIES(c) { + for (Company *c : Company::Iterate()) { if (c->bankrupt_asked == 0xFF) c->bankrupt_asked = 0xFFFF; } @@ -2199,8 +2190,7 @@ bool AfterLoadGame() if (IsSavegameVersionBefore(SLV_120)) { extern VehicleDefaultSettings _old_vds; - Company *c; - FOR_ALL_COMPANIES(c) { + for (Company *c : Company::Iterate()) { c->settings.vehicle = _old_vds; } } @@ -2663,8 +2653,7 @@ bool AfterLoadGame() } /* Introduced terraform/clear limits. */ - Company *c; - FOR_ALL_COMPANIES(c) { + for (Company *c : Company::Iterate()) { c->terraform_limit = _settings_game.construction.terraform_frame_burst << 16; c->clear_limit = _settings_game.construction.clear_frame_burst << 16; } @@ -2923,8 +2912,7 @@ bool AfterLoadGame() if (IsSavegameVersionBefore(SLV_175)) { /* Introduced tree planting limit. */ - Company *c; - FOR_ALL_COMPANIES(c) c->tree_limit = _settings_game.construction.tree_frame_burst << 16; + for (Company *c : Company::Iterate()) c->tree_limit = _settings_game.construction.tree_frame_burst << 16; } if (IsSavegameVersionBefore(SLV_177)) { @@ -2933,7 +2921,7 @@ bool AfterLoadGame() if (_economy.inflation_payment > MAX_INFLATION) _economy.inflation_payment = MAX_INFLATION; /* We have to convert the quarters of bankruptcy into months of bankruptcy */ - FOR_ALL_COMPANIES(c) { + for (Company *c : Company::Iterate()) { c->months_of_bankruptcy = 3 * c->months_of_bankruptcy; } } diff --git a/src/saveload/company_sl.cpp b/src/saveload/company_sl.cpp index 19e2e2343..e1dc5cdc2 100644 --- a/src/saveload/company_sl.cpp +++ b/src/saveload/company_sl.cpp @@ -94,8 +94,7 @@ CompanyManagerFace ConvertFromOldCompanyManagerFace(uint32 face) void AfterLoadCompanyStats() { /* Reset infrastructure statistics to zero. */ - Company *c; - FOR_ALL_COMPANIES(c) MemSetT(&c->infrastructure, 0); + for (Company *c : Company::Iterate()) MemSetT(&c->infrastructure, 0); /* Collect airport count. */ Station *st; @@ -105,6 +104,7 @@ void AfterLoadCompanyStats() } } + Company *c; for (TileIndex tile = 0; tile < MapSize(); tile++) { switch (GetTileType(tile)) { case MP_RAILWAY: @@ -486,8 +486,7 @@ static void SaveLoad_PLYR(Company *c) static void Save_PLYR() { - Company *c; - FOR_ALL_COMPANIES(c) { + for (Company *c : Company::Iterate()) { SlSetArrayIndex(c->index); SlAutolength((AutolengthProc*)SaveLoad_PLYR, c); } @@ -534,8 +533,7 @@ static void Check_PLYR() static void Ptrs_PLYR() { - Company *c; - FOR_ALL_COMPANIES(c) { + for (Company *c : Company::Iterate()) { SlObject(c, _company_settings_desc); } } diff --git a/src/saveload/oldloader_sl.cpp b/src/saveload/oldloader_sl.cpp index ae7aa890c..3a3efa34d 100644 --- a/src/saveload/oldloader_sl.cpp +++ b/src/saveload/oldloader_sl.cpp @@ -459,8 +459,7 @@ static bool FixTTOEngines() static void FixTTOCompanies() { - Company *c; - FOR_ALL_COMPANIES(c) { + for (Company *c : Company::Iterate()) { c->cur_economy.company_value = CalculateCompanyValue(c); // company value history is zeroed } } diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp index 639461460..d652f0d25 100644 --- a/src/saveload/saveload.cpp +++ b/src/saveload/saveload.cpp @@ -2816,8 +2816,7 @@ void GenerateDefaultSaveName(char *buf, const char *last) * 'Spectator' as "company" name. */ CompanyID cid = _local_company; if (!Company::IsValidID(cid)) { - const Company *c; - FOR_ALL_COMPANIES(c) { + for (const Company *c : Company::Iterate()) { cid = c->index; break; } |