* Set the starting year for a scenario. * @param year New starting year. */
| 1131 | * @param year New starting year. |
| 1132 | */ |
| 1133 | void SetStartingYear(TimerGameCalendar::Year year) |
| 1134 | { |
| 1135 | _settings_game.game_creation.starting_year = Clamp(year, CalendarTime::MIN_YEAR, CalendarTime::MAX_YEAR); |
| 1136 | TimerGameCalendar::Date new_calendar_date = TimerGameCalendar::ConvertYMDToDate(_settings_game.game_creation.starting_year, 0, 1); |
| 1137 | TimerGameEconomy::Date new_economy_date{new_calendar_date.base()}; |
| 1138 | |
| 1139 | /* We must set both Calendar and Economy dates to keep them in sync. Calendar first. */ |
| 1140 | TimerGameCalendar::SetDate(new_calendar_date, 0); |
| 1141 | |
| 1142 | /* If you open a savegame as a scenario, there may already be link graphs and/or vehicles. These use economy date. */ |
| 1143 | LinkGraphSchedule::instance.ShiftDates(new_economy_date - TimerGameEconomy::date); |
| 1144 | for (auto v : Vehicle::Iterate()) v->ShiftDates(new_economy_date - TimerGameEconomy::date); |
| 1145 | |
| 1146 | /* Only change the date after changing cached values above. */ |
| 1147 | TimerGameEconomy::SetDate(new_economy_date, 0); |
| 1148 | } |
| 1149 | |
| 1150 | /** |
| 1151 | * Choose the proper callback function for the main toolbar's help menu. |
no test coverage detected