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 "../core/string_compare_type.hpp"
14 #include "game_scanner.hpp"
17 /** A list that maps AI names to their AIInfo object. */
18 typedef std::map
<const char *, class ScriptInfo
*, StringCompare
> ScriptInfoList
;
20 #include "../script/api/script_event_types.hpp"
23 * Main Game class. Contains all functions needed to start, stop, save and load Game Scripts.
28 * Called every game-tick to let Game do something.
30 static void GameLoop();
33 * Initialize the Game system.
35 static void Initialize();
38 * Start up a new GameScript.
40 static void StartNew();
43 * Uninitialize the Game system.
45 static void Uninitialize(bool keepConfig
);
48 * Suspends the Game Script and then pause the execution of the script. The
49 * script will not be resumed from its suspended state until the script
55 * Resume execution of the Game Script. This function will not actually execute
56 * the script, but set a flag so that the script is executed by the usual
57 * mechanism that executes the script.
59 static void Unpause();
62 * Checks if the Game Script is paused.
63 * @return true if the Game Script is paused, otherwise false.
65 static bool IsPaused();
68 * Queue a new event for a Game Script.
70 static void NewEvent(class ScriptEvent
*event
);
73 * Get the current GameScript instance.
75 static class GameInstance
*GetGameInstance() { return Game::instance
; }
78 * Get the current GameInfo.
80 static class GameInfo
*GetInfo() { return Game::info
; }
83 static void ResetConfig();
86 * Save data from a GameScript to a savegame.
91 * Load data for a GameScript from a savegame.
93 static void Load(int version
);
95 /** Wrapper function for GameScanner::GetConsoleList */
96 static char *GetConsoleList(char *p
, const char *last
, bool newest_only
= false);
97 /** Wrapper function for GameScanner::GetConsoleLibraryList */
98 static char *GetConsoleLibraryList(char *p
, const char *last
);
99 /** Wrapper function for GameScanner::GetInfoList */
100 static const ScriptInfoList
*GetInfoList();
101 /** Wrapper function for GameScanner::GetUniqueInfoList */
102 static const ScriptInfoList
*GetUniqueInfoList();
103 /** Wrapper function for GameScannerInfo::FindInfo */
104 static class GameInfo
*FindInfo(const char *name
, int version
, bool force_exact_match
);
105 /** Wrapper function for GameScanner::FindLibrary */
106 static class GameLibrary
*FindLibrary(const char *library
, int version
);
109 * Get the current active instance.
111 static class GameInstance
*GetInstance() { return Game::instance
; }
113 /** Wrapper function for GameScanner::HasGame */
114 static bool HasGame(const struct ContentInfo
*ci
, bool md5sum
);
115 static bool HasGameLibrary(const ContentInfo
*ci
, bool md5sum
);
116 /** Gets the ScriptScanner instance that is used to find Game scripts */
117 static GameScannerInfo
*GetScannerInfo();
118 /** Gets the ScriptScanner instance that is used to find Game Libraries */
119 static GameScannerLibrary
*GetScannerLibrary();
122 static uint frame_counter
; ///< Tick counter for the Game code.
123 static class GameInstance
*instance
; ///< Instance to the current active Game.
124 static class GameScannerInfo
*scanner_info
; ///< Scanner for Game scripts.
125 static class GameScannerLibrary
*scanner_library
; ///< Scanner for GS Libraries.
126 static class GameInfo
*info
; ///< Current selected GameInfo.
129 #endif /* GAME_HPP */