Go to the documentation of this file.
10 #include "../stdafx.h"
13 #include "../script/squirrel_class.hpp"
15 #include "../script/script_storage.hpp"
16 #include "../script/script_cmd.h"
17 #include "../ai/ai_gui.hpp"
25 #include "../script/api/game/game_includes.hpp"
27 #include "../safeguards.h"
30 GameInstance::GameInstance() :
39 SQGSController_Register(this->
engine);
49 SQGS_RegisterAll(this->
engine);
73 if (info !=
nullptr) {
76 if (info->
GetURL() !=
nullptr) {
77 ScriptLog::Info(
"Please report the error to the following URL:");
78 ScriptLog::Info(info->
GetURL());
class Squirrel * engine
A wrapper around the squirrel vm.
static class GameInstance * GetGameInstance()
Get the current GameScript instance.
const char * GetMainScript() const
Get the filename of the main.nut script.
const char * GetAPIVersion() const
Get the API version this Game is written for.
Commands
List of commands.
@ WL_WARNING
Other information.
std::vector< byte > CommandDataBuffer
Storage buffer for serialized command data.
static class GameInfo * GetInfo()
Get the current GameInfo.
Runtime information about a script like a pointer to the squirrel vm and the current state.
ScriptInfo * FindLibrary(const char *library, int version) override
Find a library.
const char * GetURL() const
Get the website for this script.
void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel wl, int x=0, int y=0, const GRFFile *textref_stack_grffile=nullptr, uint textref_stack_size=0, const uint32 *textref_stack=nullptr)
Display an error message in a window.
Common return value for all commands.
void Initialize(class GameInfo *info)
Initialize the script and prepare it for its first run.
void CommandCallbackData(Commands cmd, const CommandCost &result, const CommandDataBuffer &data, CommandDataBuffer result_data)
Define a callback function for the client, after the command is finished.
void RegisterGameTranslation(Squirrel *engine)
Register the current translation to the Squirrel engine.
void RegisterAPI() override
Register all API functions to the VM.
@ GAME_DIR
Subdirectory for all game scripts.
virtual void RegisterAPI()
Register all API functions to the VM.
void Died() override
Tell the script it died.
void Initialize(const char *main_script, const char *instance_name, CompanyID company)
Initialize the script and prepare it for its first run.
const char * GetInstanceName() const
Get the name of the instance of the script to create.
CommandCallbackData * GetDoCommandCallback() override
Get the callback handling DoCommands in case of networking.
virtual int GetSetting(const char *name) const
Get the value of a setting for this config.
static GameConfig * GetConfig(ScriptSettingSource source=SSS_DEFAULT)
Get the config of a company.
Window * ShowAIDebugWindow(CompanyID show_company)
Open the AI debug window and select the given company.
All static information from an Game like name, version, etc.
int GetSetting(const char *name) override
Get the value of a setting of the current instance.
virtual void Died()
Tell the script it died.
@ OWNER_DEITY
The object is owned by a superuser / goal script.
void Continue()
A script in multiplayer waits for the server to handle its DoCommand.
bool LoadCompatibilityScripts(const char *api_version, Subdirectory dir)
Load squirrel scripts to emulate an older API.
All static information from an Script like name, version, etc.
const char * versionAPI
Current API used by this script.
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
void CcGame(Commands cmd, const CommandCost &result, const CommandDataBuffer &data, CommandDataBuffer result_data)
DoCommand callback function for all commands executed by Game Scripts.
static class GameLibrary * FindLibrary(const char *library, int version)
Wrapper function for GameScanner::FindLibrary.