mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Sync economy and calendar dates when loading old saves
parent
50cd213602
commit
fd20ada1f9
|
@ -60,6 +60,7 @@
|
||||||
#include "../water.h"
|
#include "../water.h"
|
||||||
#include "../timer/timer.h"
|
#include "../timer/timer.h"
|
||||||
#include "../timer/timer_game_calendar.h"
|
#include "../timer/timer_game_calendar.h"
|
||||||
|
#include "../timer/timer_game_economy.h"
|
||||||
#include "../timer/timer_game_tick.h"
|
#include "../timer/timer_game_tick.h"
|
||||||
|
|
||||||
#include "saveload_internal.h"
|
#include "saveload_internal.h"
|
||||||
|
@ -734,6 +735,13 @@ bool AfterLoadGame()
|
||||||
* must be done before loading sprites as some newgrfs check it */
|
* must be done before loading sprites as some newgrfs check it */
|
||||||
TimerGameCalendar::SetDate(TimerGameCalendar::date, TimerGameCalendar::date_fract);
|
TimerGameCalendar::SetDate(TimerGameCalendar::date, TimerGameCalendar::date_fract);
|
||||||
|
|
||||||
|
/* Update economy year. If we don't have a separate economy date saved, follow the calendar date. */
|
||||||
|
if (IsSavegameVersionBefore(SLV_ECONOMY_DATE)) {
|
||||||
|
TimerGameEconomy::SetDate(TimerGameCalendar::date.base(), TimerGameCalendar::date_fract);
|
||||||
|
} else {
|
||||||
|
TimerGameEconomy::SetDate(TimerGameEconomy::date, TimerGameEconomy::date_fract);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Force the old behaviour for compatibility reasons with old savegames. As new
|
* Force the old behaviour for compatibility reasons with old savegames. As new
|
||||||
* settings can only be loaded from new savegames loading old savegames with new
|
* settings can only be loaded from new savegames loading old savegames with new
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include "compat/misc_sl_compat.h"
|
#include "compat/misc_sl_compat.h"
|
||||||
|
|
||||||
#include "../timer/timer_game_calendar.h"
|
#include "../timer/timer_game_calendar.h"
|
||||||
|
#include "../timer/timer_game_economy.h"
|
||||||
#include "../zoom_func.h"
|
#include "../zoom_func.h"
|
||||||
#include "../window_gui.h"
|
#include "../window_gui.h"
|
||||||
#include "../window_func.h"
|
#include "../window_func.h"
|
||||||
|
@ -85,6 +86,8 @@ static const SaveLoad _date_desc[] = {
|
||||||
SLEG_VAR("date_fract", TimerGameCalendar::date_fract, SLE_UINT16),
|
SLEG_VAR("date_fract", TimerGameCalendar::date_fract, SLE_UINT16),
|
||||||
SLEG_CONDVAR("tick_counter", TimerGameTick::counter, SLE_FILE_U16 | SLE_VAR_U64, SL_MIN_VERSION, SLV_U64_TICK_COUNTER),
|
SLEG_CONDVAR("tick_counter", TimerGameTick::counter, SLE_FILE_U16 | SLE_VAR_U64, SL_MIN_VERSION, SLV_U64_TICK_COUNTER),
|
||||||
SLEG_CONDVAR("tick_counter", TimerGameTick::counter, SLE_UINT64, SLV_U64_TICK_COUNTER, SL_MAX_VERSION),
|
SLEG_CONDVAR("tick_counter", TimerGameTick::counter, SLE_UINT64, SLV_U64_TICK_COUNTER, SL_MAX_VERSION),
|
||||||
|
SLEG_CONDVAR("economy_date", TimerGameEconomy::date, SLE_INT32, SLV_ECONOMY_DATE, SL_MAX_VERSION),
|
||||||
|
SLEG_CONDVAR("economy_date_fract", TimerGameEconomy::date_fract, SLE_UINT16, SLV_ECONOMY_DATE, SL_MAX_VERSION),
|
||||||
SLEG_CONDVAR("age_cargo_skip_counter", _age_cargo_skip_counter, SLE_UINT8, SL_MIN_VERSION, SLV_162),
|
SLEG_CONDVAR("age_cargo_skip_counter", _age_cargo_skip_counter, SLE_UINT8, SL_MIN_VERSION, SLV_162),
|
||||||
SLEG_CONDVAR("cur_tileloop_tile", _cur_tileloop_tile, SLE_FILE_U16 | SLE_VAR_U32, SL_MIN_VERSION, SLV_6),
|
SLEG_CONDVAR("cur_tileloop_tile", _cur_tileloop_tile, SLE_FILE_U16 | SLE_VAR_U32, SL_MIN_VERSION, SLV_6),
|
||||||
SLEG_CONDVAR("cur_tileloop_tile", _cur_tileloop_tile, SLE_UINT32, SLV_6, SL_MAX_VERSION),
|
SLEG_CONDVAR("cur_tileloop_tile", _cur_tileloop_tile, SLE_UINT32, SLV_6, SL_MAX_VERSION),
|
||||||
|
|
|
@ -366,6 +366,7 @@ enum SaveLoadVersion : uint16_t {
|
||||||
SLV_TIMETABLE_START_TICKS, ///< 321 PR#11468 Convert timetable start from a date to ticks.
|
SLV_TIMETABLE_START_TICKS, ///< 321 PR#11468 Convert timetable start from a date to ticks.
|
||||||
SLV_TIMETABLE_START_TICKS_FIX, ///< 322 PR#11557 Fix for missing convert timetable start from a date to ticks.
|
SLV_TIMETABLE_START_TICKS_FIX, ///< 322 PR#11557 Fix for missing convert timetable start from a date to ticks.
|
||||||
SLV_TIMETABLE_TICKS_TYPE, ///< 323 PR#11435 Convert timetable current order time to ticks.
|
SLV_TIMETABLE_TICKS_TYPE, ///< 323 PR#11435 Convert timetable current order time to ticks.
|
||||||
|
SLV_ECONOMY_DATE, ///< 324 PR#10700 Split calendar and economy timers and dates.
|
||||||
|
|
||||||
SL_MAX_VERSION, ///< Highest possible saveload version
|
SL_MAX_VERSION, ///< Highest possible saveload version
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue