Fix #8437: Planes landing at non-rectangular airports could be drawn at the wrong height

Only the rotated intercontinental airport, don't get excited

(cherry picked from commit 190528c2a9aaf4e90d0e768e6ad6afe6870af73d)
pull/211/head
Charles Pigott 3 years ago committed by Jonathan G Rennison
parent 760cab2632
commit e8d811d472

@ -1115,6 +1115,15 @@ static bool AircraftController(Aircraft *v)
z = GetAircraftFlightLevel(v);
}
/* Some airports (like a rotated intercontinental) are non-rectangular and their primary (north-most) tile might not be at the same height as the runway.
* Therefore, as the hangar must be on flat ground (and we must have a hangar, as we're landing/braking and so not a helicopter), use that as the z position instead. */
int airport_z = v->z_pos;
if ((amd.flag & (AMED_LAND | AMED_BRAKE)) && st != nullptr) {
assert(st->airport.HasHangar());
TileIndex hangar_tile = st->airport.GetHangarTile(0);
airport_z = TilePixelHeight(hangar_tile) + 1; // To avoid clashing with the shadow
}
if (amd.flag & AMED_LAND) {
if (st->airport.tile == INVALID_TILE) {
/* Airport has been removed, abort the landing procedure */
@ -1126,27 +1135,24 @@ static bool AircraftController(Aircraft *v)
continue;
}
int curz = GetSlopePixelZ(x + amd.x, y + amd.y) + 1;
/* We're not flying below our destination, right? */
assert(curz <= z);
assert(airport_z <= z);
int t = max(1U, dist - 4);
int delta = z - curz;
int delta = z - airport_z;
/* Only start lowering when we're sufficiently close for a 1:1 glide */
if (delta >= t) {
z -= CeilDiv(z - curz, t);
z -= CeilDiv(z - airport_z, t);
}
if (z < curz) z = curz;
if (z < airport_z) z = airport_z;
}
/* We've landed. Decrease speed when we're reaching end of runway. */
if (amd.flag & AMED_BRAKE) {
int curz = GetSlopePixelZ(x, y) + 1;
if (z > curz) {
if (z > airport_z) {
z--;
} else if (z < curz) {
} else if (z < airport_z) {
z++;
}

Loading…
Cancel
Save