| 395 | |
| 396 | |
| 397 | ClosestDepot 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 | |
| 413 | static void CheckIfAircraftNeedsService(Aircraft *v) |
| 414 | { |
nothing calls this directly
no test coverage detected