OpenTTD
misc.cpp
Go to the documentation of this file.
1 /* $Id$ */
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"
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 InitializeGraphGui();
46 void InitializeObjectGui();
47 void InitializeIndustries();
48 void InitializeObjects();
49 void InitializeTrees();
50 void InitializeCompanies();
51 void InitializeCheats();
52 void InitializeNPF();
53 void InitializeOldNames();
54 
55 void InitializeGame(uint size_x, uint size_y, bool reset_date, bool reset_settings)
56 {
57  /* Make sure there isn't any window that can influence anything
58  * related to the new game we're about to start/load. */
60 
61  AllocateMap(size_x, size_y);
62 
64  _fast_forward = 0;
65  _tick_counter = 0;
66  _cur_tileloop_tile = 1;
67  _thd.redsq = INVALID_TILE;
68  if (reset_settings) MakeNewgameSettingsLive();
69 
70  if (reset_date) {
73  }
74 
77 
79 
80  InitializeSound();
82 
83  InitializeVehicles();
84 
86  InitializeLandscape();
88  InitializeRoadGui();
89  InitializeAirportGui();
90  InitializeDockGui();
91  InitializeGraphGui();
94  InitializeTrees();
95  InitializeIndustries();
97  InitializeBuildingCounts();
98 
99  InitializeNPF();
100 
102  AI::Initialize();
105 
106  InitTextEffects();
107 #ifdef ENABLE_NETWORK
109 #endif /* ENABLE_NETWORK */
111 
113 
115 
116  GamelogReset();
118  GamelogRevision();
119  GamelogMode();
122 }
void InitializeRailGui()
Initialize rail building GUI settings.
Definition: rail_gui.cpp:1882
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition: settings.cpp:77
A normal unpaused game.
Definition: openttd.h:58
GRFConfig * _grfconfig
First item in list of current GRF set up.
Functions related to dates.
Window for configuring the AIs
Functions to be called to log possibly unsafe game events.
void InitializeOldNames()
Initialize the old names table memory.
Definition: strings_sl.cpp:118
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:71
void InitializeCompanies()
Initialize the pool of companies.
void GamelogRevision()
Logs a change in game revision.
Definition: gamelog.cpp:434
void AllocateMap(uint size_x, uint size_y)
(Re)allocates a map with the given dimension
Definition: map.cpp:41
static void Initialize()
Initialize the AI system.
Definition: ai_core.cpp:165
void InitializeAIGui()
Reset the AI windows to their initial state.
Definition: ai_gui.cpp:1548
static void Clean(PoolType)
Clean all pools of given type.
Definition: pool_func.cpp:32
void ResetPersistentNewGRFData()
Reset NewGRF data which is stored persistently in savegames.
Definition: newgrf.cpp:8361
Normal pool containing game objects.
Definition: pool_type.hpp:21
Defintion of Pool, structure used to access PoolItems, and PoolItem, base structure for Vehicle...
void InitializeEconomy()
Resets economy to initial values.
Definition: economy.cpp:951
Game created.
Definition: gamelog.h:19
void SetDate(Date date, DateFract fract)
Set the date.
Definition: date.cpp:37
Tile animation!
void GamelogReset()
Resets and frees all memory allocated - used before loading or starting a new game.
Definition: gamelog.cpp:112
void InitializeCheats()
Reinitialise all the cheats.
Definition: cheat.cpp:21
Functions related to NewGRF houses.
Functions related to the gfx engine.
void InitNewsItemStructs()
Initialize the news-items data structures.
Definition: news_gui.cpp:578
void GamelogMode()
Logs a change in game mode (scenario editor or game)
Definition: gamelog.cpp:451
Definition of base types and functions in a cross-platform compatible way.
A number of safeguards to prevent using unsafe methods.
Declaration of link graph schedule used for cargo distribution.
void GamelogGRFAddList(const GRFConfig *newg)
Logs adding of list of GRFs.
Definition: gamelog.cpp:677
PauseModeByte _pause_mode
The current pause mode.
Definition: gfx.cpp:48
void UnInitWindowSystem()
Close down the windowing system.
Definition: window.cpp:1898
void GamelogStopAction()
Stops logging of any changes.
Definition: gamelog.cpp:80
void InitializeMusic()
Prepare the music system for use.
Definition: music_gui.cpp:446
static void Initialize()
Initialize the Game system.
Definition: game_core.cpp:59
uint16 _tick_counter
Ever incrementing (and sometimes wrapping) tick counter for setting off various events.
Definition: date.cpp:30
void NetworkInitChatMessage()
Initialize all buffers of the chat visualisation.
void InitializeObjects()
Initialize/reset the objects.
Definition: object_cmd.cpp:70
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:80
Functions related to the economy.
TileIndex redsq
The tile that has to get a red selection.
void InitializeAnimatedTiles()
Initialize all animated tile variables to some known begin point.
static void Clear()
Clear all link graphs and jobs from the schedule.
Functions related to OTTD&#39;s landscape.
Base functions for all Games.
Network functions used by other parts of OpenTTD.
Base functions for all AIs.
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition: tile_type.h:85
GameCreationSettings game_creation
settings used during the creation of a game (map)
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows)...
Definition: viewport.cpp:3088
Date ConvertYMDToDate(Year year, Month month, Day day)
Converts a tuple of Year, Month and Day to a Date.
Definition: date.cpp:149
Functions related to tile highlights.
Window functions not directly related to making/drawing windows.
Functions related to text effects.
void InitializeObjectGui()
Reset all data of the object GUI.
Definition: object_gui.cpp:533
Functions related to news.
Year starting_year
starting date
Base for the NewGRF implementation.