summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2009-04-21 12:51:36 +0000
committeryexo <yexo@openttd.org>2009-04-21 12:51:36 +0000
commit63db874050c4a6c03bb15e773946c465d5027bf2 (patch)
tree3f35e292c91b4d551db2499c5b952b62651b1106
parent61d883e7e5bf2cd7d946725017fe4163d640fbb6 (diff)
downloadopenttd-63db874050c4a6c03bb15e773946c465d5027bf2.tar.xz
(svn r16108) -Fix [NoAI]: When giving an aircraft a goto-hangar order don't let it be a normal goto-station order.
Note to AI writers: AIOrder.AppendOrder(vehicle_id, AIStation.GetLocation(station_id)) will give a goto-hangar order for helistations (assuming the station sign is at it's default location).
-rw-r--r--src/ai/api/ai_order.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/ai/api/ai_order.cpp b/src/ai/api/ai_order.cpp
index 6e5bd28cd..eb48dae39 100644
--- a/src/ai/api/ai_order.cpp
+++ b/src/ai/api/ai_order.cpp
@@ -23,7 +23,10 @@ static OrderType GetOrderTypeByTile(TileIndex t)
switch (::GetTileType(t)) {
default: break;
- case MP_STATION: return OT_GOTO_STATION; break;
+ case MP_STATION:
+ if (IsHangar(t)) return OT_GOTO_DEPOT;
+ return OT_GOTO_STATION;
+ break;
case MP_WATER: if (::IsShipDepot(t)) return OT_GOTO_DEPOT; break;
case MP_ROAD: if (::GetRoadTileType(t) == ROAD_TILE_DEPOT) return OT_GOTO_DEPOT; break;
case MP_RAILWAY:
@@ -267,7 +270,15 @@ static OrderType GetOrderTypeByTile(TileIndex t)
case OT_GOTO_DEPOT: {
OrderDepotTypeFlags odtf = (OrderDepotTypeFlags)(ODTFB_PART_OF_ORDERS | ((order_flags & AIOF_SERVICE_IF_NEEDED) ? ODTFB_SERVICE : 0));
OrderDepotActionFlags odaf = (OrderDepotActionFlags)(ODATF_SERVICE_ONLY | ((order_flags & AIOF_STOP_IN_DEPOT) ? ODATFB_HALT : 0));
- order.MakeGoToDepot(::GetDepotByTile(destination)->index, odtf, odaf);
+ /* Check explicitly if the order is to a station (for aircraft) or
+ * to a depot (other vehicle types). */
+ if (::GetVehicle(vehicle_id)->type == VEH_AIRCRAFT) {
+ if (!::IsTileType(destination, MP_STATION)) return false;
+ order.MakeGoToDepot(::GetStationIndex(destination), odtf, odaf);
+ } else {
+ if (::IsTileType(destination, MP_STATION)) return false;
+ order.MakeGoToDepot(::GetDepotByTile(destination)->index, odtf, odaf);
+ }
break;
}