| 90 | } |
| 91 | |
| 92 | void InitializeGame(uint size_x, uint size_y, bool reset_date, bool reset_settings) |
| 93 | { |
| 94 | /* Make sure there isn't any window that can influence anything |
| 95 | * related to the new game we're about to start/load. */ |
| 96 | UnInitWindowSystem(); |
| 97 | |
| 98 | Map::Allocate(size_x, size_y); |
| 99 | |
| 100 | _pause_mode = {}; |
| 101 | _game_speed = 100; |
| 102 | TimerGameTick::counter = 0; |
| 103 | TimerGameEconomy::days_since_last_month = 0; |
| 104 | _cur_tileloop_tile = TileIndex{1}; |
| 105 | _thd.redsq = INVALID_TILE; |
| 106 | if (reset_settings) MakeNewgameSettingsLive(); |
| 107 | |
| 108 | _newgrf_profilers.clear(); |
| 109 | |
| 110 | if (reset_date) { |
| 111 | TimerGameCalendar::Date new_date = TimerGameCalendar::ConvertYMDToDate(_settings_game.game_creation.starting_year, 0, 1); |
| 112 | TimerGameCalendar::SetDate(new_date, 0); |
| 113 | |
| 114 | if (TimerGameEconomy::UsingWallclockUnits()) { |
| 115 | /* If using wallclock units, start at year 1. */ |
| 116 | TimerGameEconomy::SetDate(TimerGameEconomy::ConvertYMDToDate(TimerGameEconomy::Year{1}, 0, 1), 0); |
| 117 | } else { |
| 118 | /* Otherwise, we always keep the economy date synced with the calendar date. */ |
| 119 | TimerGameEconomy::SetDate(TimerGameEconomy::Date{new_date.base()}, 0); |
| 120 | } |
| 121 | InitializeOldNames(); |
| 122 | } |
| 123 | |
| 124 | LinkGraphSchedule::Clear(); |
| 125 | PoolBase::Clean(PoolType::Normal); |
| 126 | |
| 127 | RebuildStationKdtree(); |
| 128 | RebuildTownKdtree(); |
| 129 | RebuildViewportKdtree(); |
| 130 | |
| 131 | ResetPersistentNewGRFData(); |
| 132 | |
| 133 | InitializeSound(); |
| 134 | InitializeMusic(); |
| 135 | |
| 136 | InitializeVehicles(); |
| 137 | |
| 138 | InitNewsItemStructs(); |
| 139 | InitializeLandscape(); |
| 140 | InitializeRailGui(); |
| 141 | InitializeRoadGui(); |
| 142 | InitializeAirportGui(); |
| 143 | InitializeDockGui(); |
| 144 | InitializeGraphGui(); |
| 145 | InitializeObjectGui(); |
| 146 | InitializeTownGui(); |
| 147 | InitializeScriptGui(); |
| 148 | InitializeTrees(); |
| 149 | InitializeIndustries(); |
no test coverage detected