diff options
author | Samu <dj_samu@hotmail.com> | 2018-10-01 16:01:28 +0100 |
---|---|---|
committer | Michael Lutz <michi@icosahedron.de> | 2019-02-27 00:06:57 +0100 |
commit | 9b99b95955d72e49821fe235c0d6fc1e75dc64b2 (patch) | |
tree | 2077846a68f10fd6f24175ae1b43ca3174e0da3f /src/order_backup.cpp | |
parent | 7ac17f5ae4576a11d1f16281b656ffcd463ab5ac (diff) | |
download | openttd-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_backup.cpp')
-rw-r--r-- | src/order_backup.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/order_backup.cpp b/src/order_backup.cpp index 597ad13bb..181e3e59d 100644 --- a/src/order_backup.cpp +++ b/src/order_backup.cpp @@ -256,15 +256,18 @@ CommandCost CmdClearOrderBackup(TileIndex tile, DoCommandFlag flags, uint32 p1, * 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. */ -/* static */ void OrderBackup::RemoveOrder(OrderType type, DestinationID destination) +/* static */ void OrderBackup::RemoveOrder(OrderType type, DestinationID destination, bool hangar) { OrderBackup *ob; FOR_ALL_ORDER_BACKUPS(ob) { for (Order *order = ob->orders; order != NULL; order = order->next) { OrderType ot = order->GetType(); if (ot == OT_GOTO_DEPOT && (order->GetDepotActionType() & ODATFB_NEAREST_DEPOT) != 0) continue; - if (ot == OT_IMPLICIT || (IsHangarTile(ob->tile) && ot == OT_GOTO_DEPOT)) ot = OT_GOTO_STATION; + if (ot == OT_IMPLICIT || (IsHangarTile(ob->tile) && ot == OT_GOTO_DEPOT && !hangar)) ot = OT_GOTO_STATION; if (ot == type && order->GetDestination() == destination) { /* Remove the order backup! If a station/depot gets removed, we can't/shouldn't restore those broken orders. */ delete ob; |