From fef8b831a93a0fc772fc8a0b7799ec51cd86a967 Mon Sep 17 00:00:00 2001 From: Pavel Stupnikov Date: Wed, 2 May 2018 22:01:30 +0300 Subject: Change: Switch town growth rate and counter to actual game ticks (#6763) --- src/saveload/afterload.cpp | 13 +++++++++++++ src/saveload/saveload.cpp | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'src/saveload') diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index f01afb425..33c49fb61 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -2969,6 +2969,19 @@ bool AfterLoadGame() #endif } + if (IsSavegameVersionBefore(198)) { + /* Convert towns growth_rate and grow_counter to ticks */ + Town *t; + FOR_ALL_TOWNS(t) { + /* 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) { + t->growth_rate = TownTicksToGameTicks(t->growth_rate & ~0x8000); + } + /* Add t->index % TOWN_GROWTH_TICKS to spread growth across ticks. */ + t->grow_counter = TownTicksToGameTicks(t->grow_counter) + t->index % TOWN_GROWTH_TICKS; + } + } /* Station acceptance is some kind of cache */ if (IsSavegameVersionBefore(127)) { diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp index cea80b59d..d06214e23 100644 --- a/src/saveload/saveload.cpp +++ b/src/saveload/saveload.cpp @@ -265,8 +265,9 @@ * 195 27572 1.6.x * 196 27778 1.7.x * 197 27978 1.8.x + * 198 */ -extern const uint16 SAVEGAME_VERSION = 197; ///< Current savegame version of OpenTTD. +extern const uint16 SAVEGAME_VERSION = 198; ///< Current savegame version of OpenTTD. SavegameType _savegame_type; ///< type of savegame we are loading FileToSaveLoad _file_to_saveload; ///< File to save or load in the openttd loop. -- cgit v1.2.3-70-g09d2