Go to the documentation of this file.
1 /* $Id: misc.cpp 26482 2014-04-23 20:13:33Z rubidium $ */
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 <>.
8  */
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"
32 #include "safeguards.h"
35 extern TileIndex _cur_tileloop_tile;
36 extern void MakeNewgameSettingsLive();
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();
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. */
60  AllocateMap(size_x, size_y);
63  _fast_forward = 0;
64  _tick_counter = 0;
65  _cur_tileloop_tile = 1;
66  _thd.redsq = INVALID_TILE;
67  if (reset_settings) MakeNewgameSettingsLive();
69  if (reset_date) {
72  }
79  InitializeSound();
82  InitializeVehicles();
85  InitializeLandscape();
87  InitializeRoadGui();
88  InitializeAirportGui();
89  InitializeDockGui();
92  InitializeTrees();
93  InitializeIndustries();
95  InitializeBuildingCounts();
97  InitializeNPF();
100  AI::Initialize();
104  InitTextEffects();
107 #endif /* ENABLE_NETWORK */
114  GamelogReset();
116  GamelogRevision();
117  GamelogMode();
120 }
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:47
void InitializeCompanies()
Initialize the pool of companies.
void GamelogRevision()
Logs a change in game revision.
Definition: gamelog.cpp:410
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:160
void InitializeAIGui()
Reset the AI windows to their initial state.
Definition: ai_gui.cpp:1540
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:8166
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:943
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:88
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:561
void GamelogMode()
Logs a change in game mode (scenario editor or game)
Definition: gamelog.cpp:427
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:653
PauseModeByte _pause_mode
The current pause mode.
Definition: gfx.cpp:48
void UnInitWindowSystem()
Close down the windowing system.
Definition: window.cpp:1890
void GamelogStopAction()
Stops logging of any changes.
Definition: gamelog.cpp:56
void InitializeMusic()
Initialize the playlists.
Definition: music_gui.cpp:107
static void Initialize()
Initialize the Game system.
Definition: game_core.cpp:50
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:3211
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:536
Functions related to news.
Year starting_year
starting date
Base for the NewGRF implementation.