Skip to content

Commit

Permalink
Fix OpenTTD#7391, 9b99b95: Don't invalidate go to depot orders of non…
Browse files Browse the repository at this point in the history
…-aircraft when invalidating hangar orders that happen to share IDs.

This was caused because hangars are referred to by station ID, which is not unique with respect to depot IDs.
  • Loading branch information
michicc committed Mar 20, 2019
1 parent e3c639a commit fca3c14
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/order_backup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ CommandCost CmdClearOrderBackup(TileIndex tile, DoCommandFlag flags, uint32 p1,
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_GOTO_DEPOT && hangar && !IsHangarTile(ob->tile)) continue; // Not an aircraft? Can't have a hangar order.
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. */
Expand Down
3 changes: 2 additions & 1 deletion src/order_cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1851,7 +1851,7 @@ void RemoveOrderFromAllVehicles(OrderType type, DestinationID destination, bool

order = &v->current_order;
if ((v->type == VEH_AIRCRAFT && order->IsType(OT_GOTO_DEPOT) && !hangar ? OT_GOTO_STATION : order->GetType()) == type &&
v->current_order.GetDestination() == destination) {
(!hangar || v->type == VEH_AIRCRAFT) && v->current_order.GetDestination() == destination) {
order->MakeDummy();
SetWindowDirty(WC_VEHICLE_VIEW, v->index);
}
Expand All @@ -1864,6 +1864,7 @@ void RemoveOrderFromAllVehicles(OrderType type, DestinationID destination, bool

OrderType ot = order->GetType();
if (ot == OT_GOTO_DEPOT && (order->GetDepotActionType() & ODATFB_NEAREST_DEPOT) != 0) continue;
if (ot == OT_GOTO_DEPOT && hangar && v->type != VEH_AIRCRAFT) continue; // Not an aircraft? Can't have a hangar order.
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
Expand Down

0 comments on commit fca3c14

Please sign in to comment.