diff options
-rw-r--r-- | src/ai/api/ai_order.cpp | 138 | ||||
-rw-r--r-- | src/ai/api/ai_order.hpp | 157 | ||||
-rw-r--r-- | src/ai/api/ai_order.hpp.sq | 60 |
3 files changed, 335 insertions, 20 deletions
diff --git a/src/ai/api/ai_order.cpp b/src/ai/api/ai_order.cpp index 6e8b1163a..194addf20 100644 --- a/src/ai/api/ai_order.cpp +++ b/src/ai/api/ai_order.cpp @@ -42,6 +42,15 @@ static OrderType GetOrderTypeByTile(TileIndex t) return AIVehicle::IsValidVehicle(vehicle_id) && order_position >= 0 && (order_position < ::GetVehicle(vehicle_id)->GetNumOrders() || order_position == ORDER_CURRENT); } +/* static */ bool AIOrder::IsConditionalOrder(VehicleID vehicle_id, OrderPosition order_position) +{ + if (order_position == ORDER_CURRENT) return false; + if (!IsValidVehicleOrder(vehicle_id, order_position)) return false; + + const Order *order = ::GetVehicleOrder(GetVehicle(vehicle_id), order_position); + return order->GetType() == OT_CONDITIONAL; +} + /* static */ AIOrder::OrderPosition AIOrder::ResolveOrderPosition(VehicleID vehicle_id, OrderPosition order_position) { if (!AIVehicle::IsValidVehicle(vehicle_id)) return ORDER_INVALID; @@ -70,6 +79,25 @@ static OrderType GetOrderTypeByTile(TileIndex t) } } +/* static */ bool AIOrder::IsValidConditionalOrder(OrderCondition condition, CompareFunction compare) +{ + switch (condition) { + case OC_LOAD_PERCENTAGE: + case OC_RELIABILITY: + case OC_MAX_SPEED: + case OC_AGE: + return compare >= CF_EQUALS && compare <= CF_MORE_EQUALS); + + case OC_REQUIRES_SERVICE: + return compare == CF_IS_TRUE || compare == CF_IS_FALSE; + + case OC_UNCONDITIONALLY: + return true; + + default: return false; + } +} + /* static */ int32 AIOrder::GetOrderCount(VehicleID vehicle_id) { return AIVehicle::IsValidVehicle(vehicle_id) ? ::GetVehicle(vehicle_id)->GetNumOrders() : -1; @@ -84,8 +112,8 @@ static OrderType GetOrderTypeByTile(TileIndex t) if (order_position == ORDER_CURRENT) { order = &v->current_order; } else { - order = v->GetFirstOrder(); - for (int i = 0; i < order_position; i++) order = order->next; + order = ::GetVehicleOrder(GetVehicle(vehicle_id), order_position); + if (order->GetType() == OT_CONDITIONAL) return INVALID_TILE; } switch (order->GetType()) { @@ -107,8 +135,8 @@ static OrderType GetOrderTypeByTile(TileIndex t) if (order_position == ORDER_CURRENT) { order = &::GetVehicle(vehicle_id)->current_order; } else { - order = ::GetVehicle(vehicle_id)->GetFirstOrder(); - for (int i = 0; i < order_position; i++) order = order->next; + order = ::GetVehicleOrder(GetVehicle(vehicle_id), order_position); + if (order->GetType() == OT_CONDITIONAL) return AIOF_INVALID; } AIOrderFlags order_flags = AIOF_NONE; @@ -129,12 +157,97 @@ static OrderType GetOrderTypeByTile(TileIndex t) return order_flags; } +/* static */ AIOrder::OrderPosition AIOrder::GetOrderJumpTo(VehicleID vehicle_id, OrderPosition order_position) +{ + if (!IsValidVehicleOrder(vehicle_id, order_position)) return ORDER_INVALID; + if (order_position == ORDER_CURRENT || !IsConditionalOrder(vehicle_id, order_position)) return ORDER_INVALID; + + const Order *order = ::GetVehicleOrder(GetVehicle(vehicle_id), order_position); + return (OrderPosition)order->GetConditionSkipToOrder(); +} + +/* static */ AIOrder::OrderCondition AIOrder::GetOrderCondition(VehicleID vehicle_id, OrderPosition order_position) +{ + if (!IsValidVehicleOrder(vehicle_id, order_position)) return OC_INVALID; + if (order_position == ORDER_CURRENT || !IsConditionalOrder(vehicle_id, order_position)) return OC_INVALID; + + const Order *order = ::GetVehicleOrder(GetVehicle(vehicle_id), order_position); + return (OrderCondition)order->GetConditionVariable(); +} + +/* static */ AIOrder::CompareFunction AIOrder::GetOrderCompareFunction(VehicleID vehicle_id, OrderPosition order_position) +{ + if (!IsValidVehicleOrder(vehicle_id, order_position)) return CF_INVALID; + if (order_position == ORDER_CURRENT || !IsConditionalOrder(vehicle_id, order_position)) return CF_INVALID; + + const Order *order = ::GetVehicleOrder(GetVehicle(vehicle_id), order_position); + return (CompareFunction)order->GetConditionComparator(); +} + +/* static */ int32 AIOrder::GetOrderCompareValue(VehicleID vehicle_id, OrderPosition order_position) +{ + if (!IsValidVehicleOrder(vehicle_id, order_position)) return -1; + if (order_position == ORDER_CURRENT || !IsConditionalOrder(vehicle_id, order_position)) return -1; + + const Order *order = ::GetVehicleOrder(GetVehicle(vehicle_id), order_position); + int32 value = order->GetConditionValue(); + if (order->GetConditionVariable() == OCV_MAX_SPEED) value = value * 16 / 10; + return value; +} + +/* static */ bool AIOrder::SetOrderJumpTo(VehicleID vehicle_id, OrderPosition order_position, OrderPosition jump_to) +{ + EnforcePrecondition(false, IsValidVehicleOrder(vehicle_id, order_position)); + EnforcePrecondition(false, order_position != ORDER_CURRENT && IsConditionalOrder(vehicle_id, order_position)); + EnforcePrecondition(false, IsValidVehicleOrder(vehicle_id, jump_to) && jump_to != ORDER_CURRENT); + + return AIObject::DoCommand(0, vehicle_id | (order_position << 16), MOF_COND_DESTINATION | (jump_to << 4), CMD_MODIFY_ORDER); +} + +/* static */ bool AIOrder::SetOrderCondition(VehicleID vehicle_id, OrderPosition order_position, OrderCondition condition) +{ + EnforcePrecondition(false, IsValidVehicleOrder(vehicle_id, order_position)); + EnforcePrecondition(false, order_position != ORDER_CURRENT && IsConditionalOrder(vehicle_id, order_position)); + EnforcePrecondition(false, condition >= OC_LOAD_PERCENTAGE && condition <= OC_UNCONDITIONALLY); + + return AIObject::DoCommand(0, vehicle_id | (order_position << 16), MOF_COND_VARIABLE | (condition << 4), CMD_MODIFY_ORDER); +} + +/* static */ bool AIOrder::SetOrderCompareFunction(VehicleID vehicle_id, OrderPosition order_position, CompareFunction compare) +{ + EnforcePrecondition(false, IsValidVehicleOrder(vehicle_id, order_position)); + EnforcePrecondition(false, order_position != ORDER_CURRENT && IsConditionalOrder(vehicle_id, order_position)); + EnforcePrecondition(false, compare >= CF_EQUALS && compare <= CF_IS_FALSE); + + return AIObject::DoCommand(0, vehicle_id | (order_position << 16), MOF_COND_COMPARATOR | (compare << 4), CMD_MODIFY_ORDER); +} + +/* static */ bool AIOrder::SetOrderCompareValue(VehicleID vehicle_id, OrderPosition order_position, int32 value) +{ + EnforcePrecondition(false, IsValidVehicleOrder(vehicle_id, order_position)); + EnforcePrecondition(false, order_position != ORDER_CURRENT && IsConditionalOrder(vehicle_id, order_position)); + EnforcePrecondition(false, value >= 0 && value < 2048); + if (GetOrderCondition(vehicle_id, order_position) == OC_MAX_SPEED) value = value * 10 / 16; + + return AIObject::DoCommand(0, vehicle_id | (order_position << 16), MOF_COND_VALUE | (value << 4), CMD_MODIFY_ORDER); +} + /* static */ bool AIOrder::AppendOrder(VehicleID vehicle_id, TileIndex destination, AIOrderFlags order_flags) { EnforcePrecondition(false, AIVehicle::IsValidVehicle(vehicle_id)); + EnforcePrecondition(false, AreOrderFlagsValid(destination, order_flags)); + return InsertOrder(vehicle_id, (AIOrder::OrderPosition)::GetVehicle(vehicle_id)->GetNumOrders(), destination, order_flags); } +/* static */ bool AIOrder::AppendConditionalOrder(VehicleID vehicle_id, OrderPosition jump_to) +{ + EnforcePrecondition(false, AIVehicle::IsValidVehicle(vehicle_id)); + EnforcePrecondition(false, IsValidVehicleOrder(vehicle_id, jump_to)); + + return InsertConditionalOrder(vehicle_id, (AIOrder::OrderPosition)::GetVehicle(vehicle_id)->GetNumOrders(), jump_to); +} + /* static */ bool AIOrder::InsertOrder(VehicleID vehicle_id, OrderPosition order_position, TileIndex destination, AIOrder::AIOrderFlags order_flags) { /* IsValidVehicleOrder is not good enough because it does not allow appending. */ @@ -169,6 +282,20 @@ static OrderType GetOrderTypeByTile(TileIndex t) return AIObject::DoCommand(0, vehicle_id | (order_position << 16), order.Pack(), CMD_INSERT_ORDER); } +/* static */ bool AIOrder::InsertConditionalOrder(VehicleID vehicle_id, OrderPosition order_position, OrderPosition jump_to) +{ + /* IsValidVehicleOrder is not good enough because it does not allow appending. */ + if (order_position == ORDER_CURRENT) order_position = AIOrder::ResolveOrderPosition(vehicle_id, order_position); + + EnforcePrecondition(false, AIVehicle::IsValidVehicle(vehicle_id)); + EnforcePrecondition(false, IsValidVehicleOrder(vehicle_id, jump_to)); + + Order order; + order.MakeConditional(jump_to); + + return AIObject::DoCommand(0, vehicle_id | (order_position << 16), order.Pack(), CMD_INSERT_ORDER); +} + /* static */ bool AIOrder::RemoveOrder(VehicleID vehicle_id, OrderPosition order_position) { order_position = AIOrder::ResolveOrderPosition(vehicle_id, order_position); @@ -211,8 +338,7 @@ static void _DoCommandReturnChangeOrder(class AIInstance *instance) EnforcePrecondition(false, IsValidVehicleOrder(vehicle_id, order_position)); EnforcePrecondition(false, AreOrderFlagsValid(GetOrderDestination(vehicle_id, order_position), order_flags)); - Order *order = ::GetVehicle(vehicle_id)->GetFirstOrder(); - for (int i = 0; i < order_position; i++) order = order->next; + const Order *order = ::GetVehicleOrder(GetVehicle(vehicle_id), order_position); AIOrderFlags current = GetOrderFlags(vehicle_id, order_position); diff --git a/src/ai/api/ai_order.hpp b/src/ai/api/ai_order.hpp index e5b2cd000..5365b56ff 100644 --- a/src/ai/api/ai_order.hpp +++ b/src/ai/api/ai_order.hpp @@ -69,6 +69,36 @@ public: AIOF_INVALID = 0xFFFF, }; + /** + * All conditions a conditional order can depend on. + */ + enum OrderCondition { + /* Order _is_ important, as it's based on OrderConditionVariable in order_type.h. */ + OC_LOAD_PERCENTAGE, //!< Skip based on the amount of load, value is in tons. + OC_RELIABILITY, //!< Skip based on the reliability, value is percent (0..100). + OC_MAX_SPEED, //!< Skip based on the maximum speed, value is in OpenTTD's internal speed unit, see AIEngine::GetMaxSpeed. + OC_AGE, //!< Skip based on the age, value is in years. + OC_REQUIRES_SERVICE, //!< Skip when the vehicle requires service, no value. + OC_UNCONDITIONALLY, //!< Always skip, no compare function, no value. + OC_INVALID = -1, //!< An invalid condition, do not use. + }; + + /** + * Comparators for conditional orders. + */ + enum CompareFunction { + /* Order _is_ important, as it's based on OrderConditionComparator in order_type.h. */ + CF_EQUALS, //!< Skip if both values are equal + CF_NOT_EQUALS, //!< Skip if both values are not equal + CF_LESS_THAN, //!< Skip if the value is less than the limit + CF_LESS_EQUALS, //!< Skip if the value is less or equal to the limit + CF_MORE_THAN, //!< Skip if the value is more than the limit + CF_MORE_EQUALS, //!< Skip if the value is more or equal to the limit + CF_IS_TRUE, //!< Skip if the variable is true + CF_IS_FALSE, //!< Skip if the variable is false + CF_INVALID = -1, //!< Invalid compare function, do not use. + }; + /** Different constants related to the OrderPosition */ enum OrderPosition { ORDER_CURRENT = 0xFF, //!< Constant that gets resolved to the current order. @@ -85,6 +115,15 @@ public: static bool IsValidVehicleOrder(VehicleID vehicle_id, OrderPosition order_position); /** + * Checks whether the given order is a conditional order. + * @param vehicle_id The vehicle to check. + * @param order_position The order index to check. + * @pre order_position != ORDER_CURRENT && IsValidVehicleOrder(vehicle_id, order_position). + * @return True if and only if the order is a conditional order. + */ + static bool IsConditionalOrder(VehicleID vehicle_id, OrderPosition order_position); + + /** * Resolves the given order index to the correct index for the given vehicle. * If the order index was ORDER_CURRENT it will be resolved to the index of * the current order (as shown in the order list). If the order with the @@ -105,6 +144,14 @@ public: static bool AreOrderFlagsValid(TileIndex destination, AIOrderFlags order_flags); /** + * Checks whether the given combination of condition and compare function is valid. + * @param condition The condition to check. + * @param compare The compare function to check. + * @return True if and only if the combination of condition and compare function is valid. + */ + static bool IsValidConditionalOrder(OrderCondition condition, CompareFunction compare); + + /** * Returns the number of orders for the given vehicle. * @param vehicle_id The vehicle to get the order count of. * @pre AIVehicle::IsValidVehicle(vehicle_id). @@ -118,6 +165,7 @@ public: * @param vehicle_id The vehicle to get the destination for. * @param order_position The order to get the destination for. * @pre IsValidVehicleOrder(vehicle_id, order_position). + * @pre order_position == ORDER_CURRENT || !IsConditionalOrder(vehicle_id, order_position). * @note Giving ORDER_CURRENT as order_position will give the order that is * currently being executed by the vehicle. This is not necessarily the * current order as given by ResolveOrderPosition (the current index in the @@ -132,6 +180,7 @@ public: * @param vehicle_id The vehicle to get the destination for. * @param order_position The order to get the destination for. * @pre IsValidVehicleOrder(vehicle_id, order_position). + * @pre order_position == ORDER_CURRENT || !IsConditionalOrder(vehicle_id, order_position). * @note Giving ORDER_CURRENT as order_position will give the order that is * currently being executed by the vehicle. This is not necessarily the * current order as given by ResolveOrderPosition (the current index in the @@ -142,6 +191,89 @@ public: static AIOrderFlags GetOrderFlags(VehicleID vehicle_id, OrderPosition order_position); /** + * Gets the OrderPosition to jump to if the check succeeds of the given order for the given vehicle. + * @param vehicle_id The vehicle to get the OrderPosition for. + * @param order_position The order to get the OrderPosition for. + * @pre IsValidVehicleOrder(vehicle_id, order_position). + * @pre order_position != ORDER_CURRENT && IsConditionalOrder(vehicle_id, order_position). + * @return The target of the conditional jump. + */ + static OrderPosition GetOrderJumpTo(VehicleID vehicle_id, OrderPosition order_position); + + /** + * Gets the OrderCondition of the given order for the given vehicle. + * @param vehicle_id The vehicle to get the condition type for. + * @param order_position The order to get the condition type for. + * @pre IsValidVehicleOrder(vehicle_id, order_position). + * @pre order_position != ORDER_CURRENT && IsConditionalOrder(vehicle_id, order_position). + * @return The OrderCondition of the order. + */ + static OrderCondition GetOrderCondition(VehicleID vehicle_id, OrderPosition order_position); + + /** + * Gets the CompareFunction of the given order for the given vehicle. + * @param vehicle_id The vehicle to get the compare function for. + * @param order_position The order to get the compare function for. + * @pre IsValidVehicleOrder(vehicle_id, order_position). + * @pre order_position != ORDER_CURRENT && IsConditionalOrder(vehicle_id, order_position). + * @return The CompareFunction of the order. + */ + static CompareFunction GetOrderCompareFunction(VehicleID vehicle_id, OrderPosition order_position); + + /** + * Gets the value to compare against of the given order for the given vehicle. + * @param vehicle_id The vehicle to get the value for. + * @param order_position The order to get the value for. + * @pre IsValidVehicleOrder(vehicle_id, order_position). + * @pre order_position != ORDER_CURRENT && IsConditionalOrder(vehicle_id, order_position). + * @return The value to compare against of the order. + */ + static int32 GetOrderCompareValue(VehicleID vehicle_id, OrderPosition order_position); + + /** + * Sets the OrderPosition to jump to if the check succeeds of the given order for the given vehicle. + * @param vehicle_id The vehicle to set the OrderPosition for. + * @param order_position The order to set the OrderPosition for. + * @param jump_to The order to jump to if the check succeeds. + * @pre IsValidVehicleOrder(vehicle_id, order_position). + * @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. + */ + static bool SetOrderJumpTo(VehicleID vehicle_id, OrderPosition order_position, OrderPosition jump_to); + + /** + * Sets the OrderCondition of the given order for the given vehicle. + * @param vehicle_id The vehicle to set the condition type for. + * @param order_position The order to set the condition type for. + * @pre IsValidVehicleOrder(vehicle_id, order_position). + * @pre order_position != ORDER_CURRENT && IsConditionalOrder(vehicle_id, order_position). + * @return Whether the order has been/can be changed. + */ + static bool SetOrderCondition(VehicleID vehicle_id, OrderPosition order_position, OrderCondition condition); + + /** + * Sets the CompareFunction of the given order for the given vehicle. + * @param vehicle_id The vehicle to set the compare function for. + * @param order_position The order to set the compare function for. + * @pre IsValidVehicleOrder(vehicle_id, order_position). + * @pre order_position != ORDER_CURRENT && IsConditionalOrder(vehicle_id, order_position). + * @return Whether the order has been/can be changed. + */ + static bool SetOrderCompareFunction(VehicleID vehicle_id, OrderPosition order_position, CompareFunction compare); + + /** + * Sets the value to compare against of the given order for the given vehicle. + * @param vehicle_id The vehicle to set the value for. + * @param order_position The order to set the value for. + * @pre IsValidVehicleOrder(vehicle_id, order_position). + * @pre order_position != ORDER_CURRENT && IsConditionalOrder(vehicle_id, order_position). + * @pre value >= 0 && value < 2048. + * @return Whether the order has been/can be changed. + */ + static bool SetOrderCompareValue(VehicleID vehicle_id, OrderPosition order_position, int32 value); + + /** * Appends an order to the end of the vehicle's order list. * @param vehicle_id The vehicle to append the order to. * @param destination The destination of the order. @@ -156,6 +288,18 @@ public: static bool AppendOrder(VehicleID vehicle_id, TileIndex destination, AIOrderFlags order_flags); /** + * Appends a conditional order to the end of the vehicle's order list. + * @param vehicle_id The vehicle to append the order to. + * @param jump_to The OrderPosition to jump to if the condition is true. + * @pre AIVehicle::IsValidVehicle(vehicle_id). + * @pre IsValidVehicleOrder(vehicle_id, jump_to). + * @exception AIError::ERR_OWNED_BY_ANOTHER_COMPANY + * @exception AIOrder::ERR_ORDER_NO_MORE_SPACE + * @return True if and only if the order was appended. + */ + static bool AppendConditionalOrder(VehicleID vehicle_id, OrderPosition jump_to); + + /** * Inserts an order before the given order_position into the vehicle's order list. * @param vehicle_id The vehicle to add the order to. * @param order_position The order to place the new order before. @@ -171,6 +315,19 @@ public: static bool InsertOrder(VehicleID vehicle_id, OrderPosition order_position, TileIndex destination, AIOrderFlags order_flags); /** + * Appends a conditional order before the given order_position into the vehicle's order list. + * @param vehicle_id The vehicle to add the order to. + * @param order_position The order to place the new order before. + * @param jump_to The OrderPosition to jump to if the condition is true. + * @pre IsValidVehicleOrder(vehicle_id, order_position). + * @pre IsValidVehicleOrder(vehicle_id, jump_to). + * @exception AIError::ERR_OWNED_BY_ANOTHER_COMPANY + * @exception AIOrder::ERR_ORDER_NO_MORE_SPACE + * @return True if and only if the order was inserted. + */ + static bool InsertConditionalOrder(VehicleID vehicle_id, OrderPosition order_position, OrderPosition jump_to); + + /** * Removes an order from the vehicle's order list. * @param vehicle_id The vehicle to remove the order from. * @param order_position The order to remove from the order list. diff --git a/src/ai/api/ai_order.hpp.sq b/src/ai/api/ai_order.hpp.sq index f5fba3975..5b71d2442 100644 --- a/src/ai/api/ai_order.hpp.sq +++ b/src/ai/api/ai_order.hpp.sq @@ -9,6 +9,10 @@ namespace SQConvert { template <> int Return<AIOrder::ErrorMessages>(HSQUIRRELVM vm, AIOrder::ErrorMessages res) { sq_pushinteger(vm, (int32)res); return 1; } template <> AIOrder::AIOrderFlags GetParam(ForceType<AIOrder::AIOrderFlags>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (AIOrder::AIOrderFlags)tmp; } template <> int Return<AIOrder::AIOrderFlags>(HSQUIRRELVM vm, AIOrder::AIOrderFlags res) { sq_pushinteger(vm, (int32)res); return 1; } + template <> AIOrder::OrderCondition GetParam(ForceType<AIOrder::OrderCondition>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (AIOrder::OrderCondition)tmp; } + template <> int Return<AIOrder::OrderCondition>(HSQUIRRELVM vm, AIOrder::OrderCondition res) { sq_pushinteger(vm, (int32)res); return 1; } + template <> AIOrder::CompareFunction GetParam(ForceType<AIOrder::CompareFunction>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (AIOrder::CompareFunction)tmp; } + template <> int Return<AIOrder::CompareFunction>(HSQUIRRELVM vm, AIOrder::CompareFunction res) { sq_pushinteger(vm, (int32)res); return 1; } template <> AIOrder::OrderPosition GetParam(ForceType<AIOrder::OrderPosition>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (AIOrder::OrderPosition)tmp; } template <> int Return<AIOrder::OrderPosition>(HSQUIRRELVM vm, AIOrder::OrderPosition res) { sq_pushinteger(vm, (int32)res); return 1; } @@ -42,6 +46,22 @@ void SQAIOrder_Register(Squirrel *engine) { SQAIOrder.DefSQConst(engine, AIOrder::AIOF_UNLOAD_FLAGS, "AIOF_UNLOAD_FLAGS"); SQAIOrder.DefSQConst(engine, AIOrder::AIOF_LOAD_FLAGS, "AIOF_LOAD_FLAGS"); SQAIOrder.DefSQConst(engine, AIOrder::AIOF_INVALID, "AIOF_INVALID"); + SQAIOrder.DefSQConst(engine, AIOrder::OC_LOAD_PERCENTAGE, "OC_LOAD_PERCENTAGE"); + SQAIOrder.DefSQConst(engine, AIOrder::OC_RELIABILITY, "OC_RELIABILITY"); + SQAIOrder.DefSQConst(engine, AIOrder::OC_MAX_SPEED, "OC_MAX_SPEED"); + SQAIOrder.DefSQConst(engine, AIOrder::OC_AGE, "OC_AGE"); + SQAIOrder.DefSQConst(engine, AIOrder::OC_REQUIRES_SERVICE, "OC_REQUIRES_SERVICE"); + SQAIOrder.DefSQConst(engine, AIOrder::OC_UNCONDITIONALLY, "OC_UNCONDITIONALLY"); + SQAIOrder.DefSQConst(engine, AIOrder::OC_INVALID, "OC_INVALID"); + SQAIOrder.DefSQConst(engine, AIOrder::CF_EQUALS, "CF_EQUALS"); + SQAIOrder.DefSQConst(engine, AIOrder::CF_NOT_EQUALS, "CF_NOT_EQUALS"); + SQAIOrder.DefSQConst(engine, AIOrder::CF_LESS_THAN, "CF_LESS_THAN"); + SQAIOrder.DefSQConst(engine, AIOrder::CF_LESS_EQUALS, "CF_LESS_EQUALS"); + SQAIOrder.DefSQConst(engine, AIOrder::CF_MORE_THAN, "CF_MORE_THAN"); + SQAIOrder.DefSQConst(engine, AIOrder::CF_MORE_EQUALS, "CF_MORE_EQUALS"); + SQAIOrder.DefSQConst(engine, AIOrder::CF_IS_TRUE, "CF_IS_TRUE"); + SQAIOrder.DefSQConst(engine, AIOrder::CF_IS_FALSE, "CF_IS_FALSE"); + SQAIOrder.DefSQConst(engine, AIOrder::CF_INVALID, "CF_INVALID"); SQAIOrder.DefSQConst(engine, AIOrder::ORDER_CURRENT, "ORDER_CURRENT"); SQAIOrder.DefSQConst(engine, AIOrder::ORDER_INVALID, "ORDER_INVALID"); @@ -51,20 +71,32 @@ void SQAIOrder_Register(Squirrel *engine) { AIError::RegisterErrorMapString(AIOrder::ERR_ORDER_TOO_MANY, "ERR_ORDER_TOO_MANY"); AIError::RegisterErrorMapString(AIOrder::ERR_ORDER_TOO_FAR_AWAY_FROM_PREVIOUS_DESTINATION, "ERR_ORDER_TOO_FAR_AWAY_FROM_PREVIOUS_DESTINATION"); - SQAIOrder.DefSQStaticMethod(engine, &AIOrder::IsValidVehicleOrder, "IsValidVehicleOrder", 3, "?ii"); - SQAIOrder.DefSQStaticMethod(engine, &AIOrder::ResolveOrderPosition, "ResolveOrderPosition", 3, "?ii"); - SQAIOrder.DefSQStaticMethod(engine, &AIOrder::AreOrderFlagsValid, "AreOrderFlagsValid", 3, "?ii"); - SQAIOrder.DefSQStaticMethod(engine, &AIOrder::GetOrderCount, "GetOrderCount", 2, "?i"); - SQAIOrder.DefSQStaticMethod(engine, &AIOrder::GetOrderDestination, "GetOrderDestination", 3, "?ii"); - SQAIOrder.DefSQStaticMethod(engine, &AIOrder::GetOrderFlags, "GetOrderFlags", 3, "?ii"); - SQAIOrder.DefSQStaticMethod(engine, &AIOrder::AppendOrder, "AppendOrder", 4, "?iii"); - SQAIOrder.DefSQStaticMethod(engine, &AIOrder::InsertOrder, "InsertOrder", 5, "?iiii"); - SQAIOrder.DefSQStaticMethod(engine, &AIOrder::RemoveOrder, "RemoveOrder", 3, "?ii"); - SQAIOrder.DefSQStaticMethod(engine, &AIOrder::ChangeOrder, "ChangeOrder", 4, "?iii"); - SQAIOrder.DefSQStaticMethod(engine, &AIOrder::MoveOrder, "MoveOrder", 4, "?iii"); - SQAIOrder.DefSQStaticMethod(engine, &AIOrder::CopyOrders, "CopyOrders", 3, "?ii"); - SQAIOrder.DefSQStaticMethod(engine, &AIOrder::ShareOrders, "ShareOrders", 3, "?ii"); - SQAIOrder.DefSQStaticMethod(engine, &AIOrder::UnshareOrders, "UnshareOrders", 2, "?i"); + SQAIOrder.DefSQStaticMethod(engine, &AIOrder::IsValidVehicleOrder, "IsValidVehicleOrder", 3, "?ii"); + SQAIOrder.DefSQStaticMethod(engine, &AIOrder::IsConditionalOrder, "IsConditionalOrder", 3, "?ii"); + SQAIOrder.DefSQStaticMethod(engine, &AIOrder::ResolveOrderPosition, "ResolveOrderPosition", 3, "?ii"); + SQAIOrder.DefSQStaticMethod(engine, &AIOrder::AreOrderFlagsValid, "AreOrderFlagsValid", 3, "?ii"); + SQAIOrder.DefSQStaticMethod(engine, &AIOrder::IsValidConditionalOrder, "IsValidConditionalOrder", 3, "?ii"); + SQAIOrder.DefSQStaticMethod(engine, &AIOrder::GetOrderCount, "GetOrderCount", 2, "?i"); + SQAIOrder.DefSQStaticMethod(engine, &AIOrder::GetOrderDestination, "GetOrderDestination", 3, "?ii"); + SQAIOrder.DefSQStaticMethod(engine, &AIOrder::GetOrderFlags, "GetOrderFlags", 3, "?ii"); + SQAIOrder.DefSQStaticMethod(engine, &AIOrder::GetOrderJumpTo, "GetOrderJumpTo", 3, "?ii"); + SQAIOrder.DefSQStaticMethod(engine, &AIOrder::GetOrderCondition, "GetOrderCondition", 3, "?ii"); + SQAIOrder.DefSQStaticMethod(engine, &AIOrder::GetOrderCompareFunction, "GetOrderCompareFunction", 3, "?ii"); + SQAIOrder.DefSQStaticMethod(engine, &AIOrder::GetOrderCompareValue, "GetOrderCompareValue", 3, "?ii"); + SQAIOrder.DefSQStaticMethod(engine, &AIOrder::SetOrderJumpTo, "SetOrderJumpTo", 4, "?iii"); + SQAIOrder.DefSQStaticMethod(engine, &AIOrder::SetOrderCondition, "SetOrderCondition", 4, "?iii"); + SQAIOrder.DefSQStaticMethod(engine, &AIOrder::SetOrderCompareFunction, "SetOrderCompareFunction", 4, "?iii"); + SQAIOrder.DefSQStaticMethod(engine, &AIOrder::SetOrderCompareValue, "SetOrderCompareValue", 4, "?iii"); + SQAIOrder.DefSQStaticMethod(engine, &AIOrder::AppendOrder, "AppendOrder", 4, "?iii"); + SQAIOrder.DefSQStaticMethod(engine, &AIOrder::AppendConditionalOrder, "AppendConditionalOrder", 3, "?ii"); + SQAIOrder.DefSQStaticMethod(engine, &AIOrder::InsertOrder, "InsertOrder", 5, "?iiii"); + SQAIOrder.DefSQStaticMethod(engine, &AIOrder::InsertConditionalOrder, "InsertConditionalOrder", 4, "?iii"); + SQAIOrder.DefSQStaticMethod(engine, &AIOrder::RemoveOrder, "RemoveOrder", 3, "?ii"); + SQAIOrder.DefSQStaticMethod(engine, &AIOrder::ChangeOrder, "ChangeOrder", 4, "?iii"); + SQAIOrder.DefSQStaticMethod(engine, &AIOrder::MoveOrder, "MoveOrder", 4, "?iii"); + SQAIOrder.DefSQStaticMethod(engine, &AIOrder::CopyOrders, "CopyOrders", 3, "?ii"); + SQAIOrder.DefSQStaticMethod(engine, &AIOrder::ShareOrders, "ShareOrders", 3, "?ii"); + SQAIOrder.DefSQStaticMethod(engine, &AIOrder::UnshareOrders, "UnshareOrders", 2, "?i"); SQAIOrder.PostRegister(engine); } |