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

Method FindClosestDepot

src/aircraft_cmd.cpp:397–411  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

395
396
397ClosestDepot Aircraft::FindClosestDepot()
398{
399 const Station *st = GetTargetAirportIfValid(this);
400 /* If the station is not a valid airport or if it has no hangars */
401 if (st == nullptr || !CanVehicleUseStation(this, st) || !st->airport.HasHangar()) {
402 /* the aircraft has to search for a hangar on its own */
403 StationID station = FindNearestHangar(this);
404
405 if (station == StationID::Invalid()) return ClosestDepot();
406
407 st = Station::Get(station);
408 }
409
410 return ClosestDepot(st->xy, st->index);
411}
412
413static void CheckIfAircraftNeedsService(Aircraft *v)
414{

Callers

nothing calls this directly

Calls 6

GetTargetAirportIfValidFunction · 0.85
CanVehicleUseStationFunction · 0.85
FindNearestHangarFunction · 0.85
InvalidFunction · 0.85
ClosestDepotClass · 0.85
HasHangarMethod · 0.80

Tested by

no test coverage detected