summaryrefslogtreecommitdiff
path: root/src/aircraft_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/aircraft_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/aircraft_cmd.cpp')
-rw-r--r--src/aircraft_cmd.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp
index d6d99ae24..7c3566372 100644
--- a/src/aircraft_cmd.cpp
+++ b/src/aircraft_cmd.cpp
@@ -2103,7 +2103,19 @@ void UpdateAirplanesOnNewStation(const Station *st)
FOR_ALL_AIRCRAFT(v) {
if (!v->IsNormalAircraft() || v->targetairport != st->index) continue;
assert(v->state == FLYING);
+
+ Order *o = &v->current_order;
+ /* The aircraft is heading to a hangar, but the new station doesn't have one,
+ * or the aircraft can't land on the new station. Cancel current order. */
+ if (o->IsType(OT_GOTO_DEPOT) && !(o->GetDepotOrderType() & ODTFB_PART_OF_ORDERS) && o->GetDestination() == st->index &&
+ (!st->airport.HasHangar() || !CanVehicleUseStation(v, st))) {
+ o->MakeDummy();
+ SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, WID_VV_START_STOP);
+ }
v->pos = v->previous_pos = AircraftGetEntryPoint(v, ap, rotation);
UpdateAircraftCache(v);
}
+
+ /* Heliports don't have a hangar. Invalidate all go to hangar orders from all aircraft. */
+ if (!st->airport.HasHangar()) RemoveOrderFromAllVehicles(OT_GOTO_DEPOT, st->index, true);
}