From 6f730b11246ab085d3b6092175f6785702a756d7 Mon Sep 17 00:00:00 2001 From: yexo Date: Sun, 6 Feb 2011 12:15:17 +0000 Subject: (svn r21992) -Fix [FS#4467]: AIs trying to change the AIOF_GOTO_NEAREST_DEPOT flag for existing orders triggered an assert. Explicitly forbid this as precondition for SetOrderFlags --- src/ai/api/ai_order.cpp | 2 ++ src/ai/api/ai_order.hpp | 1 + 2 files changed, 3 insertions(+) (limited to 'src') diff --git a/src/ai/api/ai_order.cpp b/src/ai/api/ai_order.cpp index 3bde539be..752291751 100644 --- a/src/ai/api/ai_order.cpp +++ b/src/ai/api/ai_order.cpp @@ -509,6 +509,8 @@ static void _DoCommandReturnSetOrderFlags(class AIInstance *instance) AIOrderFlags current = GetOrderFlags(vehicle_id, order_position); + EnforcePrecondition(false, (order_flags & AIOF_GOTO_NEAREST_DEPOT) == (current & AIOF_GOTO_NEAREST_DEPOT)); + if ((current & AIOF_NON_STOP_FLAGS) != (order_flags & AIOF_NON_STOP_FLAGS)) { return AIObject::DoCommand(0, vehicle_id | (order_position << 20), (order_flags & AIOF_NON_STOP_FLAGS) << 4 | MOF_NON_STOP, CMD_MODIFY_ORDER, NULL, &_DoCommandReturnSetOrderFlags); } diff --git a/src/ai/api/ai_order.hpp b/src/ai/api/ai_order.hpp index bfd10a0a9..14f07e6de 100644 --- a/src/ai/api/ai_order.hpp +++ b/src/ai/api/ai_order.hpp @@ -457,6 +457,7 @@ public: * @param order_flags The new flags given to the order. * @pre IsValidVehicleOrder(vehicle_id, order_position). * @pre AreOrderFlagsValid(GetOrderDestination(vehicle_id, order_position), order_flags). + * @pre (order_flags & AIOF_GOTO_NEAREST_DEPOT) == (GetOrderFlags(vehicle_id, order_position) & AIOF_GOTO_NEAREST_DEPOT). * @exception AIError::ERR_OWNED_BY_ANOTHER_COMPANY * @return True if and only if the order was changed. */ -- cgit v1.2.3-70-g09d2