summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSamu <dj_samu@hotmail.com>2018-10-01 23:44:12 +0100
committerNiels Martin Hansen <nielsm@indvikleren.dk>2019-01-28 17:24:33 +0100
commit9c6ac309e0b51fe7952f42ca9a8e2ee30debc473 (patch)
treecbd0059aeb0f735587d461bd47ac26fee4ff55ed /src
parentb28a6784363254de49cc95747c4aada7477d8338 (diff)
downloadopenttd-9c6ac309e0b51fe7952f42ca9a8e2ee30debc473.tar.xz
Fix #6636: Airplanes could be sent to helicopter station depots
Diffstat (limited to 'src')
-rw-r--r--src/aircraft_cmd.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp
index 5f36a7577..d6d99ae24 100644
--- a/src/aircraft_cmd.cpp
+++ b/src/aircraft_cmd.cpp
@@ -128,16 +128,15 @@ static StationID FindNearestHangar(const Aircraft *v)
const AircraftVehicleInfo *avi = AircraftVehInfo(v->engine_type);
FOR_ALL_STATIONS(st) {
- if (st->owner != v->owner || !(st->facilities & FACIL_AIRPORT)) continue;
+ if (st->owner != v->owner || !(st->facilities & FACIL_AIRPORT) || !st->airport.HasHangar()) continue;
const AirportFTAClass *afc = st->airport.GetFTA();
- if (!st->airport.HasHangar() || (
- /* don't crash the plane if we know it can't land at the airport */
- (afc->flags & AirportFTAClass::SHORT_STRIP) &&
- (avi->subtype & AIR_FAST) &&
- !_cheats.no_jetcrash.value)) {
- continue;
- }
+
+ /* don't crash the plane if we know it can't land at the airport */
+ if ((afc->flags & AirportFTAClass::SHORT_STRIP) && (avi->subtype & AIR_FAST) && !_cheats.no_jetcrash.value) continue;
+
+ /* the plane won't land at any helicopter station */
+ if (!(afc->flags & AirportFTAClass::AIRPLANES) && (avi->subtype & AIR_CTOL)) continue;
/* v->tile can't be used here, when aircraft is flying v->tile is set to 0 */
uint distance = DistanceSquare(vtile, st->airport.tile);
@@ -380,7 +379,7 @@ bool Aircraft::FindClosestDepot(TileIndex *location, DestinationID *destination,
{
const Station *st = GetTargetAirportIfValid(this);
/* If the station is not a valid airport or if it has no hangars */
- if (st == NULL || !st->airport.HasHangar()) {
+ if (st == NULL || !CanVehicleUseStation(this, st) || !st->airport.HasHangar()) {
/* the aircraft has to search for a hangar on its own */
StationID station = FindNearestHangar(this);