summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2010-01-27 12:45:41 +0000
committeryexo <yexo@openttd.org>2010-01-27 12:45:41 +0000
commit849e676410472daf17a1996a57bccacab91594dc (patch)
treeb025ec592f533cf7342c63c4b2dcc44ad8df8e5b /src
parentcd6eac77c37e07c1e51856ae94a69b4aa8cd8af9 (diff)
downloadopenttd-849e676410472daf17a1996a57bccacab91594dc.tar.xz
(svn r18924) -Fix [NoAI]: AIOrder::GetOrderDestination could return a non-waypoint tile when the waypoint was a multitile waypoint
Diffstat (limited to 'src')
-rw-r--r--src/ai/api/ai_order.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/ai/api/ai_order.cpp b/src/ai/api/ai_order.cpp
index b6280be1f..0c0a3b0e5 100644
--- a/src/ai/api/ai_order.cpp
+++ b/src/ai/api/ai_order.cpp
@@ -188,8 +188,7 @@ static const Order *ResolveOrder(VehicleID vehicle_id, AIOrder::OrderPosition or
case OT_GOTO_STATION: {
const Station *st = ::Station::Get(order->GetDestination());
if (st->train_station.tile != INVALID_TILE) {
- for (uint i = 0; i < st->train_station.w; i++) {
- TileIndex t = st->train_station.tile + TileDiffXY(i, 0);
+ TILE_AREA_LOOP(t, st->train_station) {
if (st->TileBelongsToRailStation(t)) return t;
}
} else if (st->dock_tile != INVALID_TILE) {
@@ -206,7 +205,16 @@ static const Order *ResolveOrder(VehicleID vehicle_id, AIOrder::OrderPosition or
}
return INVALID_TILE;
}
- case OT_GOTO_WAYPOINT: return ::Waypoint::Get(order->GetDestination())->xy;
+
+ case OT_GOTO_WAYPOINT: {
+ const Waypoint *wp = ::Waypoint::Get(order->GetDestination());
+ if (wp->train_station.tile != INVALID_TILE) {
+ TILE_AREA_LOOP(t, wp->train_station) {
+ if (wp->TileBelongsToRailStation(t)) return t;
+ }
+ }
+ return INVALID_TILE;
+ }
default: return INVALID_TILE;
}
}