summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2008-09-14 08:47:18 +0000
committerpeter1138 <peter1138@openttd.org>2008-09-14 08:47:18 +0000
commitfb77ced24a37a5754c9738a7fa74c3d028228849 (patch)
tree0b7c150df3d0680abc1dc1d19284d26bfefde937 /src
parent7dc595ca72f66e0609b3e2a2dabd7cc55569b1e1 (diff)
downloadopenttd-fb77ced24a37a5754c9738a7fa74c3d028228849.tar.xz
(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.
Diffstat (limited to 'src')
-rw-r--r--src/order_cmd.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp
index eefebf3ba..0c7849dc1 100644
--- a/src/order_cmd.cpp
+++ b/src/order_cmd.cpp
@@ -304,8 +304,10 @@ static uint GetOrderDistance(const Order *prev, const Order *cur, const Vehicle
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));