12 #include "../stdafx.h" 15 #include "../script/squirrel_class.hpp" 17 #include "../script/script_storage.hpp" 18 #include "../ai/ai_gui.hpp" 27 #include "../script/api/game/game_accounting.hpp.sq" 28 #include "../script/api/game/game_admin.hpp.sq" 29 #include "../script/api/game/game_airport.hpp.sq" 30 #include "../script/api/game/game_base.hpp.sq" 31 #include "../script/api/game/game_basestation.hpp.sq" 32 #include "../script/api/game/game_bridge.hpp.sq" 33 #include "../script/api/game/game_bridgelist.hpp.sq" 34 #include "../script/api/game/game_cargo.hpp.sq" 35 #include "../script/api/game/game_cargolist.hpp.sq" 36 #include "../script/api/game/game_cargomonitor.hpp.sq" 37 #include "../script/api/game/game_client.hpp.sq" 38 #include "../script/api/game/game_clientlist.hpp.sq" 39 #include "../script/api/game/game_company.hpp.sq" 40 #include "../script/api/game/game_companymode.hpp.sq" 41 #include "../script/api/game/game_controller.hpp.sq" 42 #include "../script/api/game/game_date.hpp.sq" 43 #include "../script/api/game/game_depotlist.hpp.sq" 44 #include "../script/api/game/game_engine.hpp.sq" 45 #include "../script/api/game/game_enginelist.hpp.sq" 46 #include "../script/api/game/game_error.hpp.sq" 47 #include "../script/api/game/game_event.hpp.sq" 48 #include "../script/api/game/game_event_types.hpp.sq" 49 #include "../script/api/game/game_execmode.hpp.sq" 50 #include "../script/api/game/game_game.hpp.sq" 51 #include "../script/api/game/game_gamesettings.hpp.sq" 52 #include "../script/api/game/game_goal.hpp.sq" 53 #include "../script/api/game/game_industry.hpp.sq" 54 #include "../script/api/game/game_industrylist.hpp.sq" 55 #include "../script/api/game/game_industrytype.hpp.sq" 56 #include "../script/api/game/game_industrytypelist.hpp.sq" 57 #include "../script/api/game/game_infrastructure.hpp.sq" 58 #include "../script/api/game/game_list.hpp.sq" 59 #include "../script/api/game/game_log.hpp.sq" 60 #include "../script/api/game/game_map.hpp.sq" 61 #include "../script/api/game/game_marine.hpp.sq" 62 #include "../script/api/game/game_news.hpp.sq" 63 #include "../script/api/game/game_order.hpp.sq" 64 #include "../script/api/game/game_rail.hpp.sq" 65 #include "../script/api/game/game_railtypelist.hpp.sq" 66 #include "../script/api/game/game_road.hpp.sq" 67 #include "../script/api/game/game_roadtypelist.hpp.sq" 68 #include "../script/api/game/game_sign.hpp.sq" 69 #include "../script/api/game/game_signlist.hpp.sq" 70 #include "../script/api/game/game_station.hpp.sq" 71 #include "../script/api/game/game_stationlist.hpp.sq" 72 #include "../script/api/game/game_story_page.hpp.sq" 73 #include "../script/api/game/game_storypageelementlist.hpp.sq" 74 #include "../script/api/game/game_storypagelist.hpp.sq" 75 #include "../script/api/game/game_subsidy.hpp.sq" 76 #include "../script/api/game/game_subsidylist.hpp.sq" 77 #include "../script/api/game/game_testmode.hpp.sq" 78 #include "../script/api/game/game_text.hpp.sq" 79 #include "../script/api/game/game_tile.hpp.sq" 80 #include "../script/api/game/game_tilelist.hpp.sq" 81 #include "../script/api/game/game_town.hpp.sq" 82 #include "../script/api/game/game_townlist.hpp.sq" 83 #include "../script/api/game/game_tunnel.hpp.sq" 84 #include "../script/api/game/game_vehicle.hpp.sq" 85 #include "../script/api/game/game_vehiclelist.hpp.sq" 86 #include "../script/api/game/game_viewport.hpp.sq" 87 #include "../script/api/game/game_waypoint.hpp.sq" 88 #include "../script/api/game/game_waypointlist.hpp.sq" 89 #include "../script/api/game/game_window.hpp.sq" 91 #include "../safeguards.h" 94 GameInstance::GameInstance() :
103 SQGSController_Register(this->
engine);
113 SQGSList_Register(this->
engine);
114 SQGSAccounting_Register(this->
engine);
115 SQGSAdmin_Register(this->
engine);
116 SQGSAirport_Register(this->
engine);
117 SQGSBase_Register(this->
engine);
118 SQGSBaseStation_Register(this->
engine);
119 SQGSBridge_Register(this->
engine);
120 SQGSBridgeList_Register(this->
engine);
121 SQGSBridgeList_Length_Register(this->
engine);
122 SQGSCargo_Register(this->
engine);
123 SQGSCargoList_Register(this->
engine);
124 SQGSCargoList_IndustryAccepting_Register(this->
engine);
125 SQGSCargoList_IndustryProducing_Register(this->
engine);
126 SQGSCargoList_StationAccepting_Register(this->
engine);
127 SQGSCargoMonitor_Register(this->
engine);
128 SQGSClient_Register(this->
engine);
129 SQGSClientList_Register(this->
engine);
130 SQGSClientList_Company_Register(this->
engine);
131 SQGSCompany_Register(this->
engine);
132 SQGSCompanyMode_Register(this->
engine);
133 SQGSDate_Register(this->
engine);
134 SQGSDepotList_Register(this->
engine);
135 SQGSEngine_Register(this->
engine);
136 SQGSEngineList_Register(this->
engine);
137 SQGSError_Register(this->
engine);
138 SQGSEvent_Register(this->
engine);
139 SQGSEventAdminPort_Register(this->
engine);
140 SQGSEventCompanyBankrupt_Register(this->
engine);
141 SQGSEventCompanyInTrouble_Register(this->
engine);
142 SQGSEventCompanyMerger_Register(this->
engine);
143 SQGSEventCompanyNew_Register(this->
engine);
144 SQGSEventCompanyTown_Register(this->
engine);
145 SQGSEventController_Register(this->
engine);
146 SQGSEventExclusiveTransportRights_Register(this->
engine);
147 SQGSEventGoalQuestionAnswer_Register(this->
engine);
148 SQGSEventIndustryClose_Register(this->
engine);
149 SQGSEventIndustryOpen_Register(this->
engine);
150 SQGSEventRoadReconstruction_Register(this->
engine);
151 SQGSEventStationFirstVehicle_Register(this->
engine);
152 SQGSEventSubsidyAwarded_Register(this->
engine);
153 SQGSEventSubsidyExpired_Register(this->
engine);
154 SQGSEventSubsidyOffer_Register(this->
engine);
155 SQGSEventSubsidyOfferExpired_Register(this->
engine);
156 SQGSEventTownFounded_Register(this->
engine);
157 SQGSEventVehicleCrashed_Register(this->
engine);
158 SQGSEventWindowWidgetClick_Register(this->
engine);
159 SQGSExecMode_Register(this->
engine);
160 SQGSGame_Register(this->
engine);
161 SQGSGameSettings_Register(this->
engine);
162 SQGSGoal_Register(this->
engine);
163 SQGSIndustry_Register(this->
engine);
164 SQGSIndustryList_Register(this->
engine);
165 SQGSIndustryList_CargoAccepting_Register(this->
engine);
166 SQGSIndustryList_CargoProducing_Register(this->
engine);
167 SQGSIndustryType_Register(this->
engine);
168 SQGSIndustryTypeList_Register(this->
engine);
169 SQGSInfrastructure_Register(this->
engine);
170 SQGSLog_Register(this->
engine);
171 SQGSMap_Register(this->
engine);
172 SQGSMarine_Register(this->
engine);
173 SQGSNews_Register(this->
engine);
174 SQGSOrder_Register(this->
engine);
175 SQGSRail_Register(this->
engine);
176 SQGSRailTypeList_Register(this->
engine);
177 SQGSRoad_Register(this->
engine);
178 SQGSRoadTypeList_Register(this->
engine);
179 SQGSSign_Register(this->
engine);
180 SQGSSignList_Register(this->
engine);
181 SQGSStation_Register(this->
engine);
182 SQGSStationList_Register(this->
engine);
183 SQGSStationList_Cargo_Register(this->
engine);
184 SQGSStationList_CargoPlanned_Register(this->
engine);
185 SQGSStationList_CargoPlannedByFrom_Register(this->
engine);
186 SQGSStationList_CargoPlannedByVia_Register(this->
engine);
187 SQGSStationList_CargoPlannedFromByVia_Register(this->
engine);
188 SQGSStationList_CargoPlannedViaByFrom_Register(this->
engine);
189 SQGSStationList_CargoWaiting_Register(this->
engine);
190 SQGSStationList_CargoWaitingByFrom_Register(this->
engine);
191 SQGSStationList_CargoWaitingByVia_Register(this->
engine);
192 SQGSStationList_CargoWaitingFromByVia_Register(this->
engine);
193 SQGSStationList_CargoWaitingViaByFrom_Register(this->
engine);
194 SQGSStationList_Vehicle_Register(this->
engine);
195 SQGSStoryPage_Register(this->
engine);
196 SQGSStoryPageElementList_Register(this->
engine);
197 SQGSStoryPageList_Register(this->
engine);
198 SQGSSubsidy_Register(this->
engine);
199 SQGSSubsidyList_Register(this->
engine);
200 SQGSTestMode_Register(this->
engine);
201 SQGSText_Register(this->
engine);
202 SQGSTile_Register(this->
engine);
203 SQGSTileList_Register(this->
engine);
204 SQGSTileList_IndustryAccepting_Register(this->
engine);
205 SQGSTileList_IndustryProducing_Register(this->
engine);
206 SQGSTileList_StationType_Register(this->
engine);
207 SQGSTown_Register(this->
engine);
208 SQGSTownEffectList_Register(this->
engine);
209 SQGSTownList_Register(this->
engine);
210 SQGSTunnel_Register(this->
engine);
211 SQGSVehicle_Register(this->
engine);
212 SQGSVehicleList_Register(this->
engine);
213 SQGSVehicleList_Depot_Register(this->
engine);
214 SQGSVehicleList_SharedOrders_Register(this->
engine);
215 SQGSVehicleList_Station_Register(this->
engine);
216 SQGSViewport_Register(this->
engine);
217 SQGSWaypoint_Register(this->
engine);
218 SQGSWaypointList_Register(this->
engine);
219 SQGSWaypointList_Vehicle_Register(this->
engine);
220 SQGSWindow_Register(this->
engine);
224 if (!this->LoadCompatibilityScripts(this->versionAPI,
GAME_DIR)) this->Died();
244 if (info !=
nullptr) {
247 if (info->
GetURL() !=
nullptr) {
248 ScriptLog::Info(
"Please report the error to the following URL:");
249 ScriptLog::Info(info->
GetURL());
void Died() override
Tell the script it died.
int version
Version of the script.
GameConfig stores the configuration settings of every Game.
void RegisterGameTranslation(Squirrel *engine)
Register the current translation to the Squirrel engine.
Base functions regarding game texts.
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.
Subdirectory for all game scripts.
void Continue()
A script in multiplayer waits for the server to handle his DoCommand.
static GameConfig * GetConfig(ScriptSettingSource source=SSS_DEFAULT)
Get the config of a company.
Common return value for all commands.
int GetSetting(const char *name) override
Get the value of a setting of the current instance.
All static information from an Game like name, version, etc.
const char * GetMainScript() const
Get the filename of the main.nut script.
void CommandCallback(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
Define a callback function for the client, after the command is finished.
void CcGame(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
DoCommand callback function for all commands executed by Game Scripts.
All static information from an Script like name, version, etc.
The GameInstance tracks games.
Runtime information about a script like a pointer to the squirrel vm and the current state...
static class GameLibrary * FindLibrary(const char *library, int version)
Wrapper function for GameScanner::FindLibrary.
const char * GetAPIVersion() const
Get the API version this Game is written for.
const char * GetURL() const
Get the website for this script.
static class GameInfo * GetInfo()
Get the current GameInfo.
Window * ShowAIDebugWindow(CompanyID show_company)
Open the AI debug window and select the given company.
const char * name
Full name of the script.
void RegisterAPI() override
Register all API functions to the VM.
GameInfo keeps track of all information of an Game, like Author, Description, ... ...
static class GameInstance * GetGameInstance()
Get the current GameScript instance.
uint32 TileIndex
The index/ID of a Tile.
ScriptInfo * FindLibrary(const char *library, int version) override
Find a library.
virtual void RegisterAPI()
Register all API functions to the VM.
void Initialize(const char *main_script, const char *instance_name, CompanyID company)
Initialize the script and prepare it for its first run.
Base functions for all Games.
class Squirrel * engine
Engine used to register for Squirrel.
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
CommandCallback * 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.
virtual void Died()
Tell the script it died.
void Initialize(class GameInfo *info)
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.
The object is owned by a superuser / goal script.