Loading

Paste #pawcshgoi

  1. Index: src/aircraft_cmd.cpp
  2. ===================================================================
  3. --- src/aircraft_cmd.cpp    (revision 27930)
  4. +++ src/aircraft_cmd.cpp    (working copy)
  5. @@ -2085,7 +2085,19 @@
  6.     FOR_ALL_AIRCRAFT(v) {
  7.         if (!v->IsNormalAircraft() || v->targetairport != st->index) continue;
  8.         assert(v->state == FLYING);
  9. +
  10. +       Order *o = &v->current_order;
  11. +       /* The aircraft is heading to a hangar, but the new station doesn't have one,
  12. +        * or the aircraft can't land on the new station. Cancel current order. */
  13. +       if (o->IsType(OT_GOTO_DEPOT) && !(o->GetDepotOrderType() & ODTFB_PART_OF_ORDERS) && o->GetDestination() == st->index &&
  14. +               (!st->airport.HasHangar() || !CanVehicleUseStation(v, st))) {
  15. +           o->MakeDummy();
  16. +           SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, WID_VV_START_STOP);
  17. +       }
  18.         v->pos = v->previous_pos = AircraftGetEntryPoint(v, ap, rotation);
  19.         UpdateAircraftCache(v);
  20.     }
  21. +
  22. +   /* Heliports don't have a hangar. Invalidate all go to hangar orders from all aircraft. */
  23. +   if (!st->airport.HasHangar()) RemoveOrderFromAllVehicles(OT_GOTO_DEPOT, st->index, true);
  24.  }
  25. Index: src/order_backup.cpp
  26. ===================================================================
  27. --- src/order_backup.cpp    (revision 27930)
  28. +++ src/order_backup.cpp    (working copy)
  29. @@ -256,8 +256,11 @@
  30.   * Removes an order from all vehicles. Triggers when, say, a station is removed.
  31.   * @param type The type of the order (OT_GOTO_[STATION|DEPOT|WAYPOINT]).
  32.   * @param destination The destination. Can be a StationID, DepotID or WaypointID.
  33. + * @param hangar Only used for airports in the destination.
  34. + *               When false, remove airport and hangar orders.
  35. + *               When true, remove either airport or hangar order.
  36.   */
  37. -/* static */ void OrderBackup::RemoveOrder(OrderType type, DestinationID destination)
  38. +/* static */ void OrderBackup::RemoveOrder(OrderType type, DestinationID destination, bool hangar)
  39.  {
  40.     OrderBackup *ob;
  41.     FOR_ALL_ORDER_BACKUPS(ob) {
  42. @@ -264,7 +267,7 @@
  43.         for (Order *order = ob->orders; order != NULL; order = order->next) {
  44.             OrderType ot = order->GetType();
  45.             if (ot == OT_GOTO_DEPOT && (order->GetDepotActionType() & ODATFB_NEAREST_DEPOT) != 0) continue;
  46. -           if (ot == OT_IMPLICIT || (IsHangarTile(ob->tile) && ot == OT_GOTO_DEPOT)) ot = OT_GOTO_STATION;
  47. +           if (ot == OT_IMPLICIT || (IsHangarTile(ob->tile) && ot == OT_GOTO_DEPOT && !hangar)) ot = OT_GOTO_STATION;
  48.             if (ot == type && order->GetDestination() == destination) {
  49.                 /* Remove the order backup! If a station/depot gets removed, we can't/shouldn't restore those broken orders. */
  50.                 delete ob;
  51. Index: src/order_backup.h
  52. ===================================================================
  53. --- src/order_backup.h  (revision 27930)
  54. +++ src/order_backup.h  (working copy)
  55. @@ -63,7 +63,7 @@
  56.  
  57.     static void ClearGroup(GroupID group);
  58.     static void ClearVehicle(const Vehicle *v);
  59. -   static void RemoveOrder(OrderType type, DestinationID destination);
  60. +   static void RemoveOrder(OrderType type, DestinationID destination, bool hangar);
  61.  };
  62.  
  63.  /**
  64. Index: src/order_cmd.cpp
  65. ===================================================================
  66. --- src/order_cmd.cpp   (revision 27930)
  67. +++ src/order_cmd.cpp   (working copy)
  68. @@ -1833,8 +1833,11 @@
  69.   * Removes an order from all vehicles. Triggers when, say, a station is removed.
  70.   * @param type The type of the order (OT_GOTO_[STATION|DEPOT|WAYPOINT]).
  71.   * @param destination The destination. Can be a StationID, DepotID or WaypointID.
  72. + * @param hangar Only used for airports in the destination.
  73. + *               When false, remove airport and hangar orders.
  74. + *               When true, remove either airport or hangar order.
  75.   */
  76. -void RemoveOrderFromAllVehicles(OrderType type, DestinationID destination)
  77. +void RemoveOrderFromAllVehicles(OrderType type, DestinationID destination, bool hangar)
  78.  {
  79.     Vehicle *v;
  80.  
  81. @@ -1847,7 +1850,7 @@
  82.         Order *order;
  83.  
  84.         order = &v->current_order;
  85. -       if ((v->type == VEH_AIRCRAFT && order->IsType(OT_GOTO_DEPOT) ? OT_GOTO_STATION : order->GetType()) == type &&
  86. +       if ((v->type == VEH_AIRCRAFT && order->IsType(OT_GOTO_DEPOT) && !hangar ? OT_GOTO_STATION : order->GetType()) == type &&
  87.                 v->current_order.GetDestination() == destination) {
  88.             order->MakeDummy();
  89.             SetWindowDirty(WC_VEHICLE_VIEW, v->index);
  90. @@ -1861,7 +1864,7 @@
  91.  
  92.             OrderType ot = order->GetType();
  93.             if (ot == OT_GOTO_DEPOT && (order->GetDepotActionType() & ODATFB_NEAREST_DEPOT) != 0) continue;
  94. -           if (ot == OT_IMPLICIT || (v->type == VEH_AIRCRAFT && ot == OT_GOTO_DEPOT)) ot = OT_GOTO_STATION;
  95. +           if (ot == OT_IMPLICIT || (v->type == VEH_AIRCRAFT && ot == OT_GOTO_DEPOT && !hangar)) ot = OT_GOTO_STATION;
  96.             if (ot == type && order->GetDestination() == destination) {
  97.                 /* We want to clear implicit orders, but we don't want to make them
  98.                  * dummy orders. They should just vanish. Also check the actual order
  99. @@ -1895,7 +1898,7 @@
  100.         }
  101.     }
  102.  
  103. -   OrderBackup::RemoveOrder(type, destination);
  104. +   OrderBackup::RemoveOrder(type, destination, hangar);
  105.  }
  106.  
  107.  /**
  108. Index: src/order_func.h
  109. ===================================================================
  110. --- src/order_func.h    (revision 27930)
  111. +++ src/order_func.h    (working copy)
  112. @@ -17,7 +17,7 @@
  113.  #include "company_type.h"
  114.  
  115.  /* Functions */
  116. -void RemoveOrderFromAllVehicles(OrderType type, DestinationID destination);
  117. +void RemoveOrderFromAllVehicles(OrderType type, DestinationID destination, bool hangar = false);
  118.  void InvalidateVehicleOrder(const Vehicle *v, int data);
  119.  void CheckOrders(const Vehicle*);
  120.  void DeleteVehicleOrders(Vehicle *v, bool keep_orderlist = false, bool reset_order_indices = true);

Comments