|
@@ -225,24 +225,26 @@ static void InitializeWindowsAndCaches()
|
|
|
UpdateAllTownVirtCoords();
|
|
|
|
|
|
Company *c;
|
|
|
FOR_ALL_COMPANIES(c) {
|
|
|
/* 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.filetype == FT_SCENARIO && c->inaugurated_year != MIN_YEAR) {
|
|
|
c->inaugurated_year = _cur_year;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
RecomputePrices();
|
|
|
|
|
|
SetCachedEngineCounts();
|
|
|
|
|
|
Station::RecomputeIndustriesNearForAll();
|
|
|
RebuildSubsidisedSourceAndDestinationCache();
|
|
|
|
|
|
/* Towns have a noise controlled number of airports system
|
|
|
* So each airport's noise value must be added to the town->noise_reached value
|
|
|
* Reset each town's noise_reached value to '0' before. */
|
|
|
UpdateAirportsNoise();
|
|
|
|
|
|
CheckTrainsLengths();
|
|
|
}
|
|
@@ -521,27 +523,24 @@ bool AfterLoadGame()
|
|
|
LoadStringWidthTable();
|
|
|
|
|
|
/* Copy temporary data to Engine pool */
|
|
|
CopyTempEngineData();
|
|
|
|
|
|
/* Connect front and rear engines of multiheaded trains and converts
|
|
|
* subtype to the new format */
|
|
|
if (CheckSavegameVersionOldStyle(17, 1)) ConvertOldMultiheadToNew();
|
|
|
|
|
|
/* Connect front and rear engines of multiheaded trains */
|
|
|
ConnectMultiheadedTrains();
|
|
|
|
|
|
/* reinit the landscape variables (landscape might have changed) */
|
|
|
InitializeLandscapeVariables(true);
|
|
|
|
|
|
/* Update all vehicles */
|
|
|
AfterLoadVehicles(true);
|
|
|
|
|
|
/* Make sure there is an AI attached to an AI company */
|
|
|
{
|
|
|
Company *c;
|
|
|
FOR_ALL_COMPANIES(c) {
|
|
|
if (c->is_ai && c->ai_instance == NULL) AI::StartNew(c->index);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/* make sure there is a town in the game */
|
|
@@ -1920,46 +1919,64 @@ bool AfterLoadGame()
|
|
|
default:
|
|
|
/* Industry -> Industry */
|
|
|
s->src_type = s->dst_type = ST_INDUSTRY;
|
|
|
if (Industry::IsValidID(s->src) && Industry::IsValidID(s->dst)) continue;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
/* Awarded subsidy or invalid source/destination, invalidate */
|
|
|
delete s;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (CheckSavegameVersion(126)) {
|
|
|
/* Recompute inflation based on old unround loan limit
|
|
|
* Note: Max loan is 500000. With an inflation of 4% across 170 years
|
|
|
* that results in a max loan of about 0.7 * 2^31.
|
|
|
* So taking the 16 bit fractional part into account there are plenty of bits left
|
|
|
* for unmodified savegames ...
|
|
|
*/
|
|
|
uint64 aimed_inflation = (_economy.old_max_loan_unround << 16 | _economy.old_max_loan_unround_fract) / _settings_game.difficulty.max_loan;
|
|
|
|
|
|
/* ... well, just clamp it then. */
|
|
|
if (aimed_inflation > MAX_INFLATION) aimed_inflation = MAX_INFLATION;
|
|
|
|
|
|
/* Simulate the inflation, so we also get the payment inflation */
|
|
|
while (_economy.inflation_prices < aimed_inflation) {
|
|
|
AddInflation(false);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
AfterLoadLabelMaps();
|
|
|
|
|
|
GamelogPrintDebug(1);
|
|
|
|
|
|
InitializeWindowsAndCaches();
|
|
|
/* Restore the signals */
|
|
|
ResetSignalHandlers();
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
/** Reload all NewGRF files during a running game. This is a cut-down
|
|
|
* version of AfterLoadGame().
|
|
|
* XXX - We need to reset the vehicle position hash because with a non-empty
|
|
|
* hash AfterLoadVehicles() will loop infinitely. We need AfterLoadVehicles()
|
|
|
* to recalculate vehicle data as some NewGRF vehicle sets could have been
|
|
|
* removed or added and changed statistics */
|
|
|
void ReloadNewGRFData()
|
|
|
{
|
|
|
/* reload grf data */
|
|
|
GfxLoadSprites();
|
|
|
LoadStringWidthTable();
|
|
|
ResetEconomy();
|
|
|
RecomputePrices();
|
|
|
/* reload vehicles */
|
|
|
ResetVehiclePosHash();
|
|
|
AfterLoadVehicles(false);
|
|
|
StartupEngines();
|
|
|
SetCachedEngineCounts();
|
|
|
/* update station graphics */
|
|
|
AfterLoadStations();
|
|
|
/* Check and update house and town values */
|
|
|
UpdateHousesAndTowns();
|
|
|
/* Update livery selection windows */
|
|
|
for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; i++) InvalidateWindowData(WC_COMPANY_COLOUR, i);
|
|
|
/* redraw the whole screen */
|