From 2f495c015ac9d4cf3a6a3881577fd5a3867701e7 Mon Sep 17 00:00:00 2001 From: Tyler Trahan Date: Mon, 24 Apr 2023 13:33:03 -0400 Subject: [PATCH] Fix 7c6bf97: Don't change date and shift dates in the wrong order (#10711) --- src/cheat_gui.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cheat_gui.cpp b/src/cheat_gui.cpp index 48a2fd5073..07863ee84c 100644 --- a/src/cheat_gui.cpp +++ b/src/cheat_gui.cpp @@ -112,13 +112,13 @@ static int32 ClickChangeDateCheat(int32 new_value, int32 change_direction) ConvertDateToYMD(TimerGameCalendar::date, &ymd); Date new_date = ConvertYMDToDate(new_value, ymd.month, ymd.day); - /* Change the date. */ - TimerGameCalendar::SetDate(new_date, TimerGameCalendar::date_fract); - - /* Shift cached dates. */ + /* Shift cached dates before we change the date. */ for (auto v : Vehicle::Iterate()) v->ShiftDates(new_date - TimerGameCalendar::date); LinkGraphSchedule::instance.ShiftDates(new_date - TimerGameCalendar::date); + /* Now it's safe to actually change the date. */ + TimerGameCalendar::SetDate(new_date, TimerGameCalendar::date_fract); + EnginesMonthlyLoop(); SetWindowDirty(WC_STATUS_BAR, 0); InvalidateWindowClassesData(WC_BUILD_STATION, 0);