|
OpenTTD Source 20260218-master-g2123fca5ea
|
#include <game.hpp>
Static Public Member Functions | |
| static void | GameLoop () |
| Called every game-tick to let Game do something. | |
| static void | Initialize () |
| Initialize the Game system. | |
| static void | StartNew () |
| Start up a new GameScript. | |
| static void | Uninitialize (bool keepConfig) |
| Uninitialize the Game system. | |
| static void | Pause () |
| Suspends the Game Script and then pause the execution of the script. | |
| static void | Unpause () |
| Resume execution of the Game Script. | |
| static bool | IsPaused () |
| Checks if the Game Script is paused. | |
| static void | NewEvent (class ScriptEvent *event) |
| Queue a new event for the game script. | |
| static class GameInfo * | GetInfo () |
| Get the current GameInfo. | |
| static void | Rescan () |
| Rescans all searchpaths for available Game scripts. | |
| static void | ResetConfig () |
| Reset all GameConfigs, and make them reload their GameInfo. | |
| static void | Save () |
| Save data from a GameScript to a savegame. | |
| static void | GetConsoleList (std::back_insert_iterator< std::string > &output_iterator, bool newest_only) |
| Get the list of registered scripts to print on the console. | |
| static void | GetConsoleLibraryList (std::back_insert_iterator< std::string > &output_iterator, bool newest_only) |
| Get the list of registered scripts to print on the console. | |
| static const ScriptInfoList * | GetInfoList () |
| Get the list of all registered scripts. | |
| static const ScriptInfoList * | GetUniqueInfoList () |
| Get the list of the latest version of all registered scripts. | |
| static class GameInfo * | FindInfo (const std::string &name, int version, bool force_exact_match) |
| Finds the appropriate ScriptInfo for a given script name and version. | |
| static class GameLibrary * | FindLibrary (const std::string &library, int version) |
| Find a library. | |
| static class GameInstance * | GetInstance () |
| Get the current active instance. | |
| static void | ResetInstance () |
| Reset the current active instance. | |
| static bool | HasGame (const ContentInfo &ci, bool md5sum) |
| Wrapper function for GameScanner::HasGame. | |
| static bool | HasGameLibrary (const ContentInfo &ci, bool md5sum) |
| Check whether we have an Game library with the exact characteristics as ci. | |
| static GameScannerInfo * | GetScannerInfo () |
| Gets the ScriptScanner instance that is used to find Game scripts. | |
| static GameScannerLibrary * | GetScannerLibrary () |
| Gets the ScriptScanner instance that is used to find Game Libraries. | |
Static Private Attributes | |
| static uint | frame_counter = 0 |
| Tick counter for the Game code. | |
| static std::unique_ptr< GameInstance > | instance = nullptr |
| Instance to the current active Game. | |
| static std::unique_ptr< GameScannerInfo > | scanner_info = nullptr |
| Scanner for Game scripts. | |
| static std::unique_ptr< GameScannerLibrary > | scanner_library = nullptr |
| Scanner for GS Libraries. | |
| static GameInfo * | info = nullptr |
| Current selected GameInfo. | |
|
static |
Finds the appropriate ScriptInfo for a given script name and version.
| name | The script name to find. |
| version | The version the script should have. |
| force_exact_match | Whether an exact match is required. |
Definition at line 223 of file game_core.cpp.
References scanner_info.
Referenced by GameConfig::FindInfo(), and GameConfig::ResetInfo().
|
static |
Find a library.
| library | The library name to find. |
| version | The version the library should have. |
Definition at line 228 of file game_core.cpp.
References scanner_library.
Referenced by GameInstance::FindLibrary().
|
static |
Called every game-tick to let Game do something.
Definition at line 31 of file game_core.cpp.
References _current_company, _network_server, _networking, Backup< T >::Change(), frame_counter, instance, OWNER_DEITY, PFE_GAMESCRIPT, Backup< T >::Restore(), and PerformanceMeasurer::SetInactive().
Referenced by _GenerateWorld(), and StateGameLoop().
|
static |
Get the list of registered scripts to print on the console.
| output_iterator | The iterator to write the output to. |
| newest_only | Whether to only show the newest scripts. |
Definition at line 208 of file game_core.cpp.
References scanner_library.
Referenced by ConListGameLibs().
|
static |
Get the list of registered scripts to print on the console.
| output_iterator | The iterator to write the output to. |
| newest_only | Whether to only show the newest scripts. |
Definition at line 203 of file game_core.cpp.
References scanner_info.
Referenced by ConListGame(), and ShowHelp().
|
inlinestatic |
Get the current GameInfo.
Definition at line 73 of file game.hpp.
References info.
Referenced by GameInstance::Died(), ScriptDebugWindow::GetWidgetString(), LoadTranslations(), SerializeNetworkGameInfo(), and SurveyGameScript().
|
static |
Get the list of all registered scripts.
Definition at line 213 of file game_core.cpp.
References scanner_info.
Referenced by ScriptListWindow::ScriptListWindow().
|
inlinestatic |
Get the current active instance.
Definition at line 109 of file game.hpp.
References instance.
Referenced by _GenerateWorld(), CcGame(), ScriptListWindow::ChangeScript(), ScriptDebugWindow::IsDead(), GSConfigWindow::IsEditable(), ScriptDebugWindow::IsValidDebugCompany(), ScriptDebugWindow::SelectValidDebugCompany(), ShowScriptDebugWindowIfScriptError(), and ScriptDebugWindow::UpdateGSButtonState().
|
static |
Gets the ScriptScanner instance that is used to find Game scripts.
Get the scanner info for Game scripts.
Definition at line 265 of file game_core.cpp.
References scanner_info.
Referenced by ContentInfo::GetTextfile().
|
static |
Gets the ScriptScanner instance that is used to find Game Libraries.
Get the scanner info for Game script libraries.
Definition at line 274 of file game_core.cpp.
References scanner_library.
Referenced by ContentInfo::GetTextfile().
|
static |
Get the list of the latest version of all registered scripts.
Definition at line 218 of file game_core.cpp.
References scanner_info.
Referenced by ScriptListWindow::ScriptListWindow().
|
static |
Wrapper function for GameScanner::HasGame.
Check whether we have an Game with the exact characteristics as ci.
| ci | the characteristics to search on (shortname and md5sum) |
| md5sum | whether to check the MD5 checksum |
Definition at line 245 of file game_core.cpp.
References scanner_info.
Referenced by GetHasContentProcforContentType().
|
static |
Check whether we have an Game library with the exact characteristics as ci.
| ci | the characteristics to search on (shortname and md5sum) |
| md5sum | whether to check the MD5 checksum |
Definition at line 256 of file game_core.cpp.
References scanner_library.
Referenced by GetHasContentProcforContentType().
|
static |
Initialize the Game system.
Definition at line 57 of file game_core.cpp.
References TarScanner::DoScan(), frame_counter, TarScanner::Game, instance, scanner_info, scanner_library, and Uninitialize().
Referenced by AfterNewGRFScan::OnNewGRFsScanned(), and ShowHelp().
|
static |
Checks if the Game Script is paused.
Definition at line 131 of file game_core.cpp.
References instance.
Referenced by ScriptDebugWindow::OnClick(), and ScriptDebugWindow::OnInvalidateData().
|
static |
Queue a new event for the game script.
| event | The event. |
Definition at line 136 of file game_core.cpp.
References _current_company, _network_server, _networking, instance, OWNER_DEITY, and Backup< T >::Restore().
Referenced by AdvertiseIndustryOpening(), AircraftEntersTerminal(), Subsidy::AwardTo(), ChangeIndustryProduction(), CmdCompanyCtrl(), CmdFoundTown(), CmdGoalQuestionAnswer(), CmdRenameCompany(), CmdRenamePresident(), CmdStoryPageButton(), CompanyCheckBankrupt(), CrashAirplane(), CreateSubsidy(), DisasterTick_Ufo(), DispatchLeftClickEvent(), DoStartupNewCompany(), FloodVehicle(), GenerateCompanyName(), ServerNetworkAdminSocketHandler::Receive_ADMIN_GAMESCRIPT(), RoadVehArrivesAt(), ShipArrivesAt(), TownActionBuyRights(), TownActionRoadRebuild(), TrainCrashed(), and TrainEnterStation().
|
static |
Suspends the Game Script and then pause the execution of the script.
The script will not be resumed from its suspended state until the script has been unpaused.
Definition at line 121 of file game_core.cpp.
References instance.
Referenced by ScriptDebugWindow::OnInvalidateData().
|
static |
Rescans all searchpaths for available Game scripts.
If a used Game script is no longer found it is removed from the config.
Definition at line 177 of file game_core.cpp.
References TarScanner::DoScan(), TarScanner::Game, InvalidateWindowClassesData(), InvalidateWindowData(), ResetConfig(), scanner_info, scanner_library, SetWindowClassesDirty(), WC_GAME_OPTIONS, WC_SCRIPT_DEBUG, WC_SCRIPT_LIST, and WC_SCRIPT_SETTINGS.
Referenced by NetworkContentDownloadStatusWindow::Close(), ConRescanGame(), and Uninitialize().
|
static |
Reset all GameConfigs, and make them reload their GameInfo.
If the GameInfo could no longer be found, an error is reported to the user.
Definition at line 156 of file game_core.cpp.
References _settings_game, _settings_newgame, Debug, info, instance, and ResetInstance().
Referenced by Rescan().
|
static |
Reset the current active instance.
Definition at line 233 of file game_core.cpp.
References info, and instance.
Referenced by ScriptListWindow::ChangeScript(), ResetConfig(), and Uninitialize().
|
static |
Save data from a GameScript to a savegame.
Definition at line 192 of file game_core.cpp.
References _current_company, _network_server, _networking, instance, OWNER_DEITY, Backup< T >::Restore(), and ScriptInstance::SaveEmpty().
|
static |
Start up a new GameScript.
Definition at line 72 of file game_core.cpp.
References _current_company, _network_server, _networking, ScriptConfig::AnchorUnchangeableSettings(), Backup< T >::Change(), GameConfig::GetConfig(), GameConfig::GetInfo(), info, instance, InvalidateWindowClassesData(), OWNER_DEITY, Backup< T >::Restore(), ScriptConfig::SSS_FORCE_GAME, and WC_SCRIPT_DEBUG.
Referenced by _GenerateWorld(), ScriptListWindow::ChangeScript(), and StartScripts().
|
static |
Uninitialize the Game system.
| keepConfig | Should we keep GameConfigs, or can we free that memory? |
Definition at line 102 of file game_core.cpp.
References _current_company, _settings_game, _settings_newgame, Rescan(), ResetInstance(), Backup< T >::Restore(), scanner_info, and scanner_library.
Referenced by Initialize(), AfterNewGRFScan::OnNewGRFsScanned(), ShowHelp(), and ShutdownGame().
|
static |
Resume execution of the Game Script.
This function will not actually execute the script, but set a flag so that the script is executed by the usual mechanism that executes the script.
Definition at line 126 of file game_core.cpp.
References instance.
Referenced by ScriptDebugWindow::OnClick().
|
staticprivate |
Tick counter for the Game code.
Definition at line 125 of file game.hpp.
Referenced by GameLoop(), and Initialize().
|
staticprivate |
Current selected GameInfo.
Definition at line 129 of file game.hpp.
Referenced by GetInfo(), ResetConfig(), ResetInstance(), and StartNew().
|
staticprivate |
Instance to the current active Game.
Definition at line 126 of file game.hpp.
Referenced by GameLoop(), GetInstance(), Initialize(), IsPaused(), NewEvent(), Pause(), ResetConfig(), ResetInstance(), Save(), StartNew(), and Unpause().
|
staticprivate |
Scanner for Game scripts.
Definition at line 127 of file game.hpp.
Referenced by FindInfo(), GetConsoleList(), GetInfoList(), GetScannerInfo(), GetUniqueInfoList(), HasGame(), Initialize(), Rescan(), and Uninitialize().
|
staticprivate |
Scanner for GS Libraries.
Definition at line 128 of file game.hpp.
Referenced by FindLibrary(), GetConsoleLibraryList(), GetScannerLibrary(), HasGameLibrary(), Initialize(), Rescan(), and Uninitialize().