|
@@ -240,14 +240,13 @@ static void InitializeWindowsAndCaches()
|
|
|
SetupColoursAndInitialWindow();
|
|
|
|
|
|
/* Update coordinates of the signs. */
|
|
|
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 */
|
|
|
if (_file_to_saveload.abstract_ftype == FT_SCENARIO && c->inaugurated_year != MIN_YEAR) {
|
|
|
c->inaugurated_year = _cur_year;
|
|
|
}
|
|
@@ -641,14 +640,13 @@ bool AfterLoadGame()
|
|
|
SetTileOwner(t, OWNER_WATER);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
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);
|
|
|
if (c->president_name != nullptr) c->president_name_1 = SPECSTR_PRESIDENT_NAME;
|
|
|
}
|
|
|
|
|
@@ -675,14 +673,13 @@ bool AfterLoadGame()
|
|
|
FOR_ALL_STATIONS(st) {
|
|
|
if (st->airport.tile == 0) st->airport.tile = INVALID_TILE;
|
|
|
if (st->train_station.tile == 0) st->train_station.tile = INVALID_TILE;
|
|
|
}
|
|
|
|
|
|
/* 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;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -797,14 +794,13 @@ bool AfterLoadGame()
|
|
|
|
|
|
/* Update all vehicles */
|
|
|
AfterLoadVehicles(true);
|
|
|
|
|
|
/* 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);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/* make sure there is a town in the game */
|
|
|
if (_game_mode == GM_NORMAL && Town::GetNumItems() == 0) {
|
|
@@ -997,27 +993,26 @@ bool AfterLoadGame()
|
|
|
FOR_ALL_TOWNS(t) UpdateTownMaxPass(t);
|
|
|
}
|
|
|
|
|
|
/* 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;
|
|
|
c->settings.engine_renew_money = 100000;
|
|
|
}
|
|
|
|
|
|
/* When loading a game, _local_company is not yet set to the correct value.
|
|
|
* However, in a dedicated server we are a spectator, so nothing needs to
|
|
|
* happen. In case we are not a dedicated server, the local company always
|
|
|
* 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;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (IsSavegameVersionBefore(SLV_48)) {
|
|
@@ -1346,14 +1341,13 @@ bool AfterLoadGame()
|
|
|
}
|
|
|
|
|
|
/* In version 16.1 of the savegame a company can decide if trains, which get
|
|
|
* 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)) {
|
|
|
/* Waypoints became subclasses of stations ... */
|
|
|
MoveWaypointsToBaseStations();
|
|
|
/* ... and buoys were moved to waypoints. */
|
|
@@ -1410,18 +1404,16 @@ 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);
|
|
|
}
|
|
|
|
|
|
if (!IsSavegameVersionBefore(SLV_27)) AfterLoadStations();
|
|
|
|
|
@@ -1437,13 +1429,13 @@ bool AfterLoadGame()
|
|
|
_date += DAYS_TILL_ORIGINAL_BASE_YEAR;
|
|
|
_cur_year += ORIGINAL_BASE_YEAR;
|
|
|
|
|
|
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) {
|
|
|
v->date_of_last_service += DAYS_TILL_ORIGINAL_BASE_YEAR;
|
|
|
v->build_year += ORIGINAL_BASE_YEAR;
|
|
|
}
|
|
@@ -1589,13 +1581,13 @@ bool AfterLoadGame()
|
|
|
v->cur_speed /= 10;
|
|
|
v->acceleration = avi->acceleration;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
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++) {
|
|
|
if (IsTileType(t, MP_OBJECT) && _m[t].m5 == OBJECT_STATUE) {
|
|
|
_m[t].m2 = CalcClosestTownFromTile(t)->index;
|
|
|
}
|
|
@@ -1789,13 +1781,13 @@ bool AfterLoadGame()
|
|
|
/* Set all share owners to INVALID_COMPANY for
|
|
|
* 1) all inactive companies
|
|
|
* (when inactive companies were stored in the savegame - TTD, TTDP and some
|
|
|
* *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;
|
|
|
if (!Company::IsValidID(company) || company == c->index) c->share_owners[i] = INVALID_COMPANY;
|
|
|
}
|
|
|
}
|
|
@@ -2058,14 +2050,13 @@ bool AfterLoadGame()
|
|
|
if (!a->IsNormalAircraft()) {
|
|
|
a->engine_type = a->First()->engine_type;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/* More companies ... */
|
|
|
Company *c;
|
|
|
FOR_ALL_COMPANIES(c) {
|
|
|
for (Company *c : Company::Iterate()) {
|
|
|
if (c->bankrupt_asked == 0xFF) c->bankrupt_asked = 0xFFFF;
|
|
|
}
|
|
|
|
|
|
Engine *e;
|
|
|
FOR_ALL_ENGINES(e) {
|
|
|
if (e->company_avail == 0xFF) e->company_avail = 0xFFFF;
|
|
@@ -2196,14 +2187,13 @@ bool AfterLoadGame()
|
|
|
if (o->IsType(OT_GOTO_STATION)) o->SetStopLocation(OSL_PLATFORM_FAR_END);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (IsSavegameVersionBefore(SLV_120)) {
|
|
|
extern VehicleDefaultSettings _old_vds;
|
|
|
Company *c;
|
|
|
FOR_ALL_COMPANIES(c) {
|
|
|
for (Company *c : Company::Iterate()) {
|
|
|
c->settings.vehicle = _old_vds;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (IsSavegameVersionBefore(SLV_121)) {
|
|
|
/* Delete small ufos heading for non-existing vehicles */
|
|
@@ -2660,14 +2650,13 @@ bool AfterLoadGame()
|
|
|
|
|
|
ClrBit(t->flags, 5);
|
|
|
SetBit(t->vehicle_flags, VF_PATHFINDER_LOST);
|
|
|
}
|
|
|
|
|
|
/* 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;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (IsSavegameVersionBefore(SLV_158)) {
|
|
@@ -2920,23 +2909,22 @@ bool AfterLoadGame()
|
|
|
SetRoadOwner(t, RTT_TRAM, o);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
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)) {
|
|
|
/* Fix too high inflation rates */
|
|
|
if (_economy.inflation_prices > MAX_INFLATION) _economy.inflation_prices = MAX_INFLATION;
|
|
|
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;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (IsSavegameVersionBefore(SLV_178)) {
|
|
|
extern uint8 _old_diff_level;
|