(svn r27724) -Cleanup: Remove pointless usage of IsOpenTTDBaseGRF. System GRFs are...
[openttd.git] / src / game / game.hpp
blobfaa9650bfed09f3a1f59a69fb243917a0dc9c83d
1 /* $Id$ */
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 */
10 /** @file game.hpp Base functions for all Games. */
12 #ifndef GAME_HPP
13 #define GAME_HPP
15 #include "../core/string_compare_type.hpp"
16 #include "game_scanner.hpp"
17 #include <map>
19 /** A list that maps AI names to their AIInfo object. */
20 typedef std::map<const char *, class ScriptInfo *, StringCompare> ScriptInfoList;
22 #include "../script/api/script_event_types.hpp"
24 /**
25 * Main Game class. Contains all functions needed to start, stop, save and load Game Scripts.
27 class Game {
28 public:
29 /**
30 * Called every game-tick to let Game do something.
32 static void GameLoop();
34 /**
35 * Initialize the Game system.
37 static void Initialize();
39 /**
40 * Start up a new GameScript.
42 static void StartNew();
44 /**
45 * Uninitialize the Game system.
47 static void Uninitialize(bool keepConfig);
49 /**
50 * Suspends the Game Script and then pause the execution of the script. The
51 * script will not be resumed from its suspended state until the script
52 * has been unpaused.
54 static void Pause();
56 /**
57 * Resume execution of the Game Script. This function will not actually execute
58 * the script, but set a flag so that the script is executed my the usual
59 * mechanism that executes the script.
61 static void Unpause();
63 /**
64 * Checks if the Game Script is paused.
65 * @return true if the Game Script is paused, otherwise false.
67 static bool IsPaused();
69 /**
70 * Queue a new event for a Game Script.
72 static void NewEvent(class ScriptEvent *event);
74 /**
75 * Get the current GameScript instance.
77 static class GameInstance *GetGameInstance() { return Game::instance; }
79 /**
80 * Get the current GameInfo.
82 static class GameInfo *GetInfo() { return Game::info; }
84 static void Rescan();
85 static void ResetConfig();
87 /**
88 * Save data from a GameScript to a savegame.
90 static void Save();
92 /**
93 * Load data for a GameScript from a savegame.
95 static void Load(int version);
97 /** Wrapper function for GameScanner::GetConsoleList */
98 static char *GetConsoleList(char *p, const char *last, bool newest_only = false);
99 /** Wrapper function for GameScanner::GetConsoleLibraryList */
100 static char *GetConsoleLibraryList(char *p, const char *last);
101 /** Wrapper function for GameScanner::GetInfoList */
102 static const ScriptInfoList *GetInfoList();
103 /** Wrapper function for GameScanner::GetUniqueInfoList */
104 static const ScriptInfoList *GetUniqueInfoList();
105 /** Wrapper function for GameScannerInfo::FindInfo */
106 static class GameInfo *FindInfo(const char *name, int version, bool force_exact_match);
107 /** Wrapper function for GameScanner::FindLibrary */
108 static class GameLibrary *FindLibrary(const char *library, int version);
111 * Get the current active instance.
113 static class GameInstance *GetInstance() { return Game::instance; }
115 #if defined(ENABLE_NETWORK)
116 /** Wrapper function for GameScanner::HasGame */
117 static bool HasGame(const struct ContentInfo *ci, bool md5sum);
118 static bool HasGameLibrary(const ContentInfo *ci, bool md5sum);
119 #endif
120 /** Gets the ScriptScanner instance that is used to find Game scripts */
121 static GameScannerInfo *GetScannerInfo();
122 /** Gets the ScriptScanner instance that is used to find Game Libraries */
123 static GameScannerLibrary *GetScannerLibrary();
125 private:
126 static uint frame_counter; ///< Tick counter for the Game code.
127 static class GameInstance *instance; ///< Instance to the current active Game.
128 static class GameScannerInfo *scanner_info; ///< Scanner for Game scripts.
129 static class GameScannerLibrary *scanner_library; ///< Scanner for GS Libraries.
130 static class GameInfo *info; ///< Current selected GameInfo.
133 #endif /* GAME_HPP */