Files
@ r22199:6a985bf7b172
Branch filter:
Location: cpp/openttd-patchpack/source/src/game/game_instance.cpp - annotation
r22199:6a985bf7b172
10.2 KiB
text/x-c
(svn r27379) -Codechange: Do not throw in the destructors of ScriptTest/ExecMode.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 | r18746:ffe36c655ceb r18746:ffe36c655ceb r18746:ffe36c655ceb r18746:ffe36c655ceb r18746:ffe36c655ceb r18746:ffe36c655ceb r18746:ffe36c655ceb r18746:ffe36c655ceb r18746:ffe36c655ceb r18746:ffe36c655ceb r18746:ffe36c655ceb r18746:ffe36c655ceb r18861:a0daedca90f7 r18746:ffe36c655ceb r18746:ffe36c655ceb r18746:ffe36c655ceb r18746:ffe36c655ceb r18861:a0daedca90f7 r18748:5e4b96072e2a r18748:5e4b96072e2a r18746:ffe36c655ceb r18776:45400817a6df r18746:ffe36c655ceb r18746:ffe36c655ceb r18746:ffe36c655ceb r18746:ffe36c655ceb r18746:ffe36c655ceb r18765:0c8917c89d77 r18756:f1c6c1912f14 r18756:f1c6c1912f14 r18757:638de582f61a r18757:638de582f61a r18757:638de582f61a r18756:f1c6c1912f14 r18757:638de582f61a r19489:8159e7deec22 r18756:f1c6c1912f14 r18774:2977cce7e239 r18746:ffe36c655ceb r18756:f1c6c1912f14 r18757:638de582f61a r18757:638de582f61a r18757:638de582f61a r18746:ffe36c655ceb r18746:ffe36c655ceb r18764:f6e8611401f3 r18746:ffe36c655ceb r18760:babf79514cd5 r18756:f1c6c1912f14 r18772:80ffc4ed8122 r18756:f1c6c1912f14 r18756:f1c6c1912f14 r18756:f1c6c1912f14 r18756:f1c6c1912f14 r18756:f1c6c1912f14 r18746:ffe36c655ceb r18746:ffe36c655ceb r18756:f1c6c1912f14 r18756:f1c6c1912f14 r18769:52b4e8d83a42 r18971:86e12be8b21d r18757:638de582f61a r18757:638de582f61a r18756:f1c6c1912f14 r18763:938cba34d55a r18756:f1c6c1912f14 r18757:638de582f61a r18757:638de582f61a r20329:0b11d054e50d r21217:433ac9b65f88 r21215:9db6a30bdb18 r18757:638de582f61a r18757:638de582f61a r18746:ffe36c655ceb r18777:cf24fc430b51 r18756:f1c6c1912f14 r18757:638de582f61a r18756:f1c6c1912f14 r18756:f1c6c1912f14 r18757:638de582f61a r18756:f1c6c1912f14 r18757:638de582f61a r18767:46ef79bb17eb r18757:638de582f61a r18757:638de582f61a r18773:1df705d87864 r18746:ffe36c655ceb r21383:942c32fb8b0e r21383:942c32fb8b0e r18746:ffe36c655ceb r18746:ffe36c655ceb r18746:ffe36c655ceb r18746:ffe36c655ceb r18746:ffe36c655ceb r18748:5e4b96072e2a r18746:ffe36c655ceb r19539:8ff9f94e70e3 r19539:8ff9f94e70e3 r18746:ffe36c655ceb r18746:ffe36c655ceb r18746:ffe36c655ceb r18774:2977cce7e239 r18746:ffe36c655ceb r18746:ffe36c655ceb r18746:ffe36c655ceb r18746:ffe36c655ceb r18746:ffe36c655ceb r18746:ffe36c655ceb r18746:ffe36c655ceb r18746:ffe36c655ceb r18746:ffe36c655ceb r18765:0c8917c89d77 r18756:f1c6c1912f14 r18756:f1c6c1912f14 r18757:638de582f61a r18757:638de582f61a r18757:638de582f61a r18757:638de582f61a r18756:f1c6c1912f14 r18757:638de582f61a r18757:638de582f61a r18757:638de582f61a r18757:638de582f61a r19489:8159e7deec22 r18756:f1c6c1912f14 r18774:2977cce7e239 r18756:f1c6c1912f14 r18757:638de582f61a r18757:638de582f61a r18757:638de582f61a r18746:ffe36c655ceb r18746:ffe36c655ceb r18765:0c8917c89d77 r18764:f6e8611401f3 r18764:f6e8611401f3 r18764:f6e8611401f3 r18764:f6e8611401f3 r19374:8b326f0c504b r18746:ffe36c655ceb r19375:5e05c9787ff3 r18872:35e831d058c7 r18764:f6e8611401f3 r18764:f6e8611401f3 r19376:dd573f88a83f r18764:f6e8611401f3 r18764:f6e8611401f3 r18764:f6e8611401f3 r18764:f6e8611401f3 r18764:f6e8611401f3 r18764:f6e8611401f3 r18764:f6e8611401f3 r18773:1df705d87864 r18746:ffe36c655ceb r18760:babf79514cd5 r18756:f1c6c1912f14 r18772:80ffc4ed8122 r18756:f1c6c1912f14 r18756:f1c6c1912f14 r18756:f1c6c1912f14 r18756:f1c6c1912f14 r18756:f1c6c1912f14 r18756:f1c6c1912f14 r18756:f1c6c1912f14 r18746:ffe36c655ceb r18756:f1c6c1912f14 r18756:f1c6c1912f14 r18769:52b4e8d83a42 r18971:86e12be8b21d r18757:638de582f61a r18757:638de582f61a r18756:f1c6c1912f14 r18763:938cba34d55a r18756:f1c6c1912f14 r18757:638de582f61a r18757:638de582f61a r21750:39b1b1a11c25 r21750:39b1b1a11c25 r21750:39b1b1a11c25 r21750:39b1b1a11c25 r21750:39b1b1a11c25 r21750:39b1b1a11c25 r21750:39b1b1a11c25 r21750:39b1b1a11c25 r21750:39b1b1a11c25 r21750:39b1b1a11c25 r21750:39b1b1a11c25 r18757:638de582f61a r20329:0b11d054e50d r21217:433ac9b65f88 r21215:9db6a30bdb18 r18757:638de582f61a r18757:638de582f61a r18746:ffe36c655ceb r18777:cf24fc430b51 r18756:f1c6c1912f14 r18757:638de582f61a r18757:638de582f61a r18757:638de582f61a r18757:638de582f61a r18756:f1c6c1912f14 r18756:f1c6c1912f14 r18756:f1c6c1912f14 r18757:638de582f61a r18756:f1c6c1912f14 r18757:638de582f61a r18757:638de582f61a r18757:638de582f61a r18757:638de582f61a r18767:46ef79bb17eb r18757:638de582f61a r18757:638de582f61a r18757:638de582f61a r18773:1df705d87864 r18746:ffe36c655ceb r18776:45400817a6df r19539:8ff9f94e70e3 r19539:8ff9f94e70e3 r18746:ffe36c655ceb r18746:ffe36c655ceb r18746:ffe36c655ceb r18746:ffe36c655ceb r18748:5e4b96072e2a r18746:ffe36c655ceb r18746:ffe36c655ceb r18746:ffe36c655ceb r18746:ffe36c655ceb r18754:42d72cb83fe7 r18746:ffe36c655ceb r18746:ffe36c655ceb r18861:a0daedca90f7 r18861:a0daedca90f7 r18861:a0daedca90f7 r18861:a0daedca90f7 r18861:a0daedca90f7 r18861:a0daedca90f7 r18861:a0daedca90f7 r18861:a0daedca90f7 r18861:a0daedca90f7 r18861:a0daedca90f7 r18861:a0daedca90f7 r18861:a0daedca90f7 r18861:a0daedca90f7 r18861:a0daedca90f7 r18861:a0daedca90f7 r18861:a0daedca90f7 r18861:a0daedca90f7 r18746:ffe36c655ceb r18746:ffe36c655ceb r18746:ffe36c655ceb r18746:ffe36c655ceb r18746:ffe36c655ceb r18746:ffe36c655ceb r18746:ffe36c655ceb r18746:ffe36c655ceb r18746:ffe36c655ceb r18746:ffe36c655ceb r18746:ffe36c655ceb r18746:ffe36c655ceb r18746:ffe36c655ceb r18746:ffe36c655ceb r18746:ffe36c655ceb r18746:ffe36c655ceb r18746:ffe36c655ceb | /* $Id$ */
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file game_instance.cpp Implementation of GameInstance. */
#include "../stdafx.h"
#include "../error.h"
#include "../script/squirrel_class.hpp"
#include "../script/script_storage.hpp"
#include "../ai/ai_gui.hpp"
#include "game_config.hpp"
#include "game_info.hpp"
#include "game_instance.hpp"
#include "game_text.hpp"
#include "game.hpp"
/* Convert all Game related classes to Squirrel data.
* Note: this line is a marker in squirrel_export.sh. Do not change! */
#include "../script/api/game/game_accounting.hpp.sq"
#include "../script/api/game/game_admin.hpp.sq"
#include "../script/api/game/game_airport.hpp.sq"
#include "../script/api/game/game_base.hpp.sq"
#include "../script/api/game/game_basestation.hpp.sq"
#include "../script/api/game/game_bridge.hpp.sq"
#include "../script/api/game/game_bridgelist.hpp.sq"
#include "../script/api/game/game_cargo.hpp.sq"
#include "../script/api/game/game_cargolist.hpp.sq"
#include "../script/api/game/game_cargomonitor.hpp.sq"
#include "../script/api/game/game_company.hpp.sq"
#include "../script/api/game/game_companymode.hpp.sq"
#include "../script/api/game/game_controller.hpp.sq"
#include "../script/api/game/game_date.hpp.sq"
#include "../script/api/game/game_depotlist.hpp.sq"
#include "../script/api/game/game_engine.hpp.sq"
#include "../script/api/game/game_enginelist.hpp.sq"
#include "../script/api/game/game_error.hpp.sq"
#include "../script/api/game/game_event.hpp.sq"
#include "../script/api/game/game_event_types.hpp.sq"
#include "../script/api/game/game_execmode.hpp.sq"
#include "../script/api/game/game_game.hpp.sq"
#include "../script/api/game/game_gamesettings.hpp.sq"
#include "../script/api/game/game_goal.hpp.sq"
#include "../script/api/game/game_industry.hpp.sq"
#include "../script/api/game/game_industrylist.hpp.sq"
#include "../script/api/game/game_industrytype.hpp.sq"
#include "../script/api/game/game_industrytypelist.hpp.sq"
#include "../script/api/game/game_infrastructure.hpp.sq"
#include "../script/api/game/game_list.hpp.sq"
#include "../script/api/game/game_log.hpp.sq"
#include "../script/api/game/game_map.hpp.sq"
#include "../script/api/game/game_marine.hpp.sq"
#include "../script/api/game/game_news.hpp.sq"
#include "../script/api/game/game_order.hpp.sq"
#include "../script/api/game/game_rail.hpp.sq"
#include "../script/api/game/game_railtypelist.hpp.sq"
#include "../script/api/game/game_road.hpp.sq"
#include "../script/api/game/game_sign.hpp.sq"
#include "../script/api/game/game_signlist.hpp.sq"
#include "../script/api/game/game_station.hpp.sq"
#include "../script/api/game/game_stationlist.hpp.sq"
#include "../script/api/game/game_story_page.hpp.sq"
#include "../script/api/game/game_storypageelementlist.hpp.sq"
#include "../script/api/game/game_storypagelist.hpp.sq"
#include "../script/api/game/game_subsidy.hpp.sq"
#include "../script/api/game/game_subsidylist.hpp.sq"
#include "../script/api/game/game_testmode.hpp.sq"
#include "../script/api/game/game_text.hpp.sq"
#include "../script/api/game/game_tile.hpp.sq"
#include "../script/api/game/game_tilelist.hpp.sq"
#include "../script/api/game/game_town.hpp.sq"
#include "../script/api/game/game_townlist.hpp.sq"
#include "../script/api/game/game_tunnel.hpp.sq"
#include "../script/api/game/game_vehicle.hpp.sq"
#include "../script/api/game/game_vehiclelist.hpp.sq"
#include "../script/api/game/game_viewport.hpp.sq"
#include "../script/api/game/game_waypoint.hpp.sq"
#include "../script/api/game/game_waypointlist.hpp.sq"
#include "../script/api/game/game_window.hpp.sq"
#include "../safeguards.h"
GameInstance::GameInstance() :
ScriptInstance("GS")
{}
void GameInstance::Initialize(GameInfo *info)
{
this->versionAPI = info->GetAPIVersion();
/* Register the GameController */
SQGSController_Register(this->engine);
ScriptInstance::Initialize(info->GetMainScript(), info->GetInstanceName(), OWNER_DEITY);
}
void GameInstance::RegisterAPI()
{
ScriptInstance::RegisterAPI();
/* Register all classes */
SQGSList_Register(this->engine);
SQGSAccounting_Register(this->engine);
SQGSAdmin_Register(this->engine);
SQGSAirport_Register(this->engine);
SQGSBase_Register(this->engine);
SQGSBaseStation_Register(this->engine);
SQGSBridge_Register(this->engine);
SQGSBridgeList_Register(this->engine);
SQGSBridgeList_Length_Register(this->engine);
SQGSCargo_Register(this->engine);
SQGSCargoList_Register(this->engine);
SQGSCargoList_IndustryAccepting_Register(this->engine);
SQGSCargoList_IndustryProducing_Register(this->engine);
SQGSCargoList_StationAccepting_Register(this->engine);
SQGSCargoMonitor_Register(this->engine);
SQGSCompany_Register(this->engine);
SQGSCompanyMode_Register(this->engine);
SQGSDate_Register(this->engine);
SQGSDepotList_Register(this->engine);
SQGSEngine_Register(this->engine);
SQGSEngineList_Register(this->engine);
SQGSError_Register(this->engine);
SQGSEvent_Register(this->engine);
SQGSEventAdminPort_Register(this->engine);
SQGSEventCompanyBankrupt_Register(this->engine);
SQGSEventCompanyInTrouble_Register(this->engine);
SQGSEventCompanyMerger_Register(this->engine);
SQGSEventCompanyNew_Register(this->engine);
SQGSEventCompanyTown_Register(this->engine);
SQGSEventController_Register(this->engine);
SQGSEventExclusiveTransportRights_Register(this->engine);
SQGSEventGoalQuestionAnswer_Register(this->engine);
SQGSEventIndustryClose_Register(this->engine);
SQGSEventIndustryOpen_Register(this->engine);
SQGSEventRoadReconstruction_Register(this->engine);
SQGSEventStationFirstVehicle_Register(this->engine);
SQGSEventSubsidyAwarded_Register(this->engine);
SQGSEventSubsidyExpired_Register(this->engine);
SQGSEventSubsidyOffer_Register(this->engine);
SQGSEventSubsidyOfferExpired_Register(this->engine);
SQGSEventTownFounded_Register(this->engine);
SQGSEventVehicleCrashed_Register(this->engine);
SQGSEventWindowWidgetClick_Register(this->engine);
SQGSExecMode_Register(this->engine);
SQGSGame_Register(this->engine);
SQGSGameSettings_Register(this->engine);
SQGSGoal_Register(this->engine);
SQGSIndustry_Register(this->engine);
SQGSIndustryList_Register(this->engine);
SQGSIndustryList_CargoAccepting_Register(this->engine);
SQGSIndustryList_CargoProducing_Register(this->engine);
SQGSIndustryType_Register(this->engine);
SQGSIndustryTypeList_Register(this->engine);
SQGSInfrastructure_Register(this->engine);
SQGSLog_Register(this->engine);
SQGSMap_Register(this->engine);
SQGSMarine_Register(this->engine);
SQGSNews_Register(this->engine);
SQGSOrder_Register(this->engine);
SQGSRail_Register(this->engine);
SQGSRailTypeList_Register(this->engine);
SQGSRoad_Register(this->engine);
SQGSSign_Register(this->engine);
SQGSSignList_Register(this->engine);
SQGSStation_Register(this->engine);
SQGSStationList_Register(this->engine);
SQGSStationList_Cargo_Register(this->engine);
SQGSStationList_CargoPlanned_Register(this->engine);
SQGSStationList_CargoPlannedByFrom_Register(this->engine);
SQGSStationList_CargoPlannedByVia_Register(this->engine);
SQGSStationList_CargoPlannedFromByVia_Register(this->engine);
SQGSStationList_CargoPlannedViaByFrom_Register(this->engine);
SQGSStationList_CargoWaiting_Register(this->engine);
SQGSStationList_CargoWaitingByFrom_Register(this->engine);
SQGSStationList_CargoWaitingByVia_Register(this->engine);
SQGSStationList_CargoWaitingFromByVia_Register(this->engine);
SQGSStationList_CargoWaitingViaByFrom_Register(this->engine);
SQGSStationList_Vehicle_Register(this->engine);
SQGSStoryPage_Register(this->engine);
SQGSStoryPageElementList_Register(this->engine);
SQGSStoryPageList_Register(this->engine);
SQGSSubsidy_Register(this->engine);
SQGSSubsidyList_Register(this->engine);
SQGSTestMode_Register(this->engine);
SQGSText_Register(this->engine);
SQGSTile_Register(this->engine);
SQGSTileList_Register(this->engine);
SQGSTileList_IndustryAccepting_Register(this->engine);
SQGSTileList_IndustryProducing_Register(this->engine);
SQGSTileList_StationType_Register(this->engine);
SQGSTown_Register(this->engine);
SQGSTownEffectList_Register(this->engine);
SQGSTownList_Register(this->engine);
SQGSTunnel_Register(this->engine);
SQGSVehicle_Register(this->engine);
SQGSVehicleList_Register(this->engine);
SQGSVehicleList_Depot_Register(this->engine);
SQGSVehicleList_SharedOrders_Register(this->engine);
SQGSVehicleList_Station_Register(this->engine);
SQGSViewport_Register(this->engine);
SQGSWaypoint_Register(this->engine);
SQGSWaypointList_Register(this->engine);
SQGSWaypointList_Vehicle_Register(this->engine);
SQGSWindow_Register(this->engine);
RegisterGameTranslation(this->engine);
if (!this->LoadCompatibilityScripts(this->versionAPI, GAME_DIR)) this->Died();
}
int GameInstance::GetSetting(const char *name)
{
return GameConfig::GetConfig()->GetSetting(name);
}
ScriptInfo *GameInstance::FindLibrary(const char *library, int version)
{
return (ScriptInfo *)Game::FindLibrary(library, version);
}
void GameInstance::Died()
{
ScriptInstance::Died();
ShowAIDebugWindow(OWNER_DEITY);
const GameInfo *info = Game::GetInfo();
if (info != NULL) {
ShowErrorMessage(STR_ERROR_AI_PLEASE_REPORT_CRASH, INVALID_STRING_ID, WL_WARNING);
if (info->GetURL() != NULL) {
ScriptLog::Info("Please report the error to the following URL:");
ScriptLog::Info(info->GetURL());
}
}
}
/**
* DoCommand callback function for all commands executed by Game Scripts.
* @param result The result of the command.
* @param tile The tile on which the command was executed.
* @param p1 p1 as given to DoCommandPInternal.
* @param p2 p2 as given to DoCommandPInternal.
*/
void CcGame(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
{
Game::GetGameInstance()->DoCommandCallback(result, tile, p1, p2);
Game::GetGameInstance()->Continue();
}
CommandCallback *GameInstance::GetDoCommandCallback()
{
return &CcGame;
}
|