summaryrefslogtreecommitdiff
path: root/src/order_cmd.cpp
diff options
context:
space:
mode:
authorSamu <dj_samu@hotmail.com>2018-10-01 16:01:28 +0100
committerMichael Lutz <michi@icosahedron.de>2019-02-27 00:06:57 +0100
commit9b99b95955d72e49821fe235c0d6fc1e75dc64b2 (patch)
tree2077846a68f10fd6f24175ae1b43ca3174e0da3f /src/order_cmd.cpp
parent7ac17f5ae4576a11d1f16281b656ffcd463ab5ac (diff)
downloadopenttd-9b99b95955d72e49821fe235c0d6fc1e75dc64b2.tar.xz
Fix #6574: Remove go to hangar orders when rebuilding airport
When replacing an airport with another, cancel current orders of type 'go to depot' from aircraft still heading to it if the rebuilt airport doesn't have a hangar (helicopter vs heliport), or if the airplane can't land on the rebuilt airport (airplane vs helistation). Removes 'go to hangar' orders from all aircraft when replacing an airport with hangar with another without hangar (heliport).
Diffstat (limited to 'src/order_cmd.cpp')
-rw-r--r--src/order_cmd.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp
index 83dacdca4..c2805bef3 100644
--- a/src/order_cmd.cpp
+++ b/src/order_cmd.cpp
@@ -1834,8 +1834,11 @@ void CheckOrders(const Vehicle *v)
* Removes an order from all vehicles. Triggers when, say, a station is removed.
* @param type The type of the order (OT_GOTO_[STATION|DEPOT|WAYPOINT]).
* @param destination The destination. Can be a StationID, DepotID or WaypointID.
+ * @param hangar Only used for airports in the destination.
+ * When false, remove airport and hangar orders.
+ * When true, remove either airport or hangar order.
*/
-void RemoveOrderFromAllVehicles(OrderType type, DestinationID destination)
+void RemoveOrderFromAllVehicles(OrderType type, DestinationID destination, bool hangar)
{
Vehicle *v;
@@ -1848,7 +1851,7 @@ void RemoveOrderFromAllVehicles(OrderType type, DestinationID destination)
Order *order;
order = &v->current_order;
- if ((v->type == VEH_AIRCRAFT && order->IsType(OT_GOTO_DEPOT) ? OT_GOTO_STATION : order->GetType()) == type &&
+ if ((v->type == VEH_AIRCRAFT && order->IsType(OT_GOTO_DEPOT) && !hangar ? OT_GOTO_STATION : order->GetType()) == type &&
v->current_order.GetDestination() == destination) {
order->MakeDummy();
SetWindowDirty(WC_VEHICLE_VIEW, v->index);
@@ -1862,7 +1865,7 @@ restart:
OrderType ot = order->GetType();
if (ot == OT_GOTO_DEPOT && (order->GetDepotActionType() & ODATFB_NEAREST_DEPOT) != 0) continue;
- if (ot == OT_IMPLICIT || (v->type == VEH_AIRCRAFT && ot == OT_GOTO_DEPOT)) ot = OT_GOTO_STATION;
+ if (ot == OT_IMPLICIT || (v->type == VEH_AIRCRAFT && ot == OT_GOTO_DEPOT && !hangar)) ot = OT_GOTO_STATION;
if (ot == type && order->GetDestination() == destination) {
/* We want to clear implicit orders, but we don't want to make them
* dummy orders. They should just vanish. Also check the actual order
@@ -1896,7 +1899,7 @@ restart:
}
}
- OrderBackup::RemoveOrder(type, destination);
+ OrderBackup::RemoveOrder(type, destination, hangar);
}
/**