From 12aa5b6a583aa7ca9092ec6c77e7b12677cdd6a4 Mon Sep 17 00:00:00 2001 From: truebrain Date: Mon, 19 Dec 2011 20:50:54 +0000 Subject: (svn r23604) -Add: initial support for GameScripts --- src/script/api/game/game_accounting.hpp.sq | 28 +++++++ src/script/api/game/game_controller.hpp.sq | 28 +++++++ src/script/api/game/game_error.hpp.sq | 115 +++++++++++++++++++++++++++++ src/script/api/game/game_event.hpp.sq | 67 +++++++++++++++++ src/script/api/game/game_execmode.hpp.sq | 25 +++++++ src/script/api/game/game_list.hpp.sq | 63 ++++++++++++++++ src/script/api/game/game_log.hpp.sq | 29 ++++++++ src/script/api/game/game_testmode.hpp.sq | 25 +++++++ src/script/api/script_accounting.hpp | 2 +- src/script/api/script_controller.hpp | 2 +- src/script/api/script_error.hpp | 2 +- src/script/api/script_event.hpp | 4 +- src/script/api/script_execmode.hpp | 2 +- src/script/api/script_info_docs.hpp | 11 ++- src/script/api/script_list.hpp | 2 +- src/script/api/script_log.hpp | 2 +- src/script/api/script_testmode.hpp | 2 +- src/script/api/squirrel_export.awk | 8 +- src/script/api/squirrel_export.sh | 1 + src/script/squirrel.hpp | 3 +- 20 files changed, 402 insertions(+), 19 deletions(-) create mode 100644 src/script/api/game/game_accounting.hpp.sq create mode 100644 src/script/api/game/game_controller.hpp.sq create mode 100644 src/script/api/game/game_error.hpp.sq create mode 100644 src/script/api/game/game_event.hpp.sq create mode 100644 src/script/api/game/game_execmode.hpp.sq create mode 100644 src/script/api/game/game_list.hpp.sq create mode 100644 src/script/api/game/game_log.hpp.sq create mode 100644 src/script/api/game/game_testmode.hpp.sq (limited to 'src/script') diff --git a/src/script/api/game/game_accounting.hpp.sq b/src/script/api/game/game_accounting.hpp.sq new file mode 100644 index 000000000..0e78172c0 --- /dev/null +++ b/src/script/api/game/game_accounting.hpp.sq @@ -0,0 +1,28 @@ +/* $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 . + */ + +/* THIS FILE IS AUTO-GENERATED; PLEASE DO NOT ALTER MANUALLY */ + +#include "../script_accounting.hpp" +#include "../template/template_accounting.hpp.sq" + + +template <> const char *GetClassName() { return "GSAccounting"; } + +void SQGSAccounting_Register(Squirrel *engine) +{ + DefSQClass SQGSAccounting("GSAccounting"); + SQGSAccounting.PreRegister(engine); + SQGSAccounting.AddConstructor(engine, "x"); + + SQGSAccounting.DefSQMethod(engine, &ScriptAccounting::GetCosts, "GetCosts", 1, "x"); + SQGSAccounting.DefSQMethod(engine, &ScriptAccounting::ResetCosts, "ResetCosts", 1, "x"); + + SQGSAccounting.PostRegister(engine); +} diff --git a/src/script/api/game/game_controller.hpp.sq b/src/script/api/game/game_controller.hpp.sq new file mode 100644 index 000000000..53882fd3a --- /dev/null +++ b/src/script/api/game/game_controller.hpp.sq @@ -0,0 +1,28 @@ +/* $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 . + */ + +#include "../script_controller.hpp" + +template <> const char *GetClassName() { return "GSController"; } + +void SQGSController_Register(Squirrel *engine) +{ + DefSQClass SQGSController("GSController"); + SQGSController.PreRegister(engine); + + SQGSController.DefSQStaticMethod(engine, &ScriptController::GetTick, "GetTick", 1, "."); + SQGSController.DefSQStaticMethod(engine, &ScriptController::GetOpsTillSuspend, "GetOpsTillSuspend", 1, "."); + SQGSController.DefSQStaticMethod(engine, &ScriptController::SetCommandDelay, "SetCommandDelay", 2, ".i"); + SQGSController.DefSQStaticMethod(engine, &ScriptController::Sleep, "Sleep", 2, ".i"); + SQGSController.DefSQStaticMethod(engine, &ScriptController::GetSetting, "GetSetting", 2, ".s"); + SQGSController.DefSQStaticMethod(engine, &ScriptController::GetVersion, "GetVersion", 1, "."); + SQGSController.DefSQStaticMethod(engine, &ScriptController::Print, "Print", 3, ".bs"); + + SQGSController.PostRegister(engine); +} diff --git a/src/script/api/game/game_error.hpp.sq b/src/script/api/game/game_error.hpp.sq new file mode 100644 index 000000000..ff3f940f3 --- /dev/null +++ b/src/script/api/game/game_error.hpp.sq @@ -0,0 +1,115 @@ +/* $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 . + */ + +/* THIS FILE IS AUTO-GENERATED; PLEASE DO NOT ALTER MANUALLY */ + +#include "../script_error.hpp" +#include "../template/template_error.hpp.sq" + + +template <> const char *GetClassName() { return "GSError"; } + +void SQGSError_Register(Squirrel *engine) +{ + DefSQClass SQGSError("GSError"); + SQGSError.PreRegister(engine); + SQGSError.AddConstructor(engine, "x"); + + SQGSError.DefSQConst(engine, ScriptError::ERR_CAT_NONE, "ERR_CAT_NONE"); + SQGSError.DefSQConst(engine, ScriptError::ERR_CAT_GENERAL, "ERR_CAT_GENERAL"); + SQGSError.DefSQConst(engine, ScriptError::ERR_CAT_VEHICLE, "ERR_CAT_VEHICLE"); + SQGSError.DefSQConst(engine, ScriptError::ERR_CAT_STATION, "ERR_CAT_STATION"); + SQGSError.DefSQConst(engine, ScriptError::ERR_CAT_BRIDGE, "ERR_CAT_BRIDGE"); + SQGSError.DefSQConst(engine, ScriptError::ERR_CAT_TUNNEL, "ERR_CAT_TUNNEL"); + SQGSError.DefSQConst(engine, ScriptError::ERR_CAT_TILE, "ERR_CAT_TILE"); + SQGSError.DefSQConst(engine, ScriptError::ERR_CAT_SIGN, "ERR_CAT_SIGN"); + SQGSError.DefSQConst(engine, ScriptError::ERR_CAT_RAIL, "ERR_CAT_RAIL"); + SQGSError.DefSQConst(engine, ScriptError::ERR_CAT_ROAD, "ERR_CAT_ROAD"); + SQGSError.DefSQConst(engine, ScriptError::ERR_CAT_ORDER, "ERR_CAT_ORDER"); + SQGSError.DefSQConst(engine, ScriptError::ERR_CAT_MARINE, "ERR_CAT_MARINE"); + SQGSError.DefSQConst(engine, ScriptError::ERR_CAT_WAYPOINT, "ERR_CAT_WAYPOINT"); + SQGSError.DefSQConst(engine, ScriptError::ERR_CAT_BIT_SIZE, "ERR_CAT_BIT_SIZE"); + SQGSError.DefSQConst(engine, ScriptError::ERR_NONE, "ERR_NONE"); + SQGSError.DefSQConst(engine, ScriptError::ERR_UNKNOWN, "ERR_UNKNOWN"); + SQGSError.DefSQConst(engine, ScriptError::ERR_PRECONDITION_FAILED, "ERR_PRECONDITION_FAILED"); + SQGSError.DefSQConst(engine, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG, "ERR_PRECONDITION_STRING_TOO_LONG"); + SQGSError.DefSQConst(engine, ScriptError::ERR_NEWGRF_SUPPLIED_ERROR, "ERR_NEWGRF_SUPPLIED_ERROR"); + SQGSError.DefSQConst(engine, ScriptError::ERR_GENERAL_BASE, "ERR_GENERAL_BASE"); + SQGSError.DefSQConst(engine, ScriptError::ERR_NOT_ENOUGH_CASH, "ERR_NOT_ENOUGH_CASH"); + SQGSError.DefSQConst(engine, ScriptError::ERR_LOCAL_AUTHORITY_REFUSES, "ERR_LOCAL_AUTHORITY_REFUSES"); + SQGSError.DefSQConst(engine, ScriptError::ERR_ALREADY_BUILT, "ERR_ALREADY_BUILT"); + SQGSError.DefSQConst(engine, ScriptError::ERR_AREA_NOT_CLEAR, "ERR_AREA_NOT_CLEAR"); + SQGSError.DefSQConst(engine, ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY, "ERR_OWNED_BY_ANOTHER_COMPANY"); + SQGSError.DefSQConst(engine, ScriptError::ERR_NAME_IS_NOT_UNIQUE, "ERR_NAME_IS_NOT_UNIQUE"); + SQGSError.DefSQConst(engine, ScriptError::ERR_FLAT_LAND_REQUIRED, "ERR_FLAT_LAND_REQUIRED"); + SQGSError.DefSQConst(engine, ScriptError::ERR_LAND_SLOPED_WRONG, "ERR_LAND_SLOPED_WRONG"); + SQGSError.DefSQConst(engine, ScriptError::ERR_VEHICLE_IN_THE_WAY, "ERR_VEHICLE_IN_THE_WAY"); + SQGSError.DefSQConst(engine, ScriptError::ERR_SITE_UNSUITABLE, "ERR_SITE_UNSUITABLE"); + SQGSError.DefSQConst(engine, ScriptError::ERR_TOO_CLOSE_TO_EDGE, "ERR_TOO_CLOSE_TO_EDGE"); + SQGSError.DefSQConst(engine, ScriptError::ERR_STATION_TOO_SPREAD_OUT, "ERR_STATION_TOO_SPREAD_OUT"); + + ScriptError::RegisterErrorMap(STR_ERROR_NOT_ENOUGH_CASH_REQUIRES_CURRENCY, ScriptError::ERR_NOT_ENOUGH_CASH); + ScriptError::RegisterErrorMap(STR_ERROR_LOCAL_AUTHORITY_REFUSES_TO_ALLOW_THIS, ScriptError::ERR_LOCAL_AUTHORITY_REFUSES); + ScriptError::RegisterErrorMap(STR_ERROR_ALREADY_BUILT, ScriptError::ERR_ALREADY_BUILT); + ScriptError::RegisterErrorMap(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST, ScriptError::ERR_ALREADY_BUILT); + ScriptError::RegisterErrorMap(STR_ERROR_BUILDING_MUST_BE_DEMOLISHED, ScriptError::ERR_AREA_NOT_CLEAR); + ScriptError::RegisterErrorMap(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST, ScriptError::ERR_AREA_NOT_CLEAR); + ScriptError::RegisterErrorMap(STR_ERROR_MUST_DEMOLISH_RAILROAD, ScriptError::ERR_AREA_NOT_CLEAR); + ScriptError::RegisterErrorMap(STR_ERROR_MUST_DEMOLISH_AIRPORT_FIRST, ScriptError::ERR_AREA_NOT_CLEAR); + ScriptError::RegisterErrorMap(STR_ERROR_MUST_DEMOLISH_CARGO_TRAM_STATION_FIRST, ScriptError::ERR_AREA_NOT_CLEAR); + ScriptError::RegisterErrorMap(STR_ERROR_MUST_DEMOLISH_TRUCK_STATION_FIRST, ScriptError::ERR_AREA_NOT_CLEAR); + ScriptError::RegisterErrorMap(STR_ERROR_MUST_DEMOLISH_PASSENGER_TRAM_STATION_FIRST, ScriptError::ERR_AREA_NOT_CLEAR); + ScriptError::RegisterErrorMap(STR_ERROR_MUST_DEMOLISH_BUS_STATION_FIRST, ScriptError::ERR_AREA_NOT_CLEAR); + ScriptError::RegisterErrorMap(STR_ERROR_BUOY_IN_THE_WAY, ScriptError::ERR_AREA_NOT_CLEAR); + ScriptError::RegisterErrorMap(STR_ERROR_MUST_DEMOLISH_DOCK_FIRST, ScriptError::ERR_AREA_NOT_CLEAR); + ScriptError::RegisterErrorMap(STR_ERROR_GENERIC_OBJECT_IN_THE_WAY, ScriptError::ERR_AREA_NOT_CLEAR); + ScriptError::RegisterErrorMap(STR_ERROR_COMPANY_HEADQUARTERS_IN, ScriptError::ERR_AREA_NOT_CLEAR); + ScriptError::RegisterErrorMap(STR_ERROR_OBJECT_IN_THE_WAY, ScriptError::ERR_AREA_NOT_CLEAR); + ScriptError::RegisterErrorMap(STR_ERROR_MUST_REMOVE_ROAD_FIRST, ScriptError::ERR_AREA_NOT_CLEAR); + ScriptError::RegisterErrorMap(STR_ERROR_MUST_REMOVE_RAILROAD_TRACK, ScriptError::ERR_AREA_NOT_CLEAR); + ScriptError::RegisterErrorMap(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST, ScriptError::ERR_AREA_NOT_CLEAR); + ScriptError::RegisterErrorMap(STR_ERROR_MUST_DEMOLISH_TUNNEL_FIRST, ScriptError::ERR_AREA_NOT_CLEAR); + ScriptError::RegisterErrorMap(STR_ERROR_EXCAVATION_WOULD_DAMAGE, ScriptError::ERR_AREA_NOT_CLEAR); + ScriptError::RegisterErrorMap(STR_ERROR_AREA_IS_OWNED_BY_ANOTHER, ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY); + ScriptError::RegisterErrorMap(STR_ERROR_OWNED_BY, ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY); + ScriptError::RegisterErrorMap(STR_ERROR_NAME_MUST_BE_UNIQUE, ScriptError::ERR_NAME_IS_NOT_UNIQUE); + ScriptError::RegisterErrorMap(STR_ERROR_FLAT_LAND_REQUIRED, ScriptError::ERR_FLAT_LAND_REQUIRED); + ScriptError::RegisterErrorMap(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION, ScriptError::ERR_LAND_SLOPED_WRONG); + ScriptError::RegisterErrorMap(STR_ERROR_TRAIN_IN_THE_WAY, ScriptError::ERR_VEHICLE_IN_THE_WAY); + ScriptError::RegisterErrorMap(STR_ERROR_ROAD_VEHICLE_IN_THE_WAY, ScriptError::ERR_VEHICLE_IN_THE_WAY); + ScriptError::RegisterErrorMap(STR_ERROR_SHIP_IN_THE_WAY, ScriptError::ERR_VEHICLE_IN_THE_WAY); + ScriptError::RegisterErrorMap(STR_ERROR_AIRCRAFT_IN_THE_WAY, ScriptError::ERR_VEHICLE_IN_THE_WAY); + ScriptError::RegisterErrorMap(STR_ERROR_SITE_UNSUITABLE, ScriptError::ERR_SITE_UNSUITABLE); + ScriptError::RegisterErrorMap(STR_ERROR_TOO_CLOSE_TO_EDGE_OF_MAP, ScriptError::ERR_TOO_CLOSE_TO_EDGE); + ScriptError::RegisterErrorMap(STR_ERROR_STATION_TOO_SPREAD_OUT, ScriptError::ERR_STATION_TOO_SPREAD_OUT); + + ScriptError::RegisterErrorMapString(ScriptError::ERR_NONE, "ERR_NONE"); + ScriptError::RegisterErrorMapString(ScriptError::ERR_UNKNOWN, "ERR_UNKNOWN"); + ScriptError::RegisterErrorMapString(ScriptError::ERR_PRECONDITION_FAILED, "ERR_PRECONDITION_FAILED"); + ScriptError::RegisterErrorMapString(ScriptError::ERR_PRECONDITION_STRING_TOO_LONG, "ERR_PRECONDITION_STRING_TOO_LONG"); + ScriptError::RegisterErrorMapString(ScriptError::ERR_NEWGRF_SUPPLIED_ERROR, "ERR_NEWGRF_SUPPLIED_ERROR"); + ScriptError::RegisterErrorMapString(ScriptError::ERR_NOT_ENOUGH_CASH, "ERR_NOT_ENOUGH_CASH"); + ScriptError::RegisterErrorMapString(ScriptError::ERR_LOCAL_AUTHORITY_REFUSES, "ERR_LOCAL_AUTHORITY_REFUSES"); + ScriptError::RegisterErrorMapString(ScriptError::ERR_ALREADY_BUILT, "ERR_ALREADY_BUILT"); + ScriptError::RegisterErrorMapString(ScriptError::ERR_AREA_NOT_CLEAR, "ERR_AREA_NOT_CLEAR"); + ScriptError::RegisterErrorMapString(ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY, "ERR_OWNED_BY_ANOTHER_COMPANY"); + ScriptError::RegisterErrorMapString(ScriptError::ERR_NAME_IS_NOT_UNIQUE, "ERR_NAME_IS_NOT_UNIQUE"); + ScriptError::RegisterErrorMapString(ScriptError::ERR_FLAT_LAND_REQUIRED, "ERR_FLAT_LAND_REQUIRED"); + ScriptError::RegisterErrorMapString(ScriptError::ERR_LAND_SLOPED_WRONG, "ERR_LAND_SLOPED_WRONG"); + ScriptError::RegisterErrorMapString(ScriptError::ERR_VEHICLE_IN_THE_WAY, "ERR_VEHICLE_IN_THE_WAY"); + ScriptError::RegisterErrorMapString(ScriptError::ERR_SITE_UNSUITABLE, "ERR_SITE_UNSUITABLE"); + ScriptError::RegisterErrorMapString(ScriptError::ERR_TOO_CLOSE_TO_EDGE, "ERR_TOO_CLOSE_TO_EDGE"); + ScriptError::RegisterErrorMapString(ScriptError::ERR_STATION_TOO_SPREAD_OUT, "ERR_STATION_TOO_SPREAD_OUT"); + + SQGSError.DefSQStaticMethod(engine, &ScriptError::GetErrorCategory, "GetErrorCategory", 1, "."); + SQGSError.DefSQStaticMethod(engine, &ScriptError::GetLastError, "GetLastError", 1, "."); + SQGSError.DefSQStaticMethod(engine, &ScriptError::GetLastErrorString, "GetLastErrorString", 1, "."); + + SQGSError.PostRegister(engine); +} diff --git a/src/script/api/game/game_event.hpp.sq b/src/script/api/game/game_event.hpp.sq new file mode 100644 index 000000000..5f87970f6 --- /dev/null +++ b/src/script/api/game/game_event.hpp.sq @@ -0,0 +1,67 @@ +/* $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 . + */ + +/* THIS FILE IS AUTO-GENERATED; PLEASE DO NOT ALTER MANUALLY */ + +#include "../script_event.hpp" +#include "../template/template_event.hpp.sq" + + +template <> const char *GetClassName() { return "GSEvent"; } + +void SQGSEvent_Register(Squirrel *engine) +{ + DefSQClass SQGSEvent("GSEvent"); + SQGSEvent.PreRegister(engine); + SQGSEvent.AddConstructor(engine, "xi"); + + SQGSEvent.DefSQConst(engine, ScriptEvent::ET_INVALID, "ET_INVALID"); + SQGSEvent.DefSQConst(engine, ScriptEvent::ET_TEST, "ET_TEST"); + SQGSEvent.DefSQConst(engine, ScriptEvent::ET_SUBSIDY_OFFER, "ET_SUBSIDY_OFFER"); + SQGSEvent.DefSQConst(engine, ScriptEvent::ET_SUBSIDY_OFFER_EXPIRED, "ET_SUBSIDY_OFFER_EXPIRED"); + SQGSEvent.DefSQConst(engine, ScriptEvent::ET_SUBSIDY_AWARDED, "ET_SUBSIDY_AWARDED"); + SQGSEvent.DefSQConst(engine, ScriptEvent::ET_SUBSIDY_EXPIRED, "ET_SUBSIDY_EXPIRED"); + SQGSEvent.DefSQConst(engine, ScriptEvent::ET_ENGINE_PREVIEW, "ET_ENGINE_PREVIEW"); + SQGSEvent.DefSQConst(engine, ScriptEvent::ET_COMPANY_NEW, "ET_COMPANY_NEW"); + SQGSEvent.DefSQConst(engine, ScriptEvent::ET_COMPANY_IN_TROUBLE, "ET_COMPANY_IN_TROUBLE"); + SQGSEvent.DefSQConst(engine, ScriptEvent::ET_COMPANY_ASK_MERGER, "ET_COMPANY_ASK_MERGER"); + SQGSEvent.DefSQConst(engine, ScriptEvent::ET_COMPANY_MERGER, "ET_COMPANY_MERGER"); + SQGSEvent.DefSQConst(engine, ScriptEvent::ET_COMPANY_BANKRUPT, "ET_COMPANY_BANKRUPT"); + SQGSEvent.DefSQConst(engine, ScriptEvent::ET_VEHICLE_CRASHED, "ET_VEHICLE_CRASHED"); + SQGSEvent.DefSQConst(engine, ScriptEvent::ET_VEHICLE_LOST, "ET_VEHICLE_LOST"); + SQGSEvent.DefSQConst(engine, ScriptEvent::ET_VEHICLE_WAITING_IN_DEPOT, "ET_VEHICLE_WAITING_IN_DEPOT"); + SQGSEvent.DefSQConst(engine, ScriptEvent::ET_VEHICLE_UNPROFITABLE, "ET_VEHICLE_UNPROFITABLE"); + SQGSEvent.DefSQConst(engine, ScriptEvent::ET_INDUSTRY_OPEN, "ET_INDUSTRY_OPEN"); + SQGSEvent.DefSQConst(engine, ScriptEvent::ET_INDUSTRY_CLOSE, "ET_INDUSTRY_CLOSE"); + SQGSEvent.DefSQConst(engine, ScriptEvent::ET_ENGINE_AVAILABLE, "ET_ENGINE_AVAILABLE"); + SQGSEvent.DefSQConst(engine, ScriptEvent::ET_STATION_FIRST_VEHICLE, "ET_STATION_FIRST_VEHICLE"); + SQGSEvent.DefSQConst(engine, ScriptEvent::ET_DISASTER_ZEPPELINER_CRASHED, "ET_DISASTER_ZEPPELINER_CRASHED"); + SQGSEvent.DefSQConst(engine, ScriptEvent::ET_DISASTER_ZEPPELINER_CLEARED, "ET_DISASTER_ZEPPELINER_CLEARED"); + SQGSEvent.DefSQConst(engine, ScriptEvent::ET_TOWN_FOUNDED, "ET_TOWN_FOUNDED"); + SQGSEvent.DefSQConst(engine, ScriptEvent::ET_AIRCRAFT_DEST_TOO_FAR, "ET_AIRCRAFT_DEST_TOO_FAR"); + + SQGSEvent.DefSQMethod(engine, &ScriptEvent::GetEventType, "GetEventType", 1, "x"); + + SQGSEvent.PostRegister(engine); +} + + +template <> const char *GetClassName() { return "GSEventController"; } + +void SQGSEventController_Register(Squirrel *engine) +{ + DefSQClass SQGSEventController("GSEventController"); + SQGSEventController.PreRegister(engine); + SQGSEventController.AddConstructor(engine, "x"); + + SQGSEventController.DefSQStaticMethod(engine, &ScriptEventController::IsEventWaiting, "IsEventWaiting", 1, "."); + SQGSEventController.DefSQStaticMethod(engine, &ScriptEventController::GetNextEvent, "GetNextEvent", 1, "."); + + SQGSEventController.PostRegister(engine); +} diff --git a/src/script/api/game/game_execmode.hpp.sq b/src/script/api/game/game_execmode.hpp.sq new file mode 100644 index 000000000..93d980312 --- /dev/null +++ b/src/script/api/game/game_execmode.hpp.sq @@ -0,0 +1,25 @@ +/* $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 . + */ + +/* THIS FILE IS AUTO-GENERATED; PLEASE DO NOT ALTER MANUALLY */ + +#include "../script_execmode.hpp" +#include "../template/template_execmode.hpp.sq" + + +template <> const char *GetClassName() { return "GSExecMode"; } + +void SQGSExecMode_Register(Squirrel *engine) +{ + DefSQClass SQGSExecMode("GSExecMode"); + SQGSExecMode.PreRegister(engine); + SQGSExecMode.AddConstructor(engine, "x"); + + SQGSExecMode.PostRegister(engine); +} diff --git a/src/script/api/game/game_list.hpp.sq b/src/script/api/game/game_list.hpp.sq new file mode 100644 index 000000000..03049b314 --- /dev/null +++ b/src/script/api/game/game_list.hpp.sq @@ -0,0 +1,63 @@ +/* $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 . + */ + +/* THIS FILE IS AUTO-GENERATED; PLEASE DO NOT ALTER MANUALLY */ + +#include "../script_list.hpp" +#include "../template/template_list.hpp.sq" + + +template <> const char *GetClassName() { return "GSList"; } + +void SQGSList_Register(Squirrel *engine) +{ + DefSQClass SQGSList("GSList"); + SQGSList.PreRegister(engine); + SQGSList.AddConstructor(engine, "x"); + + SQGSList.DefSQConst(engine, ScriptList::SORT_BY_VALUE, "SORT_BY_VALUE"); + SQGSList.DefSQConst(engine, ScriptList::SORT_BY_ITEM, "SORT_BY_ITEM"); + + SQGSList.DefSQConst(engine, ScriptList::SORT_ASCENDING, "SORT_ASCENDING"); + SQGSList.DefSQConst(engine, ScriptList::SORT_DESCENDING, "SORT_DESCENDING"); + + SQGSList.DefSQMethod(engine, &ScriptList::AddItem, "AddItem", 3, "xii"); + SQGSList.DefSQMethod(engine, &ScriptList::RemoveItem, "RemoveItem", 2, "xi"); + SQGSList.DefSQMethod(engine, &ScriptList::Clear, "Clear", 1, "x"); + SQGSList.DefSQMethod(engine, &ScriptList::HasItem, "HasItem", 2, "xi"); + SQGSList.DefSQMethod(engine, &ScriptList::Begin, "Begin", 1, "x"); + SQGSList.DefSQMethod(engine, &ScriptList::Next, "Next", 1, "x"); + SQGSList.DefSQMethod(engine, &ScriptList::IsEmpty, "IsEmpty", 1, "x"); + SQGSList.DefSQMethod(engine, &ScriptList::IsEnd, "IsEnd", 1, "x"); + SQGSList.DefSQMethod(engine, &ScriptList::Count, "Count", 1, "x"); + SQGSList.DefSQMethod(engine, &ScriptList::GetValue, "GetValue", 2, "xi"); + SQGSList.DefSQMethod(engine, &ScriptList::SetValue, "SetValue", 3, "xii"); + SQGSList.DefSQMethod(engine, &ScriptList::Sort, "Sort", 3, "xib"); + SQGSList.DefSQMethod(engine, &ScriptList::AddList, "AddList", 2, "xx"); + SQGSList.DefSQMethod(engine, &ScriptList::RemoveAboveValue, "RemoveAboveValue", 2, "xi"); + SQGSList.DefSQMethod(engine, &ScriptList::RemoveBelowValue, "RemoveBelowValue", 2, "xi"); + SQGSList.DefSQMethod(engine, &ScriptList::RemoveBetweenValue, "RemoveBetweenValue", 3, "xii"); + SQGSList.DefSQMethod(engine, &ScriptList::RemoveValue, "RemoveValue", 2, "xi"); + SQGSList.DefSQMethod(engine, &ScriptList::RemoveTop, "RemoveTop", 2, "xi"); + SQGSList.DefSQMethod(engine, &ScriptList::RemoveBottom, "RemoveBottom", 2, "xi"); + SQGSList.DefSQMethod(engine, &ScriptList::RemoveList, "RemoveList", 2, "xx"); + SQGSList.DefSQMethod(engine, &ScriptList::KeepAboveValue, "KeepAboveValue", 2, "xi"); + SQGSList.DefSQMethod(engine, &ScriptList::KeepBelowValue, "KeepBelowValue", 2, "xi"); + SQGSList.DefSQMethod(engine, &ScriptList::KeepBetweenValue, "KeepBetweenValue", 3, "xii"); + SQGSList.DefSQMethod(engine, &ScriptList::KeepValue, "KeepValue", 2, "xi"); + SQGSList.DefSQMethod(engine, &ScriptList::KeepTop, "KeepTop", 2, "xi"); + SQGSList.DefSQMethod(engine, &ScriptList::KeepBottom, "KeepBottom", 2, "xi"); + SQGSList.DefSQMethod(engine, &ScriptList::KeepList, "KeepList", 2, "xx"); + SQGSList.DefSQAdvancedMethod(engine, &ScriptList::_get, "_get"); + SQGSList.DefSQAdvancedMethod(engine, &ScriptList::_set, "_set"); + SQGSList.DefSQAdvancedMethod(engine, &ScriptList::_nexti, "_nexti"); + SQGSList.DefSQAdvancedMethod(engine, &ScriptList::Valuate, "Valuate"); + + SQGSList.PostRegister(engine); +} diff --git a/src/script/api/game/game_log.hpp.sq b/src/script/api/game/game_log.hpp.sq new file mode 100644 index 000000000..1eb44d955 --- /dev/null +++ b/src/script/api/game/game_log.hpp.sq @@ -0,0 +1,29 @@ +/* $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 . + */ + +/* THIS FILE IS AUTO-GENERATED; PLEASE DO NOT ALTER MANUALLY */ + +#include "../script_log.hpp" +#include "../template/template_log.hpp.sq" + + +template <> const char *GetClassName() { return "GSLog"; } + +void SQGSLog_Register(Squirrel *engine) +{ + DefSQClass SQGSLog("GSLog"); + SQGSLog.PreRegister(engine); + SQGSLog.AddConstructor(engine, "x"); + + SQGSLog.DefSQStaticMethod(engine, &ScriptLog::Info, "Info", 2, ".."); + SQGSLog.DefSQStaticMethod(engine, &ScriptLog::Warning, "Warning", 2, ".."); + SQGSLog.DefSQStaticMethod(engine, &ScriptLog::Error, "Error", 2, ".."); + + SQGSLog.PostRegister(engine); +} diff --git a/src/script/api/game/game_testmode.hpp.sq b/src/script/api/game/game_testmode.hpp.sq new file mode 100644 index 000000000..6e1175f06 --- /dev/null +++ b/src/script/api/game/game_testmode.hpp.sq @@ -0,0 +1,25 @@ +/* $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 . + */ + +/* THIS FILE IS AUTO-GENERATED; PLEASE DO NOT ALTER MANUALLY */ + +#include "../script_testmode.hpp" +#include "../template/template_testmode.hpp.sq" + + +template <> const char *GetClassName() { return "GSTestMode"; } + +void SQGSTestMode_Register(Squirrel *engine) +{ + DefSQClass SQGSTestMode("GSTestMode"); + SQGSTestMode.PreRegister(engine); + SQGSTestMode.AddConstructor(engine, "x"); + + SQGSTestMode.PostRegister(engine); +} diff --git a/src/script/api/script_accounting.hpp b/src/script/api/script_accounting.hpp index f87d3749c..7477e09fe 100644 --- a/src/script/api/script_accounting.hpp +++ b/src/script/api/script_accounting.hpp @@ -17,7 +17,7 @@ /** * Class that keeps track of the costs, so you can request how much a block of * commands did cost in total. Works in both Execute as in Test mode. - * @api ai + * @api ai game * Example: *
  *   {
diff --git a/src/script/api/script_controller.hpp b/src/script/api/script_controller.hpp
index ab8bf8893..03d8604ec 100644
--- a/src/script/api/script_controller.hpp
+++ b/src/script/api/script_controller.hpp
@@ -19,7 +19,7 @@
  * The Controller, the class each Script should extend. It creates the Script,
  *  makes sure the logic kicks in correctly, and that GetTick() has a valid
  *  value.
- * @api ai
+ * @api ai game
  */
 class ScriptController {
 	friend class AIScanner;
diff --git a/src/script/api/script_error.hpp b/src/script/api/script_error.hpp
index 53c084fad..6e167bd2d 100644
--- a/src/script/api/script_error.hpp
+++ b/src/script/api/script_error.hpp
@@ -40,7 +40,7 @@
 
 /**
  * Class that handles all error related functions.
- * @api ai
+ * @api ai game
  */
 class ScriptError : public ScriptObject {
 public:
diff --git a/src/script/api/script_event.hpp b/src/script/api/script_event.hpp
index bfb49be78..ba8131eda 100644
--- a/src/script/api/script_event.hpp
+++ b/src/script/api/script_event.hpp
@@ -18,7 +18,7 @@
  * Class that handles all event related functions.
  * You can lookup the type, and than convert it to the real event-class.
  * That way you can request more detailed information about the event.
- * @api ai
+ * @api ai game
  */
 class ScriptEvent : public ScriptObject {
 public:
@@ -74,7 +74,7 @@ protected:
 
 /**
  * Class that handles all event related functions.
- * @api ai
+ * @api ai game
  * @note it is not needed to create an instance of ScriptEvent to access it, as
  *  all members are static, and all data is stored AI-wide.
  */
diff --git a/src/script/api/script_execmode.hpp b/src/script/api/script_execmode.hpp
index 5fe5853af..2c64a7a01 100644
--- a/src/script/api/script_execmode.hpp
+++ b/src/script/api/script_execmode.hpp
@@ -20,7 +20,7 @@
  *   Execute. The original mode is stored and recovered from when ever the
  *   instance is destroyed.
  * In Execute mode all commands you do are executed for real.
- * @api ai
+ * @api ai game
  */
 class ScriptExecMode : public ScriptObject {
 private:
diff --git a/src/script/api/script_info_docs.hpp b/src/script/api/script_info_docs.hpp
index 28f2b53f0..10d2f09f7 100644
--- a/src/script/api/script_info_docs.hpp
+++ b/src/script/api/script_info_docs.hpp
@@ -22,7 +22,7 @@
  *       the information here can be used for libraries, but the information
  *       will not be shown in the GUI except for error/debug messages.
  *
- * @api ai
+ * @api ai game
  */
 class ScriptInfo {
 public:
@@ -151,13 +151,12 @@ public:
 	 * and not the bugfix number as valid return for this function.
 	 *
 	 * Valid return values are:
-	 * - "0.7"
-	 * - "1.0"
-	 * - "1.1"
-	 * - "1.2"
+	 * - "0.7" (for AI only)
+	 * - "1.0" (for AI only)
+	 * - "1.1" (for AI only)
+	 * - "1.2" (for both AI and GS)
 	 *
 	 * @return The version this Script is compatible with.
-	 * @note This function is optional.
 	 */
 	string GetAPIVersion();
 
diff --git a/src/script/api/script_list.hpp b/src/script/api/script_list.hpp
index 42655e950..4e3d357d2 100644
--- a/src/script/api/script_list.hpp
+++ b/src/script/api/script_list.hpp
@@ -21,7 +21,7 @@ class ScriptListSorter;
 
 /**
  * Class that creates a list which can keep item/value pairs, which you can walk.
- * @api ai
+ * @api ai game
  */
 class ScriptList : public ScriptObject {
 public:
diff --git a/src/script/api/script_log.hpp b/src/script/api/script_log.hpp
index a3a1cd9bf..589310694 100644
--- a/src/script/api/script_log.hpp
+++ b/src/script/api/script_log.hpp
@@ -16,7 +16,7 @@
 
 /**
  * Class that handles all log related functions.
- * @api ai
+ * @api ai game
  */
 class ScriptLog : public ScriptObject {
 	/* ScriptController needs access to Enum and Log, in order to keep the flow from
diff --git a/src/script/api/script_testmode.hpp b/src/script/api/script_testmode.hpp
index a447ed814..161e490a3 100644
--- a/src/script/api/script_testmode.hpp
+++ b/src/script/api/script_testmode.hpp
@@ -22,7 +22,7 @@
  * In Test mode all the commands you execute aren't really executed. The
  *   system only checks if it would be able to execute your requests, and what
  *   the cost would be.
- * @api ai
+ * @api ai game
  */
 class ScriptTestMode : public ScriptObject {
 private:
diff --git a/src/script/api/squirrel_export.awk b/src/script/api/squirrel_export.awk
index 8e4bc3546..b0b169576 100644
--- a/src/script/api/squirrel_export.awk
+++ b/src/script/api/squirrel_export.awk
@@ -95,11 +95,13 @@ BEGIN {
 	has_fileheader = "false"
 	cls_level = 0
 	RS = "\r|\n"
+	apis = tolower(api)
+	if (apis == "gs") apis = "game"
 }
 
 /@file/ {
 	filename = $3
-	gsub("^" tolower(api) "_", "script_", filename)
+	gsub("^" apis "_", "script_", filename)
 }
 
 # Ignore special doxygen blocks
@@ -133,9 +135,9 @@ BEGIN {
 		api_selected = "false"
 	} else if ($0 == "-all") {
 		api_selected = "false"
-	} else if (match($0, "-" tolower(api))) {
+	} else if (match($0, "-" apis)) {
 		api_selected = "false"
-	} else if (match($0, tolower(api))) {
+	} else if (match($0, apis)) {
 		api_selected = "true"
 	}
 
diff --git a/src/script/api/squirrel_export.sh b/src/script/api/squirrel_export.sh
index c1182ce8f..fb8e5bb8b 100755
--- a/src/script/api/squirrel_export.sh
+++ b/src/script/api/squirrel_export.sh
@@ -39,6 +39,7 @@ fi
 case $apilc in
 	template) apiuc="Template" ;;
 	ai) apiuc="AI" ;;
+	game) apiuc="GS" ;;
 	*) echo "Unknown API type."; exit 1 ;;
 esac
 
diff --git a/src/script/squirrel.hpp b/src/script/squirrel.hpp
index dbccd3c08..4e31d3247 100644
--- a/src/script/squirrel.hpp
+++ b/src/script/squirrel.hpp
@@ -16,7 +16,8 @@
 
 /** The type of script we're working with, i.e. for who is it? */
 enum ScriptType {
-	ST_AI, ///< The script is for the AI.
+	ST_AI, ///< The script is for AI scripts.
+	ST_GS, ///< The script is for Game scripts.
 };
 
 class Squirrel {
-- 
cgit v1.2.3-70-g09d2