Loading

Paste #psvcvcr2d

  1. diff -r bb9639bf29af src/aircraft_cmd.cpp
  2. --- a/src/aircraft_cmd.cpp  Thu Jan 25 23:18:41 2018 +0000
  3. +++ b/src/aircraft_cmd.cpp  Thu Jan 25 23:39:33 2018 +0000
  4. @@ -1513,6 +1513,14 @@
  5.     /* airport-road is free. We either have to go to another airport, or to the hangar
  6.      * ---> start moving */
  7.  
  8. +   if (Station::Get(v->targetairport)->airport.HasHangar()) {
  9. +       if (v->NeedsAutomaticServicing() || v->subtype == AIR_HELICOPTER && v->HasPendingReplace() && _settings_game.order.serviceathelipad &&
  10. +               (!v->HasDepotOrder() || !(v->current_order.IsType(OT_GOTO_DEPOT) && v->current_order.GetDepotOrderType() != ODTFB_SERVICE))) {
  11. +           v->current_order.MakeGoToDepot(v->targetairport, ODTFB_SERVICE);
  12. +           SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, WID_VV_START_STOP);
  13. +       }
  14. +   }
  15. +
  16.     bool go_to_hangar = false;
  17.     switch (v->current_order.GetType()) {
  18.         case OT_GOTO_STATION: // ready to fly to another airport
  19. @@ -1571,11 +1579,17 @@
  20.     /* get the next position to go to, differs per airport */
  21.     AircraftNextAirportPos_and_Order(v);
  22.  
  23. -   /* Send the helicopter to a hangar if needed for replacement */
  24. -   if (v->NeedsAutomaticServicing()) {
  25. -       Backup<CompanyByte> cur_company(_current_company, v->owner, FILE_LINE);
  26. -       DoCommand(v->tile, v->index | DEPOT_SERVICE | DEPOT_LOCATE_HANGAR, 0, DC_EXEC, CMD_SEND_VEHICLE_TO_DEPOT);
  27. -       cur_company.Restore();
  28. +   /* Send the helicopter to a hangar if needed for replacement when NeedsAutomaticServicing fails */
  29. +   if (!v->NeedsAutomaticServicing() && v->HasPendingReplace() && _settings_game.order.serviceathelipad) {
  30. +       Order *o = &v->current_order;
  31. +       if (!v->HasDepotOrder() || !(o->IsType(OT_GOTO_DEPOT) && o->GetDepotOrderType() != ODTFB_SERVICE)) {
  32. +           DestinationID destination;
  33. +           if (v->FindClosestDepot(NULL, &destination, NULL)) {
  34. +               o->MakeGoToDepot(destination, ODTFB_SERVICE);
  35. +               AircraftNextAirportPos_and_Order(v);
  36. +               SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, WID_VV_START_STOP);
  37. +           }
  38. +       }
  39.     }
  40.  }
  41.  
  42. @@ -1620,13 +1634,6 @@
  43.  {
  44.     v->state = ENDLANDING;
  45.     AircraftLandAirplane(v);  // maybe crash airplane
  46. -
  47. -   /* check if the aircraft needs to be replaced or renewed and send it to a hangar if needed */
  48. -   if (v->NeedsAutomaticServicing()) {
  49. -       Backup<CompanyByte> cur_company(_current_company, v->owner, FILE_LINE);
  50. -       DoCommand(v->tile, v->index | DEPOT_SERVICE, 0, DC_EXEC, CMD_SEND_VEHICLE_TO_DEPOT);
  51. -       cur_company.Restore();
  52. -   }
  53.  }
  54.  
  55.  static void AircraftEventHandler_HeliLanding(Aircraft *v, const AirportFTAClass *apc)

Comments