summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/aircraft_cmd.cpp12
-rw-r--r--src/order_backup.cpp7
-rw-r--r--src/order_backup.h2
-rw-r--r--src/order_cmd.cpp11
-rw-r--r--src/order_func.h2
5 files changed, 26 insertions, 8 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);
}
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;
diff --git a/src/order_backup.h b/src/order_backup.h
index 59404d5be..c56bc0ecc 100644
--- a/src/order_backup.h
+++ b/src/order_backup.h
@@ -63,7 +63,7 @@ public:
static void ClearGroup(GroupID group);
static void ClearVehicle(const Vehicle *v);
- static void RemoveOrder(OrderType type, DestinationID destination);
+ static void RemoveOrder(OrderType type, DestinationID destination, bool hangar);
};
/**
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);
}
/**
diff --git a/src/order_func.h b/src/order_func.h
index 54977181a..df9939428 100644
--- a/src/order_func.h
+++ b/src/order_func.h
@@ -17,7 +17,7 @@
#include "company_type.h"
/* Functions */
-void RemoveOrderFromAllVehicles(OrderType type, DestinationID destination);
+void RemoveOrderFromAllVehicles(OrderType type, DestinationID destination, bool hangar = false);
void InvalidateVehicleOrder(const Vehicle *v, int data);
void CheckOrders(const Vehicle*);
void DeleteVehicleOrders(Vehicle *v, bool keep_orderlist = false, bool reset_order_indices = true);