MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / CheckIfAircraftNeedsService

Function CheckIfAircraftNeedsService

src/aircraft_cmd.cpp:413–437  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

411}
412
413static void CheckIfAircraftNeedsService(Aircraft *v)
414{
415 if (Company::Get(v->owner)->settings.vehicle.servint_aircraft == 0 || !v->NeedsAutomaticServicing()) return;
416 if (v->IsChainInDepot()) {
417 VehicleServiceInDepot(v);
418 return;
419 }
420
421 /* When we're parsing conditional orders and the like
422 * we don't want to consider going to a depot too. */
423 if (!v->current_order.IsType(OT_GOTO_DEPOT) && !v->current_order.IsType(OT_GOTO_STATION)) return;
424
425 const Station *st = Station::Get(v->current_order.GetDestination().ToStationID());
426
427 assert(st != nullptr);
428
429 /* only goto depot if the target airport has a depot */
430 if (st->airport.HasHangar() && CanVehicleUseStation(v, st)) {
431 v->current_order.MakeGoToDepot(st->index, OrderDepotTypeFlag::Service);
432 SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, WID_VV_START_STOP);
433 } else if (v->current_order.IsType(OT_GOTO_DEPOT)) {
434 v->current_order.MakeDummy();
435 SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, WID_VV_START_STOP);
436 }
437}
438
439Money Aircraft::GetRunningCost() const
440{

Callers 1

OnNewEconomyDayMethod · 0.85

Calls 11

VehicleServiceInDepotFunction · 0.85
CanVehicleUseStationFunction · 0.85
SetWindowWidgetDirtyFunction · 0.85
IsTypeMethod · 0.80
GetDestinationMethod · 0.80
HasHangarMethod · 0.80
MakeGoToDepotMethod · 0.80
MakeDummyMethod · 0.80
IsChainInDepotMethod · 0.45
ToStationIDMethod · 0.45

Tested by

no test coverage detected