From 12aa5b6a583aa7ca9092ec6c77e7b12677cdd6a4 Mon Sep 17 00:00:00 2001 From: truebrain Date: Mon, 19 Dec 2011 20:50:54 +0000 Subject: [PATCH] (svn r23604) -Add: initial support for GameScripts --- projects/openttd_vs100.vcxproj | 4 + projects/openttd_vs100.vcxproj.filters | 49 ++++++--- projects/openttd_vs80.vcproj | 20 ++++ projects/openttd_vs90.vcproj | 20 ++++ source.list | 6 ++ src/command_func.h | 3 + src/game/game.hpp | 45 ++++++++ src/game/game_core.cpp | 64 ++++++++++++ src/game/game_instance.cpp | 89 ++++++++++++++++ src/game/game_instance.hpp | 36 +++++++ src/misc.cpp | 2 + src/network/network_command.cpp | 1 + src/openttd.cpp | 6 +- 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 +- 33 files changed, 729 insertions(+), 37 deletions(-) create mode 100644 src/game/game.hpp create mode 100644 src/game/game_core.cpp create mode 100644 src/game/game_instance.cpp create mode 100644 src/game/game_instance.hpp 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 diff --git a/projects/openttd_vs100.vcxproj b/projects/openttd_vs100.vcxproj index ff0ec9a9cf..44aa0247ea 100644 --- a/projects/openttd_vs100.vcxproj +++ b/projects/openttd_vs100.vcxproj @@ -913,6 +913,10 @@ + + + + diff --git a/projects/openttd_vs100.vcxproj.filters b/projects/openttd_vs100.vcxproj.filters index a90e8d8d16..7a5d16e2e6 100644 --- a/projects/openttd_vs100.vcxproj.filters +++ b/projects/openttd_vs100.vcxproj.filters @@ -43,57 +43,60 @@ {c76ff9f1-1e62-46d8-8d55-000000000013} - + {c76ff9f1-1e62-46d8-8d55-000000000014} - + {c76ff9f1-1e62-46d8-8d55-000000000015} - + {c76ff9f1-1e62-46d8-8d55-000000000016} - + {c76ff9f1-1e62-46d8-8d55-000000000017} - + {c76ff9f1-1e62-46d8-8d55-000000000018} - + {c76ff9f1-1e62-46d8-8d55-000000000019} - + {c76ff9f1-1e62-46d8-8d55-000000000020} - + {c76ff9f1-1e62-46d8-8d55-000000000021} - + {c76ff9f1-1e62-46d8-8d55-000000000022} - + {c76ff9f1-1e62-46d8-8d55-000000000023} - + {c76ff9f1-1e62-46d8-8d55-000000000024} - + {c76ff9f1-1e62-46d8-8d55-000000000025} - + {c76ff9f1-1e62-46d8-8d55-000000000026} - + {c76ff9f1-1e62-46d8-8d55-000000000027} - + {c76ff9f1-1e62-46d8-8d55-000000000028} - + {c76ff9f1-1e62-46d8-8d55-000000000029} - + {c76ff9f1-1e62-46d8-8d55-000000000030} + + {c76ff9f1-1e62-46d8-8d55-000000000031} + @@ -1962,6 +1965,18 @@ AI API + + Game Core + + + Game Core + + + Game Core + + + Game Core + Script API diff --git a/projects/openttd_vs80.vcproj b/projects/openttd_vs80.vcproj index f60e5fa074..5d6897dfa8 100644 --- a/projects/openttd_vs80.vcproj +++ b/projects/openttd_vs80.vcproj @@ -2975,6 +2975,26 @@ > + + + + + + + + + + diff --git a/projects/openttd_vs90.vcproj b/projects/openttd_vs90.vcproj index 636b9f1318..f253d4c964 100644 --- a/projects/openttd_vs90.vcproj +++ b/projects/openttd_vs90.vcproj @@ -2972,6 +2972,26 @@ > + + + + + + + + + + diff --git a/source.list b/source.list index 1de4d68b55..cdc5cbf230 100644 --- a/source.list +++ b/source.list @@ -686,6 +686,12 @@ ai/ai_scanner.hpp # AI API script/api/ai_changelog.hpp +# Game Core +game/game.hpp +game/game_core.cpp +game/game_instance.cpp +game/game_instance.hpp + # Script API script/api/script_accounting.hpp script/api/script_airport.hpp diff --git a/src/command_func.h b/src/command_func.h index a4304de0de..df5f099a7b 100644 --- a/src/command_func.h +++ b/src/command_func.h @@ -86,6 +86,9 @@ CommandCallback CcBuildCanal; /* depot_gui.cpp */ CommandCallback CcCloneVehicle; +/* game/game_instance.cpp */ +CommandCallback CcGame; + /* group_gui.cpp */ CommandCallback CcCreateGroup; diff --git a/src/game/game.hpp b/src/game/game.hpp new file mode 100644 index 0000000000..de9e8213c2 --- /dev/null +++ b/src/game/game.hpp @@ -0,0 +1,45 @@ +/* $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 . + */ + +/** @file game.hpp Base functions for all Games. */ + +#ifndef GAME_HPP +#define GAME_HPP + +/** + * Main Game class. Contains all functions needed to start, stop, save and load Game Scripts. + */ +class Game { +public: + /** + * Called every game-tick to let Game do something. + */ + static void GameLoop(); + + /** + * Initialize the Game system. + */ + static void Initialize(); + + /** + * Uninitialize the Game system. + */ + static void Uninitialize(); + + /** + * Get the current GameScript instance. + */ + static class GameInstance *GetGameInstance() { return Game::instance; } + +private: + static uint frame_counter; ///< Tick counter for the Game code. + static class GameInstance *instance; ///< Instance to the current active Game. +}; + +#endif /* GAME_HPP */ diff --git a/src/game/game_core.cpp b/src/game/game_core.cpp new file mode 100644 index 0000000000..7894ab2a60 --- /dev/null +++ b/src/game/game_core.cpp @@ -0,0 +1,64 @@ +/* $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 . + */ + +/** @file game_core.cpp Implementation of Game. */ + +#include "../stdafx.h" +#include "../command_func.h" +#include "../core/backup_type.hpp" +#include "../company_base.h" +#include "../company_func.h" +#include "../network/network.h" +#include "game.hpp" +#include "game_instance.hpp" + +/* static */ uint Game::frame_counter = 0; +/* static */ GameInstance *Game::instance = NULL; + +/* static */ void Game::GameLoop() +{ + if (_networking && !_network_server) return; + + Game::frame_counter++; + + Backup cur_company(_current_company, FILE_LINE); + cur_company.Change(OWNER_DEITY); + Game::instance->GameLoop(); + cur_company.Restore(); + + /* Occasionally collect garbage */ + if ((Game::frame_counter & 255) == 0) { + Game::instance->CollectGarbage(); + } +} + +/* static */ void Game::Initialize() +{ + if (Game::instance != NULL) Game::Uninitialize(); + + Game::frame_counter = 0; + if (Game::instance == NULL) { + /* Clients shouldn't start GameScripts */ + if (_networking && !_network_server) return; + + Backup cur_company(_current_company, FILE_LINE); + cur_company.Change(OWNER_DEITY); + + Game::instance = new GameInstance(); + Game::instance->Initialize(); + + cur_company.Restore(); + } +} + +/* static */ void Game::Uninitialize() +{ + delete Game::instance; + Game::instance = NULL; +} diff --git a/src/game/game_instance.cpp b/src/game/game_instance.cpp new file mode 100644 index 0000000000..ed30062e1d --- /dev/null +++ b/src/game/game_instance.cpp @@ -0,0 +1,89 @@ +/* $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 . + */ + +/** @file game_instance.cpp Implementation of GameInstance. */ + +#include "../stdafx.h" +#include "../debug.h" +#include "../saveload/saveload.h" + +#include "../script/squirrel_class.hpp" + +#include "../script/script_storage.hpp" +#include "game_instance.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_controller.hpp.sq" +#include "../script/api/game/game_error.hpp.sq" +#include "../script/api/game/game_event.hpp.sq" +#include "../script/api/game/game_execmode.hpp.sq" +#include "../script/api/game/game_list.hpp.sq" +#include "../script/api/game/game_log.hpp.sq" +#include "../script/api/game/game_testmode.hpp.sq" + + +GameInstance::GameInstance() : + ScriptInstance("GS") +{} + +void GameInstance::Initialize() +{ + /* Register the GameController */ + SQGSController_Register(this->engine); + + ScriptInstance::Initialize("test/main.nut", "TestGame"); +} + +void GameInstance::RegisterAPI() +{ + ScriptInstance::RegisterAPI(); + +/* Register all classes */ + SQGSList_Register(this->engine); + SQGSAccounting_Register(this->engine); + SQGSError_Register(this->engine); + SQGSEvent_Register(this->engine); + SQGSEventController_Register(this->engine); + SQGSExecMode_Register(this->engine); + SQGSLog_Register(this->engine); + SQGSTestMode_Register(this->engine); + +} + +int GameInstance::GetSetting(const char *name) +{ + return NULL; +} + +ScriptInfo *GameInstance::FindLibrary(const char *library, int version) +{ + /* 'import' is not supported with GameScripts */ + return NULL; +} + +/** + * 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; +} diff --git a/src/game/game_instance.hpp b/src/game/game_instance.hpp new file mode 100644 index 0000000000..10937c6483 --- /dev/null +++ b/src/game/game_instance.hpp @@ -0,0 +1,36 @@ +/* $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 . + */ + +/** @file game_instance.hpp The GameInstance tracks games. */ + +#ifndef GAME_INSTANCE_HPP +#define GAME_INSTANCE_HPP + +#include "../script/script_instance.hpp" + +/** Runtime information about a game script like a pointer to the squirrel vm and the current state. */ +class GameInstance : public ScriptInstance { +public: + GameInstance(); + + /** + * Initialize the script and prepare it for its first run. + */ + void Initialize(); + + /* virtual */ int GetSetting(const char *name); + /* virtual */ ScriptInfo *FindLibrary(const char *library, int version); + +private: + /* virtual */ void RegisterAPI(); + /* virtual */ CommandCallback *GetDoCommandCallback(); + /* virtual */ void LoadDummyScript() {} +}; + +#endif /* GAME_INSTANCE_HPP */ diff --git a/src/misc.cpp b/src/misc.cpp index 614ca4013b..5f05c9fe9d 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -27,6 +27,7 @@ #include "network/network_func.h" #include "window_func.h" #include "core/pool_type.hpp" +#include "game/game.hpp" extern TileIndex _cur_tileloop_tile; @@ -94,6 +95,7 @@ void InitializeGame(uint size_x, uint size_y, bool reset_date, bool reset_settin InitializeCompanies(); AI::Initialize(); + Game::Initialize(); InitializeCheats(); InitTextEffects(); diff --git a/src/network/network_command.cpp b/src/network/network_command.cpp index 02ee6acf81..c5ec83e28f 100644 --- a/src/network/network_command.cpp +++ b/src/network/network_command.cpp @@ -47,6 +47,7 @@ static CommandCallback * const _callback_table[] = { /* 0x17 */ CcRoadStop, /* 0x18 */ CcBuildIndustry, /* 0x19 */ CcStartStopVehicle, + /* 0x1A */ CcGame, }; /** diff --git a/src/openttd.cpp b/src/openttd.cpp index 5745fadee1..81c9dd4434 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -62,6 +62,7 @@ #include "hotkeys.h" #include "newgrf.h" #include "misc/getoptdata.h" +#include "game/game.hpp" #include "town.h" @@ -284,8 +285,9 @@ static void ShutdownGame() UnInitWindowSystem(); - /* stop the AI */ + /* stop the scripts */ AI::Uninitialize(false); + Game::Uninitialize(); /* Uninitialize variables that are allocated dynamically */ GamelogReset(); @@ -1253,6 +1255,7 @@ void StateGameLoop() /* dont execute the state loop during pause */ if (_pause_mode != PM_UNPAUSED) { UpdateLandscapingLimits(); + Game::GameLoop(); CallWindowTickEvent(); return; } @@ -1291,6 +1294,7 @@ void StateGameLoop() ClearStorageChanges(true); AI::GameLoop(); + Game::GameLoop(); UpdateLandscapingLimits(); CallWindowTickEvent(); 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 0000000000..0e78172c0a --- /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 0000000000..53882fd3a2 --- /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 0000000000..ff3f940f35 --- /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 0000000000..5f87970f6a --- /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 0000000000..93d980312a --- /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 0000000000..03049b314f --- /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 0000000000..1eb44d955d --- /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 0000000000..6e1175f061 --- /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 f87d3749c3..7477e09fe0 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 ab8bf8893c..03d8604ece 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 53c084fadf..6e167bd2d2 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 bfb49be786..ba8131edab 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 5fe5853afb..2c64a7a01d 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 28f2b53f0b..10d2f09f7c 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 42655e950a..4e3d357d22 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 a3a1cd9bff..5893106943 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 a447ed8146..161e490a33 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 8e4bc35462..b0b1695762 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 c1182ce8f0..fb8e5bb8b5 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 dbccd3c08a..4e31d3247e 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 {