@ -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 ( cur z < = z ) ;
assert ( airport_z < = z ) ;
int t = max ( 1U , dist - 4 ) ;
int delta = z - cur z;
int delta = z - airport_ z;
/* Only start lowering when we're sufficiently close for a 1:1 glide */
if ( delta > = t ) {
z - = CeilDiv ( z - cur z, t ) ;
z - = CeilDiv ( z - airport_ z, t ) ;
}
if ( z < curz) z = cur z;
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 > cur z) {
if ( z > airport_ z) {
z - - ;
} else if ( z < cur z) {
} else if ( z < airport_ z) {
z + + ;
}