diff options
author | frosch <frosch@openttd.org> | 2010-02-22 20:08:16 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2010-02-22 20:08:16 +0000 |
commit | 945d2c08e0d642327ec2a4137938ff5aaf94ac44 (patch) | |
tree | 8cbc4c1fde8200f14f499e570fef54d2302b86ca /src | |
parent | a90f160511ac475c0a132aca2f1741ed86217761 (diff) | |
download | openttd-945d2c08e0d642327ec2a4137938ff5aaf94ac44.tar.xz |
(svn r19210) -Fix: GetDestination() is invalid for nearest-depot orders.
Diffstat (limited to 'src')
-rw-r--r-- | src/order_cmd.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp index c347a9512..c87493fc4 100644 --- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -415,7 +415,9 @@ static TileIndex GetOrderLocation(const Order& o) default: NOT_REACHED(); case OT_GOTO_WAYPOINT: return Waypoint::Get(o.GetDestination())->xy; case OT_GOTO_STATION: return Station::Get(o.GetDestination())->xy; - case OT_GOTO_DEPOT: return Depot::Get(o.GetDestination())->xy; + case OT_GOTO_DEPOT: + if ((o.GetDepotActionType() & ODATFB_NEAREST_DEPOT) != 0) return INVALID_TILE; + return Depot::Get(o.GetDestination())->xy; } } @@ -433,7 +435,10 @@ static uint GetOrderDistance(const Order *prev, const Order *cur, const Vehicle return max(dist1, dist2); } - return DistanceManhattan(GetOrderLocation(*prev), GetOrderLocation(*cur)); + TileIndex prev_tile = GetOrderLocation(*prev); + TileIndex cur_tile = GetOrderLocation(*cur); + if (prev_tile == INVALID_TILE || cur_tile == INVALID_TILE) return 0; + return DistanceManhattan(prev_tile, cur_tile); } /** Add an order to the orderlist of a vehicle. |