OpenTTD

misc.cpp
Go to the documentation of this file.
1 /* $Id: misc.cpp 26482 2014-04-23 20:13:33Z rubidium $ */
2
3 /*
4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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/>.
8 */
9
12 #include "stdafx.h"
13 #include "landscape.h"
14 #include "news_func.h"
15 #include "ai/ai.hpp"
16 #include "ai/ai_gui.hpp"
17 #include "newgrf.h"
18 #include "newgrf_house.h"
19 #include "economy_func.h"
20 #include "date_func.h"
21 #include "texteff.hpp"
22 #include "gfx_func.h"
23 #include "gamelog.h"
24 #include "animated_tile_func.h"
25 #include "tilehighlight_func.h"
26 #include "network/network_func.h"
27 #include "window_func.h"
28 #include "core/pool_type.hpp"
29 #include "game/game.hpp"
30 #include "linkgraph/linkgraphschedule.h"
31
32 #include "safeguards.h"
33
34
35 extern TileIndex _cur_tileloop_tile;
36 extern void MakeNewgameSettingsLive();
37
38 void InitializeSound();
39 void InitializeMusic();
40 void InitializeVehicles();
41 void InitializeRailGui();
42 void InitializeRoadGui();
43 void InitializeAirportGui();
44 void InitializeDockGui();
45 void InitializeObjectGui();
46 void InitializeIndustries();
47 void InitializeObjects();
48 void InitializeTrees();
49 void InitializeCompanies();
50 void InitializeCheats();
51 void InitializeNPF();
52 void InitializeOldNames();
53
54 void InitializeGame(uint size_x, uint size_y, bool reset_date, bool reset_settings)
55 {
56 /* Make sure there isn't any window that can influence anything
57 * related to the new game we're about to start/load. */
58 UnInitWindowSystem();
59
60 AllocateMap(size_x, size_y);
61
62 _pause_mode = PM_UNPAUSED;
63 _fast_forward = 0;
64 _tick_counter = 0;
65 _cur_tileloop_tile = 1;
66 _thd.redsq = INVALID_TILE;
67 if (reset_settings) MakeNewgameSettingsLive();
68
69 if (reset_date) {
70 SetDate(ConvertYMDToDate(_settings_game.game_creation.starting_year, 0, 1), 0);
71 InitializeOldNames();
72 }
73
74 LinkGraphSchedule::Clear();
75 PoolBase::Clean(PT_NORMAL);
76
77 ResetPersistentNewGRFData();
78
79 InitializeSound();
80 InitializeMusic();
81
82 InitializeVehicles();
83
84 InitNewsItemStructs();
85 InitializeLandscape();
86 InitializeRailGui();
87 InitializeRoadGui();
88 InitializeAirportGui();
89 InitializeDockGui();
90 InitializeObjectGui();
91 InitializeAIGui();
92 InitializeTrees();
93 InitializeIndustries();
94 InitializeObjects();
95 InitializeBuildingCounts();
96
97 InitializeNPF();
98
99 InitializeCompanies();
100 AI::Initialize();
101 Game::Initialize();
102 InitializeCheats();
103
104 InitTextEffects();
105 #ifdef ENABLE_NETWORK
106 NetworkInitChatMessage();
107 #endif /* ENABLE_NETWORK */
108 InitializeAnimatedTiles();
109
110 InitializeEconomy();
111
112 ResetObjectToPlace();
113
114 GamelogReset();
115 GamelogStartAction(GLAT_START);
116 GamelogRevision();
117 GamelogMode();
118 GamelogGRFAddList(_grfconfig);
119 GamelogStopAction();
120 }
InitializeRailGui
void InitializeRailGui()
Initialize rail building GUI settings.
Definition: rail_gui.cpp:1882
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition: settings.cpp:77
PM_UNPAUSED
A normal unpaused game.
Definition: openttd.h:58
_grfconfig
GRFConfig * _grfconfig
First item in list of current GRF set up.
Definition: newgrf_config.cpp:192
date_func.h
Functions related to dates.
ai_gui.hpp
Window for configuring the AIs
gamelog.h
Functions to be called to log possibly unsafe game events.
InitializeOldNames
void InitializeOldNames()
Initialize the old names table memory.
Definition: strings_sl.cpp:118
GamelogStartAction
void GamelogStartAction(GamelogActionType at)
Stores information about new action, but doesn&#39;t allocate it Action is allocated only when there is a...
Definition: gamelog.cpp:47
InitializeCompanies
void InitializeCompanies()
Initialize the pool of companies.
Definition: company_cmd.cpp:611
GamelogRevision
void GamelogRevision()
Logs a change in game revision.
Definition: gamelog.cpp:410
AllocateMap
void AllocateMap(uint size_x, uint size_y)
(Re)allocates a map with the given dimension
Definition: map.cpp:41
AI::Initialize
static void Initialize()
Initialize the AI system.
Definition: ai_core.cpp:160
InitializeAIGui
void InitializeAIGui()
Reset the AI windows to their initial state.
Definition: ai_gui.cpp:1540
PoolBase::Clean
static void Clean(PoolType)
Clean all pools of given type.
Definition: pool_func.cpp:32
ResetPersistentNewGRFData
void ResetPersistentNewGRFData()
Reset NewGRF data which is stored persistently in savegames.
Definition: newgrf.cpp:8166
PT_NORMAL
Normal pool containing game objects.
Definition: pool_type.hpp:21
pool_type.hpp
Defintion of Pool, structure used to access PoolItems, and PoolItem, base structure for Vehicle...
InitializeEconomy
void InitializeEconomy()
Resets economy to initial values.
Definition: economy.cpp:943
GLAT_START
Game created.
Definition: gamelog.h:19
SetDate
void SetDate(Date date, DateFract fract)
Set the date.
Definition: date.cpp:37
animated_tile_func.h
Tile animation!
GamelogReset
void GamelogReset()
Resets and frees all memory allocated - used before loading or starting a new game.
Definition: gamelog.cpp:88
InitializeCheats
void InitializeCheats()
Reinitialise all the cheats.
Definition: cheat.cpp:21
newgrf_house.h
Functions related to NewGRF houses.
gfx_func.h
Functions related to the gfx engine.
InitNewsItemStructs
void InitNewsItemStructs()
Initialize the news-items data structures.
Definition: news_gui.cpp:561
GamelogMode
void GamelogMode()
Logs a change in game mode (scenario editor or game)
Definition: gamelog.cpp:427
stdafx.h
Definition of base types and functions in a cross-platform compatible way.
safeguards.h
A number of safeguards to prevent using unsafe methods.
linkgraphschedule.h
Declaration of link graph schedule used for cargo distribution.
GamelogGRFAddList
void GamelogGRFAddList(const GRFConfig *newg)
Logs adding of list of GRFs.
Definition: gamelog.cpp:653
_pause_mode
PauseModeByte _pause_mode
The current pause mode.
Definition: gfx.cpp:48
UnInitWindowSystem
void UnInitWindowSystem()
Close down the windowing system.
Definition: window.cpp:1890
GamelogStopAction
void GamelogStopAction()
Stops logging of any changes.
Definition: gamelog.cpp:56
InitializeMusic
void InitializeMusic()
Initialize the playlists.
Definition: music_gui.cpp:107
Game::Initialize
static void Initialize()
Initialize the Game system.
Definition: game_core.cpp:50
_tick_counter
uint16 _tick_counter
Ever incrementing (and sometimes wrapping) tick counter for setting off various events.
Definition: date.cpp:30
NetworkInitChatMessage
void NetworkInitChatMessage()
Initialize all buffers of the chat visualisation.
Definition: network_chat_gui.cpp:118
InitializeObjects
void InitializeObjects()
Initialize/reset the objects.
Definition: object_cmd.cpp:70
TileIndex
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:80
economy_func.h
Functions related to the economy.
TileHighlightData::redsq
TileIndex redsq
The tile that has to get a red selection.
Definition: tilehighlight_type.h:72
InitializeAnimatedTiles
void InitializeAnimatedTiles()
Initialize all animated tile variables to some known begin point.
Definition: animated_tile.cpp:94
LinkGraphSchedule::Clear
static void Clear()
Clear all link graphs and jobs from the schedule.
Definition: linkgraphschedule.cpp:97
landscape.h
Functions related to OTTD&#39;s landscape.
game.hpp
Base functions for all Games.
network_func.h
Network functions used by other parts of OpenTTD.
ai.hpp
Base functions for all AIs.
INVALID_TILE
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition: tile_type.h:85
GameSettings::game_creation
GameCreationSettings game_creation
settings used during the creation of a game (map)
Definition: settings_type.h:544
ResetObjectToPlace
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows)...
Definition: viewport.cpp:3211
ConvertYMDToDate
Date ConvertYMDToDate(Year year, Month month, Day day)
Converts a tuple of Year, Month and Day to a Date.
Definition: date.cpp:149
tilehighlight_func.h
Functions related to tile highlights.
window_func.h
Window functions not directly related to making/drawing windows.
texteff.hpp
Functions related to text effects.
InitializeObjectGui
void InitializeObjectGui()
Reset all data of the object GUI.
Definition: object_gui.cpp:536
news_func.h
Functions related to news.
GameCreationSettings::starting_year
Year starting_year
starting date
Definition: settings_type.h:277
newgrf.h
Base for the NewGRF implementation.