OpenTTD Source: src/game/game.hpp Source File

OpenTTD Source 13.1

game.hpp
Go to the documentation of this file.
1 /*
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/>.
6 */
7
10 #ifndef GAME_HPP
11 #define GAME_HPP
12
13 #include "../core/string_compare_type.hpp"
14 #include "game_scanner.hpp"
15 #include <map>
16
18 typedef std::map<const char *, class ScriptInfo *, StringCompare> ScriptInfoList;
19
20 #include "../script/api/script_event_types.hpp"
21
25 class Game {
26 public:
30 static void GameLoop();
31
35 static void Initialize();
36
40 static void StartNew();
41
45 static void Uninitialize(bool keepConfig);
46
52 static void Pause();
53
59 static void Unpause();
60
65 static bool IsPaused();
66
70 static void NewEvent(class ScriptEvent *event);
71
75 static class GameInstance *GetGameInstance() { return Game::instance; }
76
80 static class GameInfo *GetInfo() { return Game::info; }
81
82 static void Rescan();
83 static void ResetConfig();
84
88 static void Save();
89
91 static std::string GetConsoleList(bool newest_only = false);
93 static std::string GetConsoleLibraryList();
95 static const ScriptInfoList *GetInfoList();
97 static const ScriptInfoList *GetUniqueInfoList();
99 static class GameInfo *FindInfo(const char *name, int version, bool force_exact_match);
101 static class GameLibrary *FindLibrary(const char *library, int version);
102
106 static class GameInstance *GetInstance() { return Game::instance; }
107
109 static bool HasGame(const struct ContentInfo *ci, bool md5sum);
110 static bool HasGameLibrary(const ContentInfo *ci, bool md5sum);
112 static GameScannerInfo *GetScannerInfo();
114 static GameScannerLibrary *GetScannerLibrary();
115
116 private:
117 static uint frame_counter;
118 static class GameInstance *instance;
119 static class GameScannerInfo *scanner_info;
120 static class GameScannerLibrary *scanner_library;
121 static class GameInfo *info;
122 };
123
124 #endif /* GAME_HPP */
Game::FindInfo
static class GameInfo * FindInfo(const char *name, int version, bool force_exact_match)
Wrapper function for GameScannerInfo::FindInfo.
Definition: game_core.cpp:242
Game::IsPaused
static bool IsPaused()
Checks if the Game Script is paused.
Definition: game_core.cpp:141
Game::GetGameInstance
static class GameInstance * GetGameInstance()
Get the current GameScript instance.
Definition: game.hpp:75
Game::GetInfo
static class GameInfo * GetInfo()
Get the current GameInfo.
Definition: game.hpp:80
Game::frame_counter
static uint frame_counter
Tick counter for the Game code.
Definition: game.hpp:117
Game::GetConsoleList
static std::string GetConsoleList(bool newest_only=false)
Wrapper function for GameScanner::GetConsoleList.
Definition: game_core.cpp:222
Game::GetConsoleLibraryList
static std::string GetConsoleLibraryList()
Wrapper function for GameScanner::GetConsoleLibraryList.
Definition: game_core.cpp:227
GameScannerInfo
Definition: game_scanner.hpp:15
Game::Unpause
static void Unpause()
Resume execution of the Game Script.
Definition: game_core.cpp:136
ScriptInfo::version
int version
Version of the script.
Definition: script_info.hpp:161
Game::GetScannerLibrary
static GameScannerLibrary * GetScannerLibrary()
Gets the ScriptScanner instance that is used to find Game Libraries.
Definition: game_core.cpp:272
ScriptInfoList
std::map< const char *, class ScriptInfo *, StringCompare > ScriptInfoList
A list that maps AI names to their AIInfo object.
Definition: ai.hpp:19
Game::scanner_library
static class GameScannerLibrary * scanner_library
Scanner for GS Libraries.
Definition: game.hpp:120
ContentInfo
Container for all important information about a piece of content.
Definition: tcp_content_type.h:50
Game::Pause
static void Pause()
Suspends the Game Script and then pause the execution of the script.
Definition: game_core.cpp:131
ScriptInfoList
std::map< const char *, class ScriptInfo *, StringCompare > ScriptInfoList
A list that maps AI names to their AIInfo object.
Definition: game.hpp:18
Game::NewEvent
static void NewEvent(class ScriptEvent *event)
Queue a new event for a Game Script.
Definition: game_core.cpp:146
Game::Uninitialize
static void Uninitialize(bool keepConfig)
Uninitialize the Game system.
Definition: game_core.cpp:102
GameInstance
Runtime information about a game script like a pointer to the squirrel vm and the current state.
Definition: game_instance.hpp:16
game_scanner.hpp
Game::GameLoop
static void GameLoop()
Called every game-tick to let Game do something.
Definition: game_core.cpp:31
Game::info
static class GameInfo * info
Current selected GameInfo.
Definition: game.hpp:121
Game::HasGame
static bool HasGame(const struct ContentInfo *ci, bool md5sum)
Wrapper function for GameScanner::HasGame.
Definition: game_core.cpp:258
GameInfo
All static information from an Game like name, version, etc.
Definition: game_info.hpp:16
Game::Save
static void Save()
Save data from a GameScript to a savegame.
Definition: game_core.cpp:211
GameLibrary
All static information from an Game library like name, version, etc.
Definition: game_info.hpp:50
Game::GetScannerInfo
static GameScannerInfo * GetScannerInfo()
Gets the ScriptScanner instance that is used to find Game scripts.
Definition: game_core.cpp:268
Game::GetUniqueInfoList
static const ScriptInfoList * GetUniqueInfoList()
Wrapper function for GameScanner::GetUniqueInfoList.
Definition: game_core.cpp:237
GameScannerLibrary
Definition: game_scanner.hpp:37
ScriptInfo::name
const char * name
Full name of the script.
Definition: script_info.hpp:156
Game::GetInstance
static class GameInstance * GetInstance()
Get the current active instance.
Definition: game.hpp:106
Game
Main Game class.
Definition: game.hpp:25
Game::StartNew
static void StartNew()
Start up a new GameScript.
Definition: game_core.cpp:72
Game::scanner_info
static class GameScannerInfo * scanner_info
Scanner for Game scripts.
Definition: game.hpp:119
Game::instance
static class GameInstance * instance
Instance to the current active Game.
Definition: game.hpp:118
Game::FindLibrary
static class GameLibrary * FindLibrary(const char *library, int version)
Wrapper function for GameScanner::FindLibrary.
Definition: game_core.cpp:247
Game::GetInfoList
static const ScriptInfoList * GetInfoList()
Wrapper function for GameScanner::GetInfoList.
Definition: game_core.cpp:232
Game::Initialize
static void Initialize()
Initialize the Game system.
Definition: game_core.cpp:57