OpenTTD Source
20240917-master-g9ab0a47812
|
Go to the documentation of this file.
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);
171 void Game::ResetConfig()
263 bool Game::HasGameLibrary(
const ContentInfo *ci,
bool md5sum)
void Change(const U &new_value)
Change the value of the variable.
@ OWNER_DEITY
The object is owned by a superuser / goal 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-...
@ WC_SCRIPT_DEBUG
Script debug window; Window numbers:
static bool IsPaused()
Checks if the Game Script is paused.
std::map< std::string, class ScriptInfo *, CaseInsensitiveComparator > ScriptInfoList
Type for the list of scripts.
void InsertEvent(class ScriptEvent *event)
Insert an event for this script.
void GameLoop()
Run the GameLoop of a script.
void Save()
Call the script Save function and save all data in the savegame.
Class to backup a specific variable and restore it later.
class GameLibrary * FindLibrary(const std::string &library, int version)
Find a library in the pool.
uint DoScan(Subdirectory sd)
Perform the scanning of a particular subdirectory.
bool _network_server
network-server is active
static uint frame_counter
Tick counter for the Game code.
void Unpause()
Resume execution of the script.
class GameConfig * game_config
settings for gamescript
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.
static void Unpause()
Resume execution of the Game Script.
void RescanDir()
Rescan the script dir.
#define Debug(category, level, format_string,...)
Ouptut a line of debugging information.
void Pause()
Suspends the script for the current tick and then pause the execution of script.
const ScriptInfoList * GetUniqueInfoList()
Get the list of the latest version of all registered scripts.
int version
Version of the script.
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.
static GameScannerLibrary * GetScannerLibrary()
Gets the ScriptScanner instance that is used to find Game Libraries.
static class GameInfo * FindInfo(const std::string &name, int version, bool force_exact_match)
Wrapper function for GameScannerInfo::FindInfo.
static class GameScannerLibrary * scanner_library
Scanner for GS Libraries.
static void GetConsoleLibraryList(std::back_insert_iterator< std::string > &output_iterator)
Wrapper function for GameScanner::GetConsoleLibraryList.
static void GetConsoleList(std::back_insert_iterator< std::string > &output_iterator, bool newest_only)
Wrapper function for GameScanner::GetConsoleList.
Container for all important information about a piece of content.
static void SaveEmpty()
Don't save any data in the savegame.
static void Pause()
Suspends the Game Script and then pause the execution of the script.
void Initialize(class GameInfo *info)
Initialize the script and prepare it for its first run.
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.
static void Uninitialize(bool keepConfig)
Uninitialize the Game system.
bool _networking
are we in networking mode?
@ GAME
Scan for game scripts.
Runtime information about a game script like a pointer to the squirrel vm and the current state.
@ PFE_GAMESCRIPT
Game script execution.
CompanyID _current_company
Company currently doing an action.
@ WC_GAME_OPTIONS
Game options window; Window numbers:
static void GameLoop()
Called every game-tick to let Game do something.
bool HasScript(const struct ContentInfo *ci, bool md5sum)
Check whether we have a script with the exact characteristics as ci.
void AnchorUnchangeableSettings()
As long as the default of a setting has not been changed, the value of the setting is not stored.
const ScriptInfoList * GetInfoList()
Get the list of all registered scripts.
static class GameInfo * info
Current selected GameInfo.
void Restore()
Restore the variable.
bool ResetInfo(bool force_exact_match)
When ever the Game Scanner is reloaded, all infos become invalid.
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...
static GameConfig * GetConfig(ScriptSettingSource source=SSS_DEFAULT)
Get the config of a company.
static bool HasGame(const struct ContentInfo *ci, bool md5sum)
Wrapper function for GameScanner::HasGame.
All static information from an Game like name, version, etc.
std::string name
Full name of the script.
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.
void LoadOnStack(ScriptData *data)
Store loaded data on the stack.
static void Save()
Save data from a GameScript to a savegame.
All static information from an Game library like name, version, etc.
static GameScannerInfo * GetScannerInfo()
Gets the ScriptScanner instance that is used to find Game scripts.
bool IsPaused()
Checks if the script is paused.
void CollectGarbage()
Let the VM collect any garbage.
static const ScriptInfoList * GetUniqueInfoList()
Wrapper function for GameScanner::GetUniqueInfoList.
static class GameLibrary * FindLibrary(const std::string &library, int version)
Wrapper function for GameScanner::FindLibrary.
@ WC_SCRIPT_SETTINGS
Script settings; Window numbers:
@ WC_SCRIPT_LIST
Scripts list; Window numbers:
void SetWindowClassesDirty(WindowClass cls)
Mark all windows of a particular class as dirty (in need of repainting)
@ SSS_FORCE_GAME
Get the Script config from the current game.
static void StartNew()
Start up a new GameScript.
bool HasScript() const
Is this config attached to an Script? In other words, is there a Script that is assigned to this slot...
static class GameScannerInfo * scanner_info
Scanner for Game scripts.
GameSettings _settings_newgame
Game settings for new games (updated from the intro screen).
static class GameInstance * instance
Instance to the current active Game.
static const ScriptInfoList * GetInfoList()
Wrapper function for GameScanner::GetInfoList.
const std::string & GetName() const
Get the name of the Script.
static void Initialize()
Initialize the Game system.