Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00012 #include "../stdafx.h"
00013 #include "../debug.h"
00014 #include "../saveload/saveload.h"
00015
00016 #include "../script/squirrel_class.hpp"
00017
00018 #include "../script/script_storage.hpp"
00019 #include "game_config.hpp"
00020 #include "game_info.hpp"
00021 #include "game_instance.hpp"
00022 #include "game_text.hpp"
00023 #include "game.hpp"
00024
00025
00026
00027 #include "../script/api/game/game_accounting.hpp.sq"
00028 #include "../script/api/game/game_admin.hpp.sq"
00029 #include "../script/api/game/game_airport.hpp.sq"
00030 #include "../script/api/game/game_base.hpp.sq"
00031 #include "../script/api/game/game_basestation.hpp.sq"
00032 #include "../script/api/game/game_bridge.hpp.sq"
00033 #include "../script/api/game/game_bridgelist.hpp.sq"
00034 #include "../script/api/game/game_cargo.hpp.sq"
00035 #include "../script/api/game/game_cargolist.hpp.sq"
00036 #include "../script/api/game/game_company.hpp.sq"
00037 #include "../script/api/game/game_companymode.hpp.sq"
00038 #include "../script/api/game/game_controller.hpp.sq"
00039 #include "../script/api/game/game_date.hpp.sq"
00040 #include "../script/api/game/game_depotlist.hpp.sq"
00041 #include "../script/api/game/game_engine.hpp.sq"
00042 #include "../script/api/game/game_enginelist.hpp.sq"
00043 #include "../script/api/game/game_error.hpp.sq"
00044 #include "../script/api/game/game_event.hpp.sq"
00045 #include "../script/api/game/game_event_types.hpp.sq"
00046 #include "../script/api/game/game_execmode.hpp.sq"
00047 #include "../script/api/game/game_game.hpp.sq"
00048 #include "../script/api/game/game_gamesettings.hpp.sq"
00049 #include "../script/api/game/game_goal.hpp.sq"
00050 #include "../script/api/game/game_industry.hpp.sq"
00051 #include "../script/api/game/game_industrylist.hpp.sq"
00052 #include "../script/api/game/game_industrytype.hpp.sq"
00053 #include "../script/api/game/game_industrytypelist.hpp.sq"
00054 #include "../script/api/game/game_infrastructure.hpp.sq"
00055 #include "../script/api/game/game_list.hpp.sq"
00056 #include "../script/api/game/game_log.hpp.sq"
00057 #include "../script/api/game/game_map.hpp.sq"
00058 #include "../script/api/game/game_marine.hpp.sq"
00059 #include "../script/api/game/game_news.hpp.sq"
00060 #include "../script/api/game/game_rail.hpp.sq"
00061 #include "../script/api/game/game_railtypelist.hpp.sq"
00062 #include "../script/api/game/game_road.hpp.sq"
00063 #include "../script/api/game/game_sign.hpp.sq"
00064 #include "../script/api/game/game_signlist.hpp.sq"
00065 #include "../script/api/game/game_station.hpp.sq"
00066 #include "../script/api/game/game_stationlist.hpp.sq"
00067 #include "../script/api/game/game_subsidy.hpp.sq"
00068 #include "../script/api/game/game_subsidylist.hpp.sq"
00069 #include "../script/api/game/game_testmode.hpp.sq"
00070 #include "../script/api/game/game_text.hpp.sq"
00071 #include "../script/api/game/game_tile.hpp.sq"
00072 #include "../script/api/game/game_tilelist.hpp.sq"
00073 #include "../script/api/game/game_town.hpp.sq"
00074 #include "../script/api/game/game_townlist.hpp.sq"
00075 #include "../script/api/game/game_tunnel.hpp.sq"
00076 #include "../script/api/game/game_vehicle.hpp.sq"
00077 #include "../script/api/game/game_vehiclelist.hpp.sq"
00078 #include "../script/api/game/game_viewport.hpp.sq"
00079 #include "../script/api/game/game_waypoint.hpp.sq"
00080 #include "../script/api/game/game_waypointlist.hpp.sq"
00081 #include "../script/api/game/game_window.hpp.sq"
00082
00083
00084 GameInstance::GameInstance() :
00085 ScriptInstance("GS")
00086 {}
00087
00088 void GameInstance::Initialize(GameInfo *info)
00089 {
00090
00091 SQGSController_Register(this->engine);
00092
00093 ScriptInstance::Initialize(info->GetMainScript(), info->GetInstanceName(), OWNER_DEITY);
00094 }
00095
00096 void GameInstance::RegisterAPI()
00097 {
00098 ScriptInstance::RegisterAPI();
00099
00100
00101 SQGSList_Register(this->engine);
00102 SQGSAccounting_Register(this->engine);
00103 SQGSAdmin_Register(this->engine);
00104 SQGSAirport_Register(this->engine);
00105 SQGSBase_Register(this->engine);
00106 SQGSBaseStation_Register(this->engine);
00107 SQGSBridge_Register(this->engine);
00108 SQGSBridgeList_Register(this->engine);
00109 SQGSBridgeList_Length_Register(this->engine);
00110 SQGSCargo_Register(this->engine);
00111 SQGSCargoList_Register(this->engine);
00112 SQGSCargoList_IndustryAccepting_Register(this->engine);
00113 SQGSCargoList_IndustryProducing_Register(this->engine);
00114 SQGSCargoList_StationAccepting_Register(this->engine);
00115 SQGSCompany_Register(this->engine);
00116 SQGSCompanyMode_Register(this->engine);
00117 SQGSDate_Register(this->engine);
00118 SQGSDepotList_Register(this->engine);
00119 SQGSEngine_Register(this->engine);
00120 SQGSEngineList_Register(this->engine);
00121 SQGSError_Register(this->engine);
00122 SQGSEvent_Register(this->engine);
00123 SQGSEventAdminPort_Register(this->engine);
00124 SQGSEventCompanyBankrupt_Register(this->engine);
00125 SQGSEventCompanyInTrouble_Register(this->engine);
00126 SQGSEventCompanyMerger_Register(this->engine);
00127 SQGSEventCompanyNew_Register(this->engine);
00128 SQGSEventController_Register(this->engine);
00129 SQGSEventIndustryClose_Register(this->engine);
00130 SQGSEventIndustryOpen_Register(this->engine);
00131 SQGSEventStationFirstVehicle_Register(this->engine);
00132 SQGSEventSubsidyAwarded_Register(this->engine);
00133 SQGSEventSubsidyExpired_Register(this->engine);
00134 SQGSEventSubsidyOffer_Register(this->engine);
00135 SQGSEventSubsidyOfferExpired_Register(this->engine);
00136 SQGSEventTownFounded_Register(this->engine);
00137 SQGSEventVehicleCrashed_Register(this->engine);
00138 SQGSEventWindowWidgetClick_Register(this->engine);
00139 SQGSExecMode_Register(this->engine);
00140 SQGSGame_Register(this->engine);
00141 SQGSGameSettings_Register(this->engine);
00142 SQGSGoal_Register(this->engine);
00143 SQGSIndustry_Register(this->engine);
00144 SQGSIndustryList_Register(this->engine);
00145 SQGSIndustryList_CargoAccepting_Register(this->engine);
00146 SQGSIndustryList_CargoProducing_Register(this->engine);
00147 SQGSIndustryType_Register(this->engine);
00148 SQGSIndustryTypeList_Register(this->engine);
00149 SQGSInfrastructure_Register(this->engine);
00150 SQGSLog_Register(this->engine);
00151 SQGSMap_Register(this->engine);
00152 SQGSMarine_Register(this->engine);
00153 SQGSNews_Register(this->engine);
00154 SQGSRail_Register(this->engine);
00155 SQGSRailTypeList_Register(this->engine);
00156 SQGSRoad_Register(this->engine);
00157 SQGSSign_Register(this->engine);
00158 SQGSSignList_Register(this->engine);
00159 SQGSStation_Register(this->engine);
00160 SQGSStationList_Register(this->engine);
00161 SQGSStationList_Vehicle_Register(this->engine);
00162 SQGSSubsidy_Register(this->engine);
00163 SQGSSubsidyList_Register(this->engine);
00164 SQGSTestMode_Register(this->engine);
00165 SQGSText_Register(this->engine);
00166 SQGSTile_Register(this->engine);
00167 SQGSTileList_Register(this->engine);
00168 SQGSTileList_IndustryAccepting_Register(this->engine);
00169 SQGSTileList_IndustryProducing_Register(this->engine);
00170 SQGSTileList_StationType_Register(this->engine);
00171 SQGSTown_Register(this->engine);
00172 SQGSTownEffectList_Register(this->engine);
00173 SQGSTownList_Register(this->engine);
00174 SQGSTunnel_Register(this->engine);
00175 SQGSVehicle_Register(this->engine);
00176 SQGSVehicleList_Register(this->engine);
00177 SQGSVehicleList_Depot_Register(this->engine);
00178 SQGSVehicleList_SharedOrders_Register(this->engine);
00179 SQGSVehicleList_Station_Register(this->engine);
00180 SQGSViewport_Register(this->engine);
00181 SQGSWaypoint_Register(this->engine);
00182 SQGSWaypointList_Register(this->engine);
00183 SQGSWaypointList_Vehicle_Register(this->engine);
00184 SQGSWindow_Register(this->engine);
00185
00186 RegisterGameTranslation(this->engine);
00187 }
00188
00189 int GameInstance::GetSetting(const char *name)
00190 {
00191 return GameConfig::GetConfig()->GetSetting(name);
00192 }
00193
00194 ScriptInfo *GameInstance::FindLibrary(const char *library, int version)
00195 {
00196 return (ScriptInfo *)Game::FindLibrary(library, version);
00197 }
00198
00206 void CcGame(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
00207 {
00208 Game::GetGameInstance()->DoCommandCallback(result, tile, p1, p2);
00209 Game::GetGameInstance()->Continue();
00210 }
00211
00212 CommandCallback *GameInstance::GetDoCommandCallback()
00213 {
00214 return &CcGame;
00215 }