OpenTTD Source 20241224-master-gf74b0cf984
|
#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 a Game Script. | |
static class GameInstance * | GetGameInstance () |
Get the current GameScript instance. | |
static class GameInfo * | GetInfo () |
Get the current GameInfo. | |
static void | Rescan () |
static void | ResetConfig () |
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) |
Wrapper function for GameScanner::GetConsoleList. | |
static void | GetConsoleLibraryList (std::back_insert_iterator< std::string > &output_iterator) |
Wrapper function for GameScanner::GetConsoleLibraryList. | |
static const ScriptInfoList * | GetInfoList () |
Wrapper function for GameScanner::GetInfoList. | |
static const ScriptInfoList * | GetUniqueInfoList () |
Wrapper function for GameScanner::GetUniqueInfoList. | |
static class GameInfo * | FindInfo (const std::string &name, int version, bool force_exact_match) |
Wrapper function for GameScannerInfo::FindInfo. | |
static class GameLibrary * | FindLibrary (const std::string &library, int version) |
Wrapper function for GameScanner::FindLibrary. | |
static class GameInstance * | GetInstance () |
Get the current active instance. | |
static bool | HasGame (const struct ContentInfo *ci, bool md5sum) |
Wrapper function for GameScanner::HasGame. | |
static bool | HasGameLibrary (const ContentInfo *ci, bool md5sum) |
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 class GameInstance * | instance = nullptr |
Instance to the current active Game. | |
static class GameScannerInfo * | scanner_info = nullptr |
Scanner for Game scripts. | |
static class GameScannerLibrary * | scanner_library = nullptr |
Scanner for GS Libraries. | |
static class GameInfo * | info = nullptr |
Current selected GameInfo. | |
|
static |
Wrapper function for GameScannerInfo::FindInfo.
Definition at line 237 of file game_core.cpp.
References GameScannerInfo::FindInfo(), and scanner_info.
Referenced by GameConfig::FindInfo(), and GameConfig::ResetInfo().
|
static |
Wrapper function for GameScanner::FindLibrary.
Definition at line 242 of file game_core.cpp.
References GameScannerLibrary::FindLibrary(), and 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(), ScriptInstance::CollectGarbage(), frame_counter, ScriptInstance::GameLoop(), instance, OWNER_DEITY, PFE_GAMESCRIPT, Backup< T >::Restore(), and PerformanceMeasurer::SetInactive().
Referenced by _GenerateWorld(), and StateGameLoop().
|
static |
Wrapper function for GameScanner::GetConsoleLibraryList.
Definition at line 222 of file game_core.cpp.
References ScriptScanner::GetConsoleList(), and scanner_library.
|
static |
Wrapper function for GameScanner::GetConsoleList.
Definition at line 217 of file game_core.cpp.
References ScriptScanner::GetConsoleList(), and scanner_info.
Referenced by ShowHelp().
|
inlinestatic |
Get the current GameScript instance.
Definition at line 70 of file game.hpp.
References instance.
Referenced by CcGame(), and ShowScriptDebugWindowIfScriptError().
|
inlinestatic |
Get the current GameInfo.
Definition at line 75 of file game.hpp.
References info.
Referenced by GameInstance::Died(), LoadTranslations(), ScriptDebugWindow::SetStringParameters(), and SurveyGameScript().
|
static |
Wrapper function for GameScanner::GetInfoList.
Definition at line 227 of file game_core.cpp.
References ScriptScanner::GetInfoList(), and scanner_info.
Referenced by ScriptListWindow::ScriptListWindow().
|
inlinestatic |
Get the current active instance.
Definition at line 101 of file game.hpp.
References instance.
Referenced by _GenerateWorld(), ScriptDebugWindow::IsDead(), GSConfigWindow::IsEditable(), ScriptDebugWindow::IsValidDebugCompany(), ScriptDebugWindow::SelectValidDebugCompany(), and ScriptDebugWindow::UpdateGSButtonState().
|
static |
Gets the ScriptScanner instance that is used to find Game scripts.
Definition at line 263 of file game_core.cpp.
References scanner_info.
Referenced by ContentInfo::GetTextfile().
|
static |
Gets the ScriptScanner instance that is used to find Game Libraries.
Definition at line 267 of file game_core.cpp.
References scanner_library.
Referenced by ContentInfo::GetTextfile().
|
static |
Wrapper function for GameScanner::GetUniqueInfoList.
Definition at line 232 of file game_core.cpp.
References ScriptScanner::GetUniqueInfoList(), and scanner_info.
Referenced by ScriptListWindow::ScriptListWindow().
|
static |
Wrapper function for GameScanner::HasGame.
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 253 of file game_core.cpp.
References ScriptScanner::HasScript(), and scanner_info.
Referenced by ClientNetworkContentSocketHandler::Receive_SERVER_INFO().
|
static |
Definition at line 258 of file game_core.cpp.
|
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 141 of file game_core.cpp.
References instance, and ScriptInstance::IsPaused().
Referenced by ScriptDebugWindow::OnClick(), and ScriptDebugWindow::OnInvalidateData().
|
static |
Queue a new event for a Game Script.
Definition at line 146 of file game_core.cpp.
References _current_company, _network_server, _networking, ScriptInstance::InsertEvent(), instance, OWNER_DEITY, and Backup< T >::Restore().
Referenced by AdvertiseIndustryOpening(), AircraftEntersTerminal(), Subsidy::AwardTo(), ChangeIndustryProduction(), CmdCompanyCtrl(), CmdFoundTown(), CmdGoalQuestionAnswer(), CmdStoryPageButton(), CompanyCheckBankrupt(), CrashAirplane(), CreateSubsidy(), DisasterTick_Ufo(), DispatchLeftClickEvent(), DoStartupNewCompany(), FloodVehicle(), 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 131 of file game_core.cpp.
References instance, and ScriptInstance::Pause().
Referenced by ScriptDebugWindow::OnInvalidateData().
|
static |
Definition at line 191 of file game_core.cpp.
|
static |
Definition at line 166 of file game_core.cpp.
|
static |
Save data from a GameScript to a savegame.
Definition at line 206 of file game_core.cpp.
References _current_company, _network_server, _networking, instance, OWNER_DEITY, Backup< T >::Restore(), ScriptInstance::Save(), 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(), info, GameInstance::Initialize(), instance, InvalidateWindowClassesData(), ScriptInstance::LoadOnStack(), OWNER_DEITY, Backup< T >::Restore(), ScriptConfig::SSS_FORCE_GAME, and WC_SCRIPT_DEBUG.
Referenced by _GenerateWorld(), and StartScripts().
|
static |
Uninitialize the Game system.
Definition at line 102 of file game_core.cpp.
References _current_company, _settings_game, _settings_newgame, GameSettings::game_config, info, instance, 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 136 of file game_core.cpp.
References instance, and ScriptInstance::Unpause().
Referenced by ScriptDebugWindow::OnClick().
|
staticprivate |
Tick counter for the Game code.
Definition at line 112 of file game.hpp.
Referenced by GameLoop(), and Initialize().
|
staticprivate |
Current selected GameInfo.
Definition at line 116 of file game.hpp.
Referenced by GetInfo(), StartNew(), and Uninitialize().
|
staticprivate |
Instance to the current active Game.
Definition at line 113 of file game.hpp.
Referenced by GameLoop(), GetGameInstance(), GetInstance(), Initialize(), IsPaused(), NewEvent(), Pause(), Save(), StartNew(), Uninitialize(), and Unpause().
|
staticprivate |
Scanner for Game scripts.
Definition at line 114 of file game.hpp.
Referenced by FindInfo(), GetConsoleList(), GetInfoList(), GetScannerInfo(), GetUniqueInfoList(), HasGame(), Initialize(), and Uninitialize().
|
staticprivate |
Scanner for GS Libraries.
Definition at line 115 of file game.hpp.
Referenced by FindLibrary(), GetConsoleLibraryList(), GetScannerLibrary(), Initialize(), and Uninitialize().