diff options
author | frosch <frosch@openttd.org> | 2009-09-06 18:53:57 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2009-09-06 18:53:57 +0000 |
commit | 438a429549486f08919748cee0f5346ccacf760b (patch) | |
tree | 3858342b95e237dcb97d35476646e0d0f9d23aeb /src/saveload/afterload.cpp | |
parent | 2ce1a608a8ff5eb4cd6582adac990b2004ce1103 (diff) | |
download | openttd-438a429549486f08919748cee0f5346ccacf760b.tar.xz |
(svn r17433) -Codechange: Store cumulated inflation in savegame and compute all prices from that instead of storing all prices separately.
Note: Savegame conversion computes the inflation from max loan. Prices from modified savegames will get lost. TTO savegames will also behave slightly different.
-Change: NewGRF price modifiers now take effect everytime when loading NewGRFs instead of once on gamestart.
Diffstat (limited to 'src/saveload/afterload.cpp')
-rw-r--r-- | src/saveload/afterload.cpp | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index d76638183..ce03b01af 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -234,6 +234,8 @@ static void InitializeWindowsAndCaches() } } + RecomputePrices(); + SetCachedEngineCounts(); Station::RecomputeIndustriesNearForAll(); @@ -530,9 +532,6 @@ bool AfterLoadGame() /* Connect front and rear engines of multiheaded trains */ ConnectMultiheadedTrains(); - /* reinit the landscape variables (landscape might have changed) */ - InitializeLandscapeVariables(true); - /* Update all vehicles */ AfterLoadVehicles(true); @@ -1929,6 +1928,24 @@ bool AfterLoadGame() } } + 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); @@ -1950,7 +1967,7 @@ void ReloadNewGRFData() /* reload grf data */ GfxLoadSprites(); LoadStringWidthTable(); - ResetEconomy(); + RecomputePrices(); /* reload vehicles */ ResetVehiclePosHash(); AfterLoadVehicles(false); |