Codechange: Use cached town, station, industry names for list window sorting
[openttd-github.git] / src / misc.cpp
blobc56eb6a38d3133034fafd2f8b672497d5aa9e00d
1 /*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6 */
8 /** @file misc.cpp Misc functions that shouldn't be here. */
10 #include "stdafx.h"
11 #include "landscape.h"
12 #include "news_func.h"
13 #include "ai/ai.hpp"
14 #include "ai/ai_gui.hpp"
15 #include "newgrf.h"
16 #include "newgrf_house.h"
17 #include "economy_func.h"
18 #include "date_func.h"
19 #include "texteff.hpp"
20 #include "gfx_func.h"
21 #include "gamelog.h"
22 #include "animated_tile_func.h"
23 #include "tilehighlight_func.h"
24 #include "network/network_func.h"
25 #include "window_func.h"
26 #include "core/pool_type.hpp"
27 #include "game/game.hpp"
28 #include "linkgraph/linkgraphschedule.h"
29 #include "station_kdtree.h"
30 #include "town_kdtree.h"
31 #include "viewport_kdtree.h"
33 #include "safeguards.h"
36 extern TileIndex _cur_tileloop_tile;
37 extern void MakeNewgameSettingsLive();
39 void InitializeSound();
40 void InitializeMusic();
41 void InitializeVehicles();
42 void InitializeRailGui();
43 void InitializeRoadGui();
44 void InitializeAirportGui();
45 void InitializeDockGui();
46 void InitializeGraphGui();
47 void InitializeObjectGui();
48 void InitializeTownGui();
49 void InitializeIndustries();
50 void InitializeObjects();
51 void InitializeTrees();
52 void InitializeCompanies();
53 void InitializeCheats();
54 void InitializeNPF();
55 void InitializeOldNames();
57 void InitializeGame(uint size_x, uint size_y, bool reset_date, bool reset_settings)
59 /* Make sure there isn't any window that can influence anything
60 * related to the new game we're about to start/load. */
61 UnInitWindowSystem();
63 AllocateMap(size_x, size_y);
65 _pause_mode = PM_UNPAUSED;
66 _fast_forward = 0;
67 _tick_counter = 0;
68 _cur_tileloop_tile = 1;
69 _thd.redsq = INVALID_TILE;
70 if (reset_settings) MakeNewgameSettingsLive();
72 if (reset_date) {
73 SetDate(ConvertYMDToDate(_settings_game.game_creation.starting_year, 0, 1), 0);
74 InitializeOldNames();
77 LinkGraphSchedule::Clear();
78 PoolBase::Clean(PT_NORMAL);
80 RebuildStationKdtree();
81 RebuildTownKdtree();
82 RebuildViewportKdtree();
84 ResetPersistentNewGRFData();
86 InitializeSound();
87 InitializeMusic();
89 InitializeVehicles();
91 InitNewsItemStructs();
92 InitializeLandscape();
93 InitializeRailGui();
94 InitializeRoadGui();
95 InitializeAirportGui();
96 InitializeDockGui();
97 InitializeGraphGui();
98 InitializeObjectGui();
99 InitializeTownGui();
100 InitializeAIGui();
101 InitializeTrees();
102 InitializeIndustries();
103 InitializeObjects();
104 InitializeBuildingCounts();
106 InitializeNPF();
108 InitializeCompanies();
109 AI::Initialize();
110 Game::Initialize();
111 InitializeCheats();
113 InitTextEffects();
114 NetworkInitChatMessage();
115 InitializeAnimatedTiles();
117 InitializeEconomy();
119 ResetObjectToPlace();
121 GamelogReset();
122 GamelogStartAction(GLAT_START);
123 GamelogRevision();
124 GamelogMode();
125 GamelogGRFAddList(_grfconfig);
126 GamelogStopAction();