diff options
Diffstat (limited to 'src/script')
-rw-r--r-- | src/script/api/game/game_order.hpp.sq | 100 | ||||
-rw-r--r-- | src/script/api/script_order.hpp | 19 |
2 files changed, 118 insertions, 1 deletions
diff --git a/src/script/api/game/game_order.hpp.sq b/src/script/api/game/game_order.hpp.sq new file mode 100644 index 000000000..1f1bbf4fa --- /dev/null +++ b/src/script/api/game/game_order.hpp.sq @@ -0,0 +1,100 @@ +/* $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/>. + */ + +/* THIS FILE IS AUTO-GENERATED; PLEASE DO NOT ALTER MANUALLY */ + +#include "../script_order.hpp" +#include "../template/template_order.hpp.sq" + + +template <> const char *GetClassName<ScriptOrder, ST_GS>() { return "GSOrder"; } + +void SQGSOrder_Register(Squirrel *engine) +{ + DefSQClass<ScriptOrder, ST_GS> SQGSOrder("GSOrder"); + SQGSOrder.PreRegister(engine); + SQGSOrder.AddConstructor<void (ScriptOrder::*)(), 1>(engine, "x"); + + SQGSOrder.DefSQConst(engine, ScriptOrder::ERR_ORDER_BASE, "ERR_ORDER_BASE"); + SQGSOrder.DefSQConst(engine, ScriptOrder::ERR_ORDER_TOO_MANY, "ERR_ORDER_TOO_MANY"); + SQGSOrder.DefSQConst(engine, ScriptOrder::ERR_ORDER_TOO_FAR_AWAY_FROM_PREVIOUS_DESTINATION, "ERR_ORDER_TOO_FAR_AWAY_FROM_PREVIOUS_DESTINATION"); + SQGSOrder.DefSQConst(engine, ScriptOrder::ERR_ORDER_AIRCRAFT_NOT_ENOUGH_RANGE, "ERR_ORDER_AIRCRAFT_NOT_ENOUGH_RANGE"); + SQGSOrder.DefSQConst(engine, ScriptOrder::AIOF_NONE, "AIOF_NONE"); + SQGSOrder.DefSQConst(engine, ScriptOrder::AIOF_NON_STOP_INTERMEDIATE, "AIOF_NON_STOP_INTERMEDIATE"); + SQGSOrder.DefSQConst(engine, ScriptOrder::AIOF_NON_STOP_DESTINATION, "AIOF_NON_STOP_DESTINATION"); + SQGSOrder.DefSQConst(engine, ScriptOrder::AIOF_UNLOAD, "AIOF_UNLOAD"); + SQGSOrder.DefSQConst(engine, ScriptOrder::AIOF_TRANSFER, "AIOF_TRANSFER"); + SQGSOrder.DefSQConst(engine, ScriptOrder::AIOF_NO_UNLOAD, "AIOF_NO_UNLOAD"); + SQGSOrder.DefSQConst(engine, ScriptOrder::AIOF_FULL_LOAD, "AIOF_FULL_LOAD"); + SQGSOrder.DefSQConst(engine, ScriptOrder::AIOF_FULL_LOAD_ANY, "AIOF_FULL_LOAD_ANY"); + SQGSOrder.DefSQConst(engine, ScriptOrder::AIOF_NO_LOAD, "AIOF_NO_LOAD"); + SQGSOrder.DefSQConst(engine, ScriptOrder::AIOF_SERVICE_IF_NEEDED, "AIOF_SERVICE_IF_NEEDED"); + SQGSOrder.DefSQConst(engine, ScriptOrder::AIOF_STOP_IN_DEPOT, "AIOF_STOP_IN_DEPOT"); + SQGSOrder.DefSQConst(engine, ScriptOrder::AIOF_GOTO_NEAREST_DEPOT, "AIOF_GOTO_NEAREST_DEPOT"); + SQGSOrder.DefSQConst(engine, ScriptOrder::AIOF_NON_STOP_FLAGS, "AIOF_NON_STOP_FLAGS"); + SQGSOrder.DefSQConst(engine, ScriptOrder::AIOF_UNLOAD_FLAGS, "AIOF_UNLOAD_FLAGS"); + SQGSOrder.DefSQConst(engine, ScriptOrder::AIOF_LOAD_FLAGS, "AIOF_LOAD_FLAGS"); + SQGSOrder.DefSQConst(engine, ScriptOrder::AIOF_DEPOT_FLAGS, "AIOF_DEPOT_FLAGS"); + SQGSOrder.DefSQConst(engine, ScriptOrder::AIOF_INVALID, "AIOF_INVALID"); + SQGSOrder.DefSQConst(engine, ScriptOrder::OC_LOAD_PERCENTAGE, "OC_LOAD_PERCENTAGE"); + SQGSOrder.DefSQConst(engine, ScriptOrder::OC_RELIABILITY, "OC_RELIABILITY"); + SQGSOrder.DefSQConst(engine, ScriptOrder::OC_MAX_SPEED, "OC_MAX_SPEED"); + SQGSOrder.DefSQConst(engine, ScriptOrder::OC_AGE, "OC_AGE"); + SQGSOrder.DefSQConst(engine, ScriptOrder::OC_REQUIRES_SERVICE, "OC_REQUIRES_SERVICE"); + SQGSOrder.DefSQConst(engine, ScriptOrder::OC_UNCONDITIONALLY, "OC_UNCONDITIONALLY"); + SQGSOrder.DefSQConst(engine, ScriptOrder::OC_REMAINING_LIFETIME, "OC_REMAINING_LIFETIME"); + SQGSOrder.DefSQConst(engine, ScriptOrder::OC_INVALID, "OC_INVALID"); + SQGSOrder.DefSQConst(engine, ScriptOrder::CF_EQUALS, "CF_EQUALS"); + SQGSOrder.DefSQConst(engine, ScriptOrder::CF_NOT_EQUALS, "CF_NOT_EQUALS"); + SQGSOrder.DefSQConst(engine, ScriptOrder::CF_LESS_THAN, "CF_LESS_THAN"); + SQGSOrder.DefSQConst(engine, ScriptOrder::CF_LESS_EQUALS, "CF_LESS_EQUALS"); + SQGSOrder.DefSQConst(engine, ScriptOrder::CF_MORE_THAN, "CF_MORE_THAN"); + SQGSOrder.DefSQConst(engine, ScriptOrder::CF_MORE_EQUALS, "CF_MORE_EQUALS"); + SQGSOrder.DefSQConst(engine, ScriptOrder::CF_IS_TRUE, "CF_IS_TRUE"); + SQGSOrder.DefSQConst(engine, ScriptOrder::CF_IS_FALSE, "CF_IS_FALSE"); + SQGSOrder.DefSQConst(engine, ScriptOrder::CF_INVALID, "CF_INVALID"); + SQGSOrder.DefSQConst(engine, ScriptOrder::ORDER_CURRENT, "ORDER_CURRENT"); + SQGSOrder.DefSQConst(engine, ScriptOrder::ORDER_INVALID, "ORDER_INVALID"); + SQGSOrder.DefSQConst(engine, ScriptOrder::STOPLOCATION_NEAR, "STOPLOCATION_NEAR"); + SQGSOrder.DefSQConst(engine, ScriptOrder::STOPLOCATION_MIDDLE, "STOPLOCATION_MIDDLE"); + SQGSOrder.DefSQConst(engine, ScriptOrder::STOPLOCATION_FAR, "STOPLOCATION_FAR"); + SQGSOrder.DefSQConst(engine, ScriptOrder::STOPLOCATION_INVALID, "STOPLOCATION_INVALID"); + + ScriptError::RegisterErrorMap(STR_ERROR_NO_MORE_SPACE_FOR_ORDERS, ScriptOrder::ERR_ORDER_TOO_MANY); + ScriptError::RegisterErrorMap(STR_ERROR_TOO_FAR_FROM_PREVIOUS_DESTINATION, ScriptOrder::ERR_ORDER_TOO_FAR_AWAY_FROM_PREVIOUS_DESTINATION); + ScriptError::RegisterErrorMap(STR_ERROR_AIRCRAFT_NOT_ENOUGH_RANGE, ScriptOrder::ERR_ORDER_AIRCRAFT_NOT_ENOUGH_RANGE); + + ScriptError::RegisterErrorMapString(ScriptOrder::ERR_ORDER_TOO_MANY, "ERR_ORDER_TOO_MANY"); + ScriptError::RegisterErrorMapString(ScriptOrder::ERR_ORDER_TOO_FAR_AWAY_FROM_PREVIOUS_DESTINATION, "ERR_ORDER_TOO_FAR_AWAY_FROM_PREVIOUS_DESTINATION"); + ScriptError::RegisterErrorMapString(ScriptOrder::ERR_ORDER_AIRCRAFT_NOT_ENOUGH_RANGE, "ERR_ORDER_AIRCRAFT_NOT_ENOUGH_RANGE"); + + SQGSOrder.DefSQStaticMethod(engine, &ScriptOrder::IsValidVehicleOrder, "IsValidVehicleOrder", 3, ".ii"); + SQGSOrder.DefSQStaticMethod(engine, &ScriptOrder::IsGotoStationOrder, "IsGotoStationOrder", 3, ".ii"); + SQGSOrder.DefSQStaticMethod(engine, &ScriptOrder::IsGotoDepotOrder, "IsGotoDepotOrder", 3, ".ii"); + SQGSOrder.DefSQStaticMethod(engine, &ScriptOrder::IsGotoWaypointOrder, "IsGotoWaypointOrder", 3, ".ii"); + SQGSOrder.DefSQStaticMethod(engine, &ScriptOrder::IsConditionalOrder, "IsConditionalOrder", 3, ".ii"); + SQGSOrder.DefSQStaticMethod(engine, &ScriptOrder::IsVoidOrder, "IsVoidOrder", 3, ".ii"); + SQGSOrder.DefSQStaticMethod(engine, &ScriptOrder::IsRefitOrder, "IsRefitOrder", 3, ".ii"); + SQGSOrder.DefSQStaticMethod(engine, &ScriptOrder::IsCurrentOrderPartOfOrderList, "IsCurrentOrderPartOfOrderList", 2, ".i"); + SQGSOrder.DefSQStaticMethod(engine, &ScriptOrder::ResolveOrderPosition, "ResolveOrderPosition", 3, ".ii"); + SQGSOrder.DefSQStaticMethod(engine, &ScriptOrder::AreOrderFlagsValid, "AreOrderFlagsValid", 3, ".ii"); + SQGSOrder.DefSQStaticMethod(engine, &ScriptOrder::IsValidConditionalOrder, "IsValidConditionalOrder", 3, ".ii"); + SQGSOrder.DefSQStaticMethod(engine, &ScriptOrder::GetOrderCount, "GetOrderCount", 2, ".i"); + SQGSOrder.DefSQStaticMethod(engine, &ScriptOrder::GetOrderDestination, "GetOrderDestination", 3, ".ii"); + SQGSOrder.DefSQStaticMethod(engine, &ScriptOrder::GetOrderFlags, "GetOrderFlags", 3, ".ii"); + SQGSOrder.DefSQStaticMethod(engine, &ScriptOrder::GetOrderJumpTo, "GetOrderJumpTo", 3, ".ii"); + SQGSOrder.DefSQStaticMethod(engine, &ScriptOrder::GetOrderCondition, "GetOrderCondition", 3, ".ii"); + SQGSOrder.DefSQStaticMethod(engine, &ScriptOrder::GetOrderCompareFunction, "GetOrderCompareFunction", 3, ".ii"); + SQGSOrder.DefSQStaticMethod(engine, &ScriptOrder::GetOrderCompareValue, "GetOrderCompareValue", 3, ".ii"); + SQGSOrder.DefSQStaticMethod(engine, &ScriptOrder::GetStopLocation, "GetStopLocation", 3, ".ii"); + SQGSOrder.DefSQStaticMethod(engine, &ScriptOrder::GetOrderRefit, "GetOrderRefit", 3, ".ii"); + SQGSOrder.DefSQStaticMethod(engine, &ScriptOrder::GetOrderDistance, "GetOrderDistance", 4, ".iii"); + + SQGSOrder.PostRegister(engine); +} diff --git a/src/script/api/script_order.hpp b/src/script/api/script_order.hpp index 017ee3c91..eb301f50a 100644 --- a/src/script/api/script_order.hpp +++ b/src/script/api/script_order.hpp @@ -17,7 +17,7 @@ /** * Class that handles all order related functions. - * @api ai + * @api ai game */ class ScriptOrder : public ScriptObject { public: @@ -358,6 +358,7 @@ public: * @pre IsValidVehicleOrder(vehicle_id, jump_to). * @pre order_position != ORDER_CURRENT && IsConditionalOrder(vehicle_id, order_position). * @return Whether the order has been/can be changed. + * @api -game */ static bool SetOrderJumpTo(VehicleID vehicle_id, OrderPosition order_position, OrderPosition jump_to); @@ -370,6 +371,7 @@ public: * @pre order_position != ORDER_CURRENT && IsConditionalOrder(vehicle_id, order_position). * @pre condition >= OC_LOAD_PERCENTAGE && condition <= OC_UNCONDITIONALLY. * @return Whether the order has been/can be changed. + * @api -game */ static bool SetOrderCondition(VehicleID vehicle_id, OrderPosition order_position, OrderCondition condition); @@ -382,6 +384,7 @@ public: * @pre order_position != ORDER_CURRENT && IsConditionalOrder(vehicle_id, order_position). * @pre compare >= CF_EQUALS && compare <= CF_IS_FALSE. * @return Whether the order has been/can be changed. + * @api -game */ static bool SetOrderCompareFunction(VehicleID vehicle_id, OrderPosition order_position, CompareFunction compare); @@ -394,6 +397,7 @@ public: * @pre order_position != ORDER_CURRENT && IsConditionalOrder(vehicle_id, order_position). * @pre value >= 0 && value < 2048. * @return Whether the order has been/can be changed. + * @api -game */ static bool SetOrderCompareValue(VehicleID vehicle_id, OrderPosition order_position, int32 value); @@ -407,6 +411,7 @@ public: * @pre IsGotoStationOrder(vehicle_id, order_position). * @pre stop_location >= STOPLOCATION_NEAR && stop_location <= STOPLOCATION_FAR * @return Whether the order has been/can be changed. + * @api -game */ static bool SetStopLocation(VehicleID vehicle_id, OrderPosition order_position, StopLocation stop_location); @@ -419,6 +424,7 @@ public: * @pre IsGotoStationOrder(vehicle_id, order_position) || (IsGotoDepotOrder(vehicle_id, order_position) && refit_cargo != CT_AUTO_REFIT). * @pre ScriptCargo::IsValidCargo(refit_cargo) || refit_cargo == CT_AUTO_REFIT || refit_cargo == CT_NO_REFIT * @return Whether the order has been/can be changed. + * @api -game */ static bool SetOrderRefit(VehicleID vehicle_id, OrderPosition order_position, CargoID refit_cargo); @@ -433,6 +439,7 @@ public: * @exception ScriptOrder::ERR_ORDER_TOO_MANY * @exception ScriptOrder::ERR_ORDER_TOO_FAR_AWAY_FROM_PREVIOUS_DESTINATION * @return True if and only if the order was appended. + * @api -game */ static bool AppendOrder(VehicleID vehicle_id, TileIndex destination, ScriptOrderFlags order_flags); @@ -445,6 +452,7 @@ public: * @exception ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY * @exception ScriptOrder::ERR_ORDER_TOO_MANY * @return True if and only if the order was appended. + * @api -game */ static bool AppendConditionalOrder(VehicleID vehicle_id, OrderPosition jump_to); @@ -460,6 +468,7 @@ public: * @exception ScriptOrder::ERR_ORDER_TOO_MANY * @exception ScriptOrder::ERR_ORDER_TOO_FAR_AWAY_FROM_PREVIOUS_DESTINATION * @return True if and only if the order was inserted. + * @api -game */ static bool InsertOrder(VehicleID vehicle_id, OrderPosition order_position, TileIndex destination, ScriptOrderFlags order_flags); @@ -473,6 +482,7 @@ public: * @exception ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY * @exception ScriptOrder::ERR_ORDER_TOO_MANY * @return True if and only if the order was inserted. + * @api -game */ static bool InsertConditionalOrder(VehicleID vehicle_id, OrderPosition order_position, OrderPosition jump_to); @@ -483,6 +493,7 @@ public: * @pre IsValidVehicleOrder(vehicle_id, order_position). * @exception ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY * @return True if and only if the order was removed. + * @api -game */ static bool RemoveOrder(VehicleID vehicle_id, OrderPosition order_position); @@ -502,6 +513,7 @@ public: * @pre (order_flags & AIOF_GOTO_NEAREST_DEPOT) == (GetOrderFlags(vehicle_id, order_position) & AIOF_GOTO_NEAREST_DEPOT). * @exception ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY * @return True if and only if the order was changed. + * @api -game */ static bool SetOrderFlags(VehicleID vehicle_id, OrderPosition order_position, ScriptOrderFlags order_flags); @@ -518,6 +530,7 @@ public: * the target order is moved upwards (e.g. 3). If the order is moved * to a higher place (e.g. from 7 to 9) the target will be moved * downwards (e.g. 8). + * @api -game */ static bool MoveOrder(VehicleID vehicle_id, OrderPosition order_position_move, OrderPosition order_position_target); @@ -528,6 +541,7 @@ public: * @pre IsValidVehicleOrder(vehicle_id, next_order). * @exception ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY * @return True if and only the current order was changed. + * @api -game */ static bool SkipToOrder(VehicleID vehicle_id, OrderPosition next_order); @@ -542,6 +556,7 @@ public: * @exception ScriptOrder::ERR_ORDER_TOO_MANY * @exception ScriptOrder::ERR_ORDER_AIRCRAFT_NOT_ENOUGH_RANGE * @return True if and only if the copying succeeded. + * @api -game */ static bool CopyOrders(VehicleID vehicle_id, VehicleID main_vehicle_id); @@ -555,6 +570,7 @@ public: * @exception ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY * @exception ScriptOrder::ERR_ORDER_AIRCRAFT_NOT_ENOUGH_RANGE * @return True if and only if the sharing succeeded. + * @api -game */ static bool ShareOrders(VehicleID vehicle_id, VehicleID main_vehicle_id); @@ -563,6 +579,7 @@ public: * @param vehicle_id The vehicle to remove from the shared order list. * @pre ScriptVehicle::IsValidVehicle(vehicle_id). * @return True if and only if the unsharing succeeded. + * @api -game */ static bool UnshareOrders(VehicleID vehicle_id); |