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/>.
8 /** @file game.hpp Base functions for all Games. */
13 #include "game_scanner.hpp"
15 #include "../script/api/script_event_types.hpp"
18 * Main Game class. Contains all functions needed to start, stop, save and load Game Scripts.
23 * Called every game-tick to let Game do something.
25 static void GameLoop();
28 * Initialize the Game system.
30 static void Initialize();
33 * Start up a new GameScript.
35 static void StartNew();
38 * Uninitialize the Game system.
40 static void Uninitialize(bool keepConfig
);
43 * Suspends the Game Script and then pause the execution of the script. The
44 * script will not be resumed from its suspended state until the script
50 * Resume execution of the Game Script. This function will not actually execute
51 * the script, but set a flag so that the script is executed by the usual
52 * mechanism that executes the script.
54 static void Unpause();
57 * Checks if the Game Script is paused.
58 * @return true if the Game Script is paused, otherwise false.
60 static bool IsPaused();
63 * Queue a new event for a Game Script.
65 static void NewEvent(class ScriptEvent
*event
);
68 * Get the current GameScript instance.
70 static class GameInstance
*GetGameInstance() { return Game::instance
; }
73 * Get the current GameInfo.
75 static class GameInfo
*GetInfo() { return Game::info
; }
78 static void ResetConfig();
81 * Save data from a GameScript to a savegame.
85 /** Wrapper function for GameScanner::GetConsoleList */
86 static void GetConsoleList(std::back_insert_iterator
<std::string
> &output_iterator
, bool newest_only
);
87 /** Wrapper function for GameScanner::GetConsoleLibraryList */
88 static void GetConsoleLibraryList(std::back_insert_iterator
<std::string
> &output_iterator
);
89 /** Wrapper function for GameScanner::GetInfoList */
90 static const ScriptInfoList
*GetInfoList();
91 /** Wrapper function for GameScanner::GetUniqueInfoList */
92 static const ScriptInfoList
*GetUniqueInfoList();
93 /** Wrapper function for GameScannerInfo::FindInfo */
94 static class GameInfo
*FindInfo(const std::string
&name
, int version
, bool force_exact_match
);
95 /** Wrapper function for GameScanner::FindLibrary */
96 static class GameLibrary
*FindLibrary(const std::string
&library
, int version
);
99 * Get the current active instance.
101 static class GameInstance
*GetInstance() { return Game::instance
; }
103 /** Wrapper function for GameScanner::HasGame */
104 static bool HasGame(const struct ContentInfo
*ci
, bool md5sum
);
105 static bool HasGameLibrary(const ContentInfo
*ci
, bool md5sum
);
106 /** Gets the ScriptScanner instance that is used to find Game scripts */
107 static GameScannerInfo
*GetScannerInfo();
108 /** Gets the ScriptScanner instance that is used to find Game Libraries */
109 static GameScannerLibrary
*GetScannerLibrary();
112 static uint frame_counter
; ///< Tick counter for the Game code.
113 static class GameInstance
*instance
; ///< Instance to the current active Game.
114 static class GameScannerInfo
*scanner_info
; ///< Scanner for Game scripts.
115 static class GameScannerLibrary
*scanner_library
; ///< Scanner for GS Libraries.
116 static class GameInfo
*info
; ///< Current selected GameInfo.
119 #endif /* GAME_HPP */