(svn r14317) -Fix (r13662) [FS#2298]: Order distance processing for conditional orders on ships treated v->orders as an array, and didn't use the correct next order.
authorpeter1138
Sun, 14 Sep 2008 08:47:18 +0000
changeset 10131 1dee92853a5d
parent 10130 f3889bf9d638
child 10132 ba6ac391e138
(svn r14317) -Fix (r13662) [FS#2298]: Order distance processing for conditional orders on ships treated v->orders as an array, and didn't use the correct next order.
src/order_cmd.cpp
--- a/src/order_cmd.cpp	Sat Sep 13 17:37:18 2008 +0000
+++ b/src/order_cmd.cpp	Sun Sep 14 08:47:18 2008 +0000
@@ -304,8 +304,10 @@
 		if (conditional_depth > v->num_orders) return 0;
 
 		conditional_depth++;
-		return max(GetOrderDistance(prev, &v->orders[cur->GetConditionSkipToOrder()], v, conditional_depth),
-				GetOrderDistance(prev, (prev + 1 == &v->orders[v->num_orders]) ? v->orders : (prev + 1), v, conditional_depth));
+
+		int dist1 = GetOrderDistance(prev, GetVehicleOrder(v, cur->GetConditionSkipToOrder()), v, conditional_depth);
+		int dist2 = GetOrderDistance(prev, cur->next == NULL ? v->orders : cur->next, v, conditional_depth);
+		return max(dist1, dist2);
 	}
 
 	return DistanceManhattan(GetOrderLocation(*prev), GetOrderLocation(*cur));