Go to the documentation of this file.
1 /* $Id: game.hpp 25114 2013-03-22 21:21:45Z frosch $ */
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 <>.
8  */
12 #ifndef GAME_HPP
13 #define GAME_HPP
15 #include "../core/string_compare_type.hpp"
16 #include "game_scanner.hpp"
17 #include <map>
20 typedef std::map<const char *, class ScriptInfo *, StringCompare> ScriptInfoList;
22 #include "../script/api/script_event_types.hpp"
27 class Game {
28 public:
32  static void GameLoop();
37  static void Initialize();
42  static void StartNew();
47  static void Uninitialize(bool keepConfig);
54  static void Pause();
61  static void Unpause();
67  static bool IsPaused();
72  static void NewEvent(class ScriptEvent *event);
77  static class GameInstance *GetGameInstance() { return Game::instance; }
82  static class GameInfo *GetInfo() { return Game::info; }
84  static void Rescan();
85  static void ResetConfig();
90  static void Save();
95  static void Load(int version);
98  static char *GetConsoleList(char *p, const char *last, bool newest_only = false);
100  static char *GetConsoleLibraryList(char *p, const char *last);
102  static const ScriptInfoList *GetInfoList();
104  static const ScriptInfoList *GetUniqueInfoList();
106  static class GameInfo *FindInfo(const char *name, int version, bool force_exact_match);
108  static class GameLibrary *FindLibrary(const char *library, int version);
113  static class GameInstance *GetInstance() { return Game::instance; }
115 #if defined(ENABLE_NETWORK)
117  static bool HasGame(const struct ContentInfo *ci, bool md5sum);
118  static bool HasGameLibrary(const ContentInfo *ci, bool md5sum);
119 #endif
125 private:
126  static uint frame_counter;
127  static class GameInstance *instance;
130  static class GameInfo *info;
131 };
133 #endif /* GAME_HPP */
static class GameScannerLibrary * scanner_library
Scanner for GS Libraries.
Definition: game.hpp:129
static void NewEvent(class ScriptEvent *event)
Queue a new event for a Game Script.
Definition: game_core.cpp:134
int version
Version of the script.
static void GameLoop()
Called every game-tick to let Game do something.
Definition: game_core.cpp:32
std::map< const char *, class ScriptInfo *, StringCompare > ScriptInfoList
A list that maps AI names to their AIInfo object.
Definition: ai.hpp:21
static void Uninitialize(bool keepConfig)
Uninitialize the Game system.
Definition: game_core.cpp:90
static bool HasGame(const struct ContentInfo *ci, bool md5sum)
Wrapper function for GameScanner::HasGame.
Definition: game_core.cpp:259
static GameScannerInfo * GetScannerInfo()
Gets the ScriptScanner instance that is used to find Game scripts.
Definition: game_core.cpp:271
static const ScriptInfoList * GetUniqueInfoList()
Wrapper function for GameScanner::GetUniqueInfoList.
Definition: game_core.cpp:236
All static information from an Game like name, version, etc.
Definition: game_info.hpp:18
static class GameInfo * info
Current selected GameInfo.
Definition: game.hpp:130
static char * GetConsoleList(char *p, const char *last, bool newest_only=false)
Wrapper function for GameScanner::GetConsoleList.
Definition: game_core.cpp:221
static class GameInstance * instance
Instance to the current active Game.
Definition: game.hpp:127
All static information from an Game library like name, version, etc.
Definition: game_info.hpp:52
static void Save()
Save data from a GameScript to a savegame.
Definition: game_core.cpp:198
Runtime information about a game script like a pointer to the squirrel vm and the current state...
static char * GetConsoleLibraryList(char *p, const char *last)
Wrapper function for GameScanner::GetConsoleLibraryList.
Definition: game_core.cpp:226
static class GameInfo * FindInfo(const char *name, int version, bool force_exact_match)
Wrapper function for GameScannerInfo::FindInfo.
Definition: game_core.cpp:241
static bool IsPaused()
Checks if the Game Script is paused.
Definition: game_core.cpp:129
Main Game class.
Definition: game.hpp:27
static class GameScannerInfo * scanner_info
Scanner for Game scripts.
Definition: game.hpp:128
static class GameLibrary * FindLibrary(const char *library, int version)
Wrapper function for GameScanner::FindLibrary.
Definition: game_core.cpp:246
static const ScriptInfoList * GetInfoList()
Wrapper function for GameScanner::GetInfoList.
Definition: game_core.cpp:231
static class GameInstance * GetInstance()
Get the current active instance.
Definition: game.hpp:113
static class GameInfo * GetInfo()
Get the current GameInfo.
Definition: game.hpp:82
static void StartNew()
Start up a new GameScript.
Definition: game_core.cpp:65
static uint frame_counter
Tick counter for the Game code.
Definition: game.hpp:126
const char * name
Full name of the script.
static void Initialize()
Initialize the Game system.
Definition: game_core.cpp:50
static class GameInstance * GetGameInstance()
Get the current GameScript instance.
Definition: game.hpp:77
declarations of the class for Game scanner
std::map< const char *, class ScriptInfo *, StringCompare > ScriptInfoList
A list that maps AI names to their AIInfo object.
Definition: game.hpp:20
static void Unpause()
Resume execution of the Game Script.
Definition: game_core.cpp:124
static GameScannerLibrary * GetScannerLibrary()
Gets the ScriptScanner instance that is used to find Game Libraries.
Definition: game_core.cpp:275
static void Load(int version)
Load data for a GameScript from a savegame.
Definition: game_core.cpp:209
Container for all important information about a piece of content.
Definition: tcp_content.h:58
static void Pause()
Suspends the Game Script and then pause the execution of the script.
Definition: game_core.cpp:119