12 #include "../stdafx.h" 13 #include "../core/backup_type.hpp" 14 #include "../company_base.h" 15 #include "../company_func.h" 16 #include "../network/network.h" 17 #include "../window_func.h" 24 #include "../safeguards.h" 35 if (Game::instance == NULL)
return;
56 if (Game::scanner_info == NULL) {
59 Game::scanner_info->Initialize();
61 Game::scanner_library->Initialize();
67 if (Game::instance != NULL)
return;
74 if (info == NULL)
return;
95 Game::instance = NULL;
105 Game::scanner_info = NULL;
106 Game::scanner_library = NULL;
121 if (Game::instance != NULL) Game::instance->
Pause();
126 if (Game::instance != NULL) Game::instance->
Unpause();
131 return Game::instance != NULL? Game::instance->
IsPaused() :
false;
146 if (Game::instance == NULL) {
159 void Game::ResetConfig()
167 if (Game::instance != NULL) {
169 Game::instance = NULL;
172 }
else if (Game::instance != NULL) {
202 Game::instance->
Save();
213 Game::instance->
Load(version);
243 return Game::scanner_info->
FindInfo(name, version, force_exact_match);
248 return Game::scanner_library->
FindLibrary(library, version);
251 #if defined(ENABLE_NETWORK) 261 return Game::scanner_info->
HasScript(ci, md5sum);
264 bool Game::HasGameLibrary(
const ContentInfo *ci,
bool md5sum)
266 return Game::scanner_library->
HasScript(ci, md5sum);
const ScriptInfoList * GetUniqueInfoList()
Get the list of the latest version of all registered scripts.
static class GameScannerLibrary * scanner_library
Scanner for GS Libraries.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
static void NewEvent(class ScriptEvent *event)
Queue a new event for a Game Script.
bool _networking
are we in networking mode?
int version
Version of the script.
static void GameLoop()
Called every game-tick to let Game do something.
GameConfig stores the configuration settings of every Game.
class GameLibrary * FindLibrary(const char *library, int version)
Find a library in the pool.
void InsertEvent(class ScriptEvent *event)
Insert an event for this script.
std::map< const char *, class ScriptInfo *, StringCompare > ScriptInfoList
A list that maps AI names to their AIInfo object.
static void Uninitialize(bool keepConfig)
Uninitialize the Game system.
class GameInfo * FindInfo(const char *nameParam, int versionParam, bool force_exact_match)
Check if we have a game by name and version available in our list.
const ScriptInfoList * GetInfoList()
Get the list of all registered scripts.
static bool HasGame(const struct ContentInfo *ci, bool md5sum)
Wrapper function for GameScanner::HasGame.
static GameScannerInfo * GetScannerInfo()
Gets the ScriptScanner instance that is used to find Game scripts.
void Change(const char *name, int version=-1, bool force_exact_match=false, bool is_random=false)
Set another Script to be loaded in this slot.
void Change(const U &new_value)
Change the value of the variable.
static const ScriptInfoList * GetUniqueInfoList()
Wrapper function for GameScanner::GetUniqueInfoList.
bool ResetInfo(bool force_exact_match)
When ever the Game Scanner is reloaded, all infos become invalid.
static GameConfig * GetConfig(ScriptSettingSource source=SSS_DEFAULT)
Get the config of a company.
AI debug window; Window numbers:
All static information from an Game like name, version, etc.
void Save()
Call the script Save function and save all data in the savegame.
void Unpause()
Resume execution of the script.
const char * GetName() const
Get the name of the Script.
Class to backup a specific variable and restore it later.
static class GameInfo * info
Current selected GameInfo.
static char * GetConsoleList(char *p, const char *last, bool newest_only=false)
Wrapper function for GameScanner::GetConsoleList.
static class GameInstance * instance
Instance to the current active Game.
The object is owned by a superuser / goal script.
All static information from an Game library like name, version, etc.
static void Save()
Save data from a GameScript to a savegame.
void InvalidateWindowClassesData(WindowClass cls, int data, bool gui_scope)
Mark window data of all windows of a given class as invalid (in need of re-computing) Note that by de...
Runtime information about a game script like a pointer to the squirrel vm and the current state...
bool HasScript(const struct ContentInfo *ci, bool md5sum)
Check whether we have a script with the exact characteristics as ci.
static char * GetConsoleLibraryList(char *p, const char *last)
Wrapper function for GameScanner::GetConsoleLibraryList.
static class GameInfo * FindInfo(const char *name, int version, bool force_exact_match)
Wrapper function for GameScannerInfo::FindInfo.
static bool IsPaused()
Checks if the Game Script is paused.
bool HasScript() const
Is this config attached to an Script? In other words, is there a Script that is assigned to this slot...
GameSettings _settings_newgame
Game settings for new games (updated from the intro screen).
static class GameScannerInfo * scanner_info
Scanner for Game scripts.
The GameInstance tracks games.
static class GameLibrary * FindLibrary(const char *library, int version)
Wrapper function for GameScanner::FindLibrary.
static const ScriptInfoList * GetInfoList()
Wrapper function for GameScanner::GetInfoList.
bool IsPaused()
Checks if the script is paused.
static void StartNew()
Start up a new GameScript.
static uint frame_counter
Tick counter for the Game code.
class GameConfig * game_config
settings for gamescript
void RescanDir()
Rescan the script dir.
uint DoScan(Subdirectory sd)
Perform the scanning of a particular subdirectory.
const char * name
Full name of the script.
#define DEBUG(name, level,...)
Output a line of debugging information.
static void Initialize()
Initialize the Game system.
void Pause()
Suspends the script for the current tick and then pause the execution of script.
GameInfo keeps track of all information of an Game, like Author, Description, ... ...
static void SaveEmpty()
Don't save any data in the savegame.
declarations of the class for Game scanner
CompanyByte _current_company
Company currently doing an action.
void AnchorUnchangeableSettings()
As long as the default of a setting has not been changed, the value of the setting is not stored...
char * GetConsoleList(char *p, const char *last, bool newest_only) const
Get the list of registered scripts to print on the console.
static void Unpause()
Resume execution of the Game Script.
static GameScannerLibrary * GetScannerLibrary()
Gets the ScriptScanner instance that is used to find Game Libraries.
Base functions for all Games.
bool _network_server
network-server is active
static void Load(int version)
Load data for a GameScript from a savegame.
AI settings; Window numbers:
void Restore()
Restore the variable.
void Initialize(class GameInfo *info)
Initialize the script and prepare it for its first run.
static void LoadEmpty()
Load and discard data from a savegame.
void Load(int version)
Load data from a savegame and store it on the stack.
void SetWindowClassesDirty(WindowClass cls)
Mark all windows of a particular class as dirty (in need of repainting)
Get the Script config from the current game.
void CollectGarbage() const
Let the VM collect any garbage.
Container for all important information about a piece of content.
static void Pause()
Suspends the Game Script and then pause the execution of the script.
void GameLoop()
Run the GameLoop of a script.
void InvalidateWindowData(WindowClass cls, WindowNumber number, int data, bool gui_scope)
Mark window data of the window of a given class and specific window number as invalid (in need of re-...