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/>.
10 /** @file game.hpp Base functions for all Games. */
15 #include "../script/script_infolist.hpp"
16 #include "../script/api/script_event_types.hpp"
17 #include "../string.h"
18 #include "../saveload/saveload_buffer.h"
21 * Main Game class. Contains all functions needed to start, stop, save and load Game Scripts.
26 * Called every game-tick to let Game do something.
28 static void GameLoop();
31 * Initialize the Game system.
33 static void Initialize();
36 * Start up a new GameScript.
38 static void StartNew();
41 * Uninitialize the Game system.
43 static void Uninitialize(bool keepConfig
);
46 * Suspends the Game Script and then pause the execution of the script. The
47 * script will not be resumed from its suspended state until the script
53 * Resume execution of the Game Script. This function will not actually execute
54 * the script, but set a flag so that the script is executed my the usual
55 * mechanism that executes the script.
57 static void Unpause();
60 * Checks if the Game Script is paused.
61 * @return true if the Game Script is paused, otherwise false.
63 static bool IsPaused();
66 * Queue a new event for a Game Script.
68 static void NewEvent(class ScriptEvent
*event
);
71 * Get the current GameScript instance.
73 static class GameInstance
*GetGameInstance() { return Game::instance
; }
76 * Get the current GameInfo.
78 static const class GameInfo
*GetInfo() { return Game::info
; }
81 static void ResetConfig();
84 * Save data from a GameScript to a savegame.
86 static void Save(SaveDumper
*dumper
);
89 * Load data for a GameScript from a savegame.
91 static void Load(LoadBuffer
*reader
, int version
);
93 /** Wrapper function for GameScanner::GetConsoleList */
94 static void GetConsoleList (stringb
*buf
, bool newest_only
= false);
95 /** Wrapper function for GameScanner::GetConsoleLibraryList */
96 static void GetConsoleLibraryList (stringb
*buf
);
97 /** Wrapper function for GameScanner::GetUniqueInfoList */
98 static const ScriptInfoList::List
*GetUniqueInfoList();
99 /** Wrapper function for GameScannerInfo::FindInfo */
100 static class GameInfo
*FindInfo(const char *name
, int version
, bool force_exact_match
);
101 /** Wrapper function for GameScanner::FindLibrary */
102 static class GameLibrary
*FindLibrary(const char *library
, int version
);
105 * Get the current active instance.
107 static class GameInstance
*GetInstance() { return Game::instance
; }
109 #if defined(ENABLE_NETWORK)
110 /** Wrapper function for GameScanner::HasGame */
111 static bool HasGame(const struct ContentInfo
*ci
, bool md5sum
);
112 static bool HasGameLibrary(const ContentInfo
*ci
, bool md5sum
);
114 static const char *FindInfoMainScript (const ContentInfo
*ci
);
115 static const char *FindLibraryMainScript (const ContentInfo
*ci
);
118 static uint frame_counter
; ///< Tick counter for the Game code.
119 static class GameInstance
*instance
; ///< Instance to the current active Game.
120 static const class GameInfo
*info
; ///< Current selected GameInfo.
123 #endif /* GAME_HPP */