summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2012-04-01 19:56:08 +0000
committerfrosch <frosch@openttd.org>2012-04-01 19:56:08 +0000
commit70ad67012588ac8ceb20e0fc7d49fd07ad51dd0b (patch)
tree675fedd0e885dda87f9807b3e02bd215e0d2ba5d /src
parente51018cbf3373ce8cfee80582e44649ee9d801a9 (diff)
downloadopenttd-70ad67012588ac8ceb20e0fc7d49fd07ad51dd0b.tar.xz
(svn r24086) -Fix [FS#5131] (r23504): Cloning orders of aircraft with limited range failed.
Diffstat (limited to 'src')
-rw-r--r--src/order_cmd.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp
index 6846c7af5..61ba4e121 100644
--- a/src/order_cmd.cpp
+++ b/src/order_cmd.cpp
@@ -1402,13 +1402,14 @@ CommandCost CmdModifyOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
/**
* Check if an aircraft has enough range for an order list.
- * @param v Aircraft to check.
+ * @param v_new Aircraft to check.
+ * @param v_order Vehicle currently holding the order list.
* @param first First order in the source order list.
* @return True if the aircraft has enough range for the orders, false otherwise.
*/
-bool CheckAircraftOrderDistance(const Aircraft *v, const Order *first)
+static bool CheckAircraftOrderDistance(const Aircraft *v_new, const Vehicle *v_order, const Order *first)
{
- if (first == NULL || v->acache.cached_max_range == 0) return true;
+ if (first == NULL || v_new->acache.cached_max_range == 0) return true;
/* Iterate over all orders to check the distance between all
* 'goto' orders and their respective next order (of any type). */
@@ -1418,7 +1419,7 @@ bool CheckAircraftOrderDistance(const Aircraft *v, const Order *first)
case OT_GOTO_DEPOT:
case OT_GOTO_WAYPOINT:
/* If we don't have a next order, we've reached the end and must check the first order instead. */
- if (GetOrderDistance(o, o->next != NULL ? o->next : first, v) > v->acache.cached_max_range_sqr) return false;
+ if (GetOrderDistance(o, o->next != NULL ? o->next : first, v_order) > v_new->acache.cached_max_range_sqr) return false;
break;
default: break;
@@ -1478,7 +1479,7 @@ CommandCost CmdCloneOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
}
/* Check for aircraft range limits. */
- if (dst->type == VEH_AIRCRAFT && !CheckAircraftOrderDistance(Aircraft::From(dst), src->GetFirstOrder())) {
+ if (dst->type == VEH_AIRCRAFT && !CheckAircraftOrderDistance(Aircraft::From(dst), src, src->GetFirstOrder())) {
return_cmd_error(STR_ERROR_AIRCRAFT_NOT_ENOUGH_RANGE);
}
@@ -1525,7 +1526,7 @@ CommandCost CmdCloneOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
}
/* Check for aircraft range limits. */
- if (dst->type == VEH_AIRCRAFT && !CheckAircraftOrderDistance(Aircraft::From(dst), src->GetFirstOrder())) {
+ if (dst->type == VEH_AIRCRAFT && !CheckAircraftOrderDistance(Aircraft::From(dst), src, src->GetFirstOrder())) {
return_cmd_error(STR_ERROR_AIRCRAFT_NOT_ENOUGH_RANGE);
}