@@ -987,97 +987,97 @@ static bool AircraftController(Aircraft
/* get aircraft back on running altitude */
SetAircraftPosition(v, gp.x, gp.y, GetAircraftFlyingAltitude(v));
continue;
}
int curz = GetSlopePixelZ(x + amd.x, y + amd.y) + 1;
/* We're not flying below our destination, right? */
assert(curz <= z);
int t = max(1U, dist - 4);
int delta = z - curz;
/* Only start lowering when we're sufficiently close for a 1:1 glide */
if (delta >= t) {
z -= CeilDiv(z - curz, t);
if (z < curz) z = curz;
/* 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) {
z--;
} else if (z < curz) {
z++;
SetAircraftPosition(v, gp.x, gp.y, z);
} while (--count != 0);
return false;
/**
* Handle crashed aircraft \a v.
* @param v Crashed aircraft.
*/
static bool HandleCrashedAircraft(Aircraft *v)
{
v->crashed_counter += 3;
Station *st = GetTargetAirportIfValid(v);
/* make aircraft crash down to the ground */
if (v->crashed_counter < 500 && st == NULL && ((v->crashed_counter % 3) == 0) ) {
int z = GetSlopePixelZ(v->x_pos, v->y_pos);
int z = GetSlopePixelZ(Clamp(v->x_pos, 0, MapMaxX() * TILE_SIZE), Clamp(v->y_pos, 0, MapMaxY() * TILE_SIZE));
v->z_pos -= 1;
if (v->z_pos == z) {
v->crashed_counter = 500;
v->z_pos++;
if (v->crashed_counter < 650) {
uint32 r;
if (Chance16R(1, 32, r)) {
static const DirDiff delta[] = {
DIRDIFF_45LEFT, DIRDIFF_SAME, DIRDIFF_SAME, DIRDIFF_45RIGHT
};
v->direction = ChangeDir(v->direction, delta[GB(r, 16, 2)]);
SetAircraftPosition(v, v->x_pos, v->y_pos, v->z_pos);
r = Random();
CreateEffectVehicleRel(v,
GB(r, 0, 4) - 4,
GB(r, 4, 4) - 4,
GB(r, 8, 4),
EV_EXPLOSION_SMALL);
} else if (v->crashed_counter >= 10000) {
/* remove rubble of crashed airplane */
/* clear runway-in on all airports, set by crashing plane
* small airports use AIRPORT_BUSY, city airports use RUNWAY_IN_OUT_block, etc.
* but they all share the same number */
if (st != NULL) {
CLRBITS(st->airport.flags, RUNWAY_IN_block);
CLRBITS(st->airport.flags, RUNWAY_IN_OUT_block); // commuter airport
CLRBITS(st->airport.flags, RUNWAY_IN2_block); // intercontinental
delete v;
return true;
* Handle smoke of broken aircraft.
* @param v Aircraft
* @param mode Is this the non-first call for this vehicle in this tick?
Status change: