10 #include "../stdafx.h"
11 #include "../core/backup_type.hpp"
12 #include "../company_base.h"
13 #include "../company_func.h"
14 #include "../network/network.h"
15 #include "../window_func.h"
16 #include "../framerate_type.h"
23 #include "../safeguards.h"
77 if (_game_mode == GM_MENU)
return;
84 if (
info ==
nullptr)
return;
95 config->SetToLoadData(
nullptr);
148 ScriptObjectRef counter(event);
166 void Game::ResetConfig()
258 bool Game::HasGameLibrary(
const ContentInfo *ci,
bool md5sum)
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.
All static information from an Game like name, version, etc.
Runtime information about a game script like a pointer to the squirrel vm and the current state.
void Initialize(class GameInfo *info)
Initialize the script and prepare it for its first run.
All static information from an Game library like name, version, etc.
class GameInfo * FindInfo(const std::string &name, int version, bool force_exact_match)
Check if we have a game by name and version available in our list.
class GameLibrary * FindLibrary(const std::string &library, int version)
Find a library in the pool.
static void StartNew()
Start up a new GameScript.
static class GameInfo * info
Current selected GameInfo.
static class GameInfo * FindInfo(const std::string &name, int version, bool force_exact_match)
Wrapper function for GameScannerInfo::FindInfo.
static GameScannerLibrary * GetScannerLibrary()
Gets the ScriptScanner instance that is used to find Game Libraries.
static void Unpause()
Resume execution of the Game Script.
static bool IsPaused()
Checks if the Game Script is paused.
static uint frame_counter
Tick counter for the Game code.
static void Save()
Save data from a GameScript to a savegame.
static class GameScannerInfo * scanner_info
Scanner for Game scripts.
static class GameInstance * instance
Instance to the current active Game.
static class GameScannerLibrary * scanner_library
Scanner for GS Libraries.
static bool HasGame(const struct ContentInfo *ci, bool md5sum)
Wrapper function for GameScanner::HasGame.
static class GameLibrary * FindLibrary(const std::string &library, int version)
Wrapper function for GameScanner::FindLibrary.
static const ScriptInfoList * GetUniqueInfoList()
Wrapper function for GameScanner::GetUniqueInfoList.
static void Pause()
Suspends the Game Script and then pause the execution of the script.
static void NewEvent(class ScriptEvent *event)
Queue a new event for a Game Script.
static void GameLoop()
Called every game-tick to let Game do something.
static void GetConsoleList(std::back_insert_iterator< std::string > &output_iterator, bool newest_only)
Wrapper function for GameScanner::GetConsoleList.
static void GetConsoleLibraryList(std::back_insert_iterator< std::string > &output_iterator)
Wrapper function for GameScanner::GetConsoleLibraryList.
static void Uninitialize(bool keepConfig)
Uninitialize the Game system.
static const ScriptInfoList * GetInfoList()
Wrapper function for GameScanner::GetInfoList.
static void Initialize()
Initialize the Game system.
static GameScannerInfo * GetScannerInfo()
Gets the ScriptScanner instance that is used to find Game scripts.
@ SSS_FORCE_GAME
Get the Script config from the current game.
void AnchorUnchangeableSettings()
As long as the default of a setting has not been changed, the value of the setting is not stored.
bool HasScript() const
Is this config attached to an Script? In other words, is there a Script that is assigned to this slot...
void Change(std::optional< const std::string > name, int version=-1, bool force_exact_match=false)
Set another Script to be loaded in this slot.
const std::string & GetName() const
Get the name of the Script.
void InsertEvent(class ScriptEvent *event)
Insert an event for this script.
void Unpause()
Resume execution of the script.
bool IsPaused()
Checks if the script is paused.
void CollectGarbage()
Let the VM collect any garbage.
static void SaveEmpty()
Don't save any data in the savegame.
void LoadOnStack(ScriptData *data)
Store loaded data on the stack.
void Save()
Call the script Save function and save all data in the savegame.
void Pause()
Suspends the script for the current tick and then pause the execution of script.
void GameLoop()
Run the GameLoop of a script.
bool HasScript(const struct ContentInfo *ci, bool md5sum)
Check whether we have a script with the exact characteristics as ci.
const ScriptInfoList * GetUniqueInfoList()
Get the list of the latest version of all registered scripts.
const ScriptInfoList * GetInfoList()
Get the list of all registered scripts.
void RescanDir()
Rescan the script dir.
void GetConsoleList(std::back_insert_iterator< std::string > &output_iterator, bool newest_only) const
Get the list of registered scripts to print on the console.
uint DoScan(Subdirectory sd)
Perform the scanning of a particular subdirectory.
@ GAME
Scan for game scripts.
CompanyID _current_company
Company currently doing an action.
@ OWNER_DEITY
The object is owned by a superuser / goal script.
#define Debug(category, level, format_string,...)
Ouptut a line of debugging information.
@ PFE_GAMESCRIPT
Game script execution.
Base functions for all Games.
GameConfig stores the configuration settings of every Game.
GameInfo keeps track of all information of an Game, like Author, Description, ...
The GameInstance tracks games.
declarations of the class for Game scanner
bool _networking
are we in networking mode?
bool _network_server
network-server is active
std::map< std::string, class ScriptInfo *, CaseInsensitiveComparator > ScriptInfoList
Type for the list of scripts.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
GameSettings _settings_newgame
Game settings for new games (updated from the intro screen).
Class to backup a specific variable and restore it later.
void Change(const U &new_value)
Change the value of the variable.
void Restore()
Restore the variable.
Container for all important information about a piece of content.
class GameConfig * game_config
settings for gamescript
void SetWindowClassesDirty(WindowClass cls)
Mark all windows of a particular class as dirty (in need of repainting)
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-...
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...
@ WC_SCRIPT_SETTINGS
Script settings; Window numbers:
@ WC_SCRIPT_LIST
Scripts list; Window numbers:
@ WC_GAME_OPTIONS
Game options window; Window numbers:
@ WC_SCRIPT_DEBUG
Script debug window; Window numbers: