OpenTTD Source  12.0-beta2
misc.cpp
Go to the documentation of this file.
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  */
7 
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"
29 #include "station_kdtree.h"
30 #include "town_kdtree.h"
31 #include "viewport_kdtree.h"
32 #include "newgrf_profiling.h"
33 
34 #include "safeguards.h"
35 
36 
37 extern TileIndex _cur_tileloop_tile;
38 extern void MakeNewgameSettingsLive();
39 
40 void InitializeSound();
41 void InitializeMusic();
42 void InitializeVehicles();
43 void InitializeRailGui();
44 void InitializeRoadGui();
45 void InitializeAirportGui();
46 void InitializeDockGui();
47 void InitializeGraphGui();
48 void InitializeObjectGui();
49 void InitializeTownGui();
50 void InitializeIndustries();
51 void InitializeObjects();
52 void InitializeTrees();
53 void InitializeCompanies();
54 void InitializeCheats();
55 void InitializeNPF();
56 void InitializeOldNames();
57 
58 void InitializeGame(uint size_x, uint size_y, bool reset_date, bool reset_settings)
59 {
60  /* Make sure there isn't any window that can influence anything
61  * related to the new game we're about to start/load. */
63 
64  AllocateMap(size_x, size_y);
65 
67  _game_speed = 100;
68  _tick_counter = 0;
69  _cur_tileloop_tile = 1;
70  _thd.redsq = INVALID_TILE;
71  if (reset_settings) MakeNewgameSettingsLive();
72 
73  _newgrf_profilers.clear();
74 
75  if (reset_date) {
78  }
79 
82 
83  RebuildStationKdtree();
84  RebuildTownKdtree();
85  RebuildViewportKdtree();
86 
88 
89  InitializeSound();
91 
92  InitializeVehicles();
93 
95  InitializeLandscape();
97  InitializeRoadGui();
98  InitializeAirportGui();
99  InitializeDockGui();
100  InitializeGraphGui();
102  InitializeTownGui();
103  InitializeAIGui();
104  InitializeTrees();
105  InitializeIndustries();
107  InitializeBuildingCounts();
108 
109  InitializeNPF();
110 
112  AI::Initialize();
115 
116  InitTextEffects();
119 
121 
123 
124  GamelogReset();
126  GamelogRevision();
127  GamelogMode();
130 }
game.hpp
InitializeCompanies
void InitializeCompanies()
Initialize the pool of companies.
Definition: company_cmd.cpp:613
LinkGraphSchedule::Clear
static void Clear()
Clear all link graphs and jobs from the schedule.
Definition: linkgraphschedule.cpp:120
TileIndex
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:83
newgrf_house.h
station_kdtree.h
GamelogMode
void GamelogMode()
Logs a change in game mode (scenario editor or game)
Definition: gamelog.cpp:455
NetworkInitChatMessage
void NetworkInitChatMessage()
Initialize all buffers of the chat visualisation.
Definition: network_chat_gui.cpp:114
ResetPersistentNewGRFData
void ResetPersistentNewGRFData()
Reset NewGRF data which is stored persistently in savegames.
Definition: newgrf.cpp:8655
SetDate
void SetDate(Date date, DateFract fract)
Set the date.
Definition: date.cpp:37
ai_gui.hpp
InitNewsItemStructs
void InitNewsItemStructs()
Initialize the news-items data structures.
Definition: news_gui.cpp:614
UnInitWindowSystem
void UnInitWindowSystem()
Close down the windowing system.
Definition: window.cpp:1844
economy_func.h
gamelog.h
GameSettings::game_creation
GameCreationSettings game_creation
settings used during the creation of a game (map)
Definition: settings_type.h:576
ai.hpp
PM_UNPAUSED
@ PM_UNPAUSED
A normal unpaused game.
Definition: openttd.h:61
gfx_func.h
InitializeOldNames
void InitializeOldNames()
Initialize the old names table memory.
Definition: strings_sl.cpp:110
InitializeEconomy
void InitializeEconomy()
Resets economy to initial values.
Definition: economy.cpp:938
tilehighlight_func.h
ConvertYMDToDate
Date ConvertYMDToDate(Year year, Month month, Day day)
Converts a tuple of Year, Month and Day to a Date.
Definition: date.cpp:149
_pause_mode
PauseMode _pause_mode
The current pause mode.
Definition: gfx.cpp:47
AI::Initialize
static void Initialize()
Initialize the AI system.
Definition: ai_core.cpp:161
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition: settings.cpp:53
GamelogStartAction
void GamelogStartAction(GamelogActionType at)
Stores information about new action, but doesn't allocate it Action is allocated only when there is a...
Definition: gamelog.cpp:69
_tick_counter
uint16 _tick_counter
Ever incrementing (and sometimes wrapping) tick counter for setting off various events.
Definition: date.cpp:30
safeguards.h
PoolBase::Clean
static void Clean(PoolType)
Clean all pools of given type.
Definition: pool_func.cpp:30
date_func.h
linkgraphschedule.h
stdafx.h
InitializeCheats
void InitializeCheats()
Reinitialise all the cheats.
Definition: cheat.cpp:19
landscape.h
GamelogStopAction
void GamelogStopAction()
Stops logging of any changes.
Definition: gamelog.cpp:78
animated_tile_func.h
texteff.hpp
PT_NORMAL
@ PT_NORMAL
Normal pool containing game objects.
Definition: pool_type.hpp:19
InitializeMusic
void InitializeMusic()
Prepare the music system for use.
Definition: music_gui.cpp:442
InitializeAIGui
void InitializeAIGui()
Reset the AI windows to their initial state.
Definition: ai_gui.cpp:1554
newgrf.h
GamelogGRFAddList
void GamelogGRFAddList(const GRFConfig *newg)
Logs adding of list of GRFs.
Definition: gamelog.cpp:681
GameCreationSettings::starting_year
Year starting_year
starting date
Definition: settings_type.h:305
GamelogReset
void GamelogReset()
Resets and frees all memory allocated - used before loading or starting a new game.
Definition: gamelog.cpp:115
_grfconfig
GRFConfig * _grfconfig
First item in list of current GRF set up.
Definition: newgrf_config.cpp:171
window_func.h
INVALID_TILE
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition: tile_type.h:88
InitializeObjectGui
void InitializeObjectGui()
Reset all data of the object GUI.
Definition: object_gui.cpp:722
InitializeObjects
void InitializeObjects()
Initialize/reset the objects.
Definition: object_cmd.cpp:68
InitializeRailGui
void InitializeRailGui()
Initialize rail building GUI settings.
Definition: rail_gui.cpp:2064
GamelogRevision
void GamelogRevision()
Logs a change in game revision.
Definition: gamelog.cpp:438
pool_type.hpp
newgrf_profiling.h
AllocateMap
void AllocateMap(uint size_x, uint size_y)
(Re)allocates a map with the given dimension
Definition: map.cpp:39
ResetObjectToPlace
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
Definition: viewport.cpp:3423
InitializeAnimatedTiles
void InitializeAnimatedTiles()
Initialize all animated tile variables to some known begin point.
Definition: animated_tile.cpp:74
town_kdtree.h
network_func.h
TileHighlightData::redsq
TileIndex redsq
The tile that has to get a red selection.
Definition: tilehighlight_type.h:72
GLAT_START
@ GLAT_START
Game created.
Definition: gamelog.h:17
_game_speed
uint16 _game_speed
Current game-speed; 100 is 1x, 0 is infinite.
Definition: gfx.cpp:37
news_func.h
Game::Initialize
static void Initialize()
Initialize the Game system.
Definition: game_core.cpp:57