|
@@ -649,13 +649,13 @@ static int UpdateAircraftSpeed(Aircraft
|
|
|
* and take-off speeds being too low. */
|
|
|
speed_limit *= _settings_game.vehicle.plane_speed;
|
|
|
|
|
|
/* adjust speed for broken vehicles */
|
|
|
if (v->vehstatus & VS_AIRCRAFT_BROKEN) {
|
|
|
if (SPEED_LIMIT_BROKEN < speed_limit) hard_limit = false;
|
|
|
speed_limit = min(speed_limit, SPEED_LIMIT_BROKEN);
|
|
|
speed_limit = std::min<uint>(speed_limit, SPEED_LIMIT_BROKEN);
|
|
|
}
|
|
|
|
|
|
if (v->vcache.cached_max_speed < speed_limit) {
|
|
|
if (v->cur_speed < speed_limit) hard_limit = false;
|
|
|
speed_limit = v->vcache.cached_max_speed;
|
|
|
}
|
|
@@ -666,16 +666,16 @@ static int UpdateAircraftSpeed(Aircraft
|
|
|
* forced to slow down rapidly in the short distance needed. The magic
|
|
|
* value 16384 was determined to give similar results to the old speed/48
|
|
|
* method at slower speeds. This also results in less reduction at slow
|
|
|
* speeds to that aircraft do not get to taxi speed straight after
|
|
|
* touchdown. */
|
|
|
if (!hard_limit && v->cur_speed > speed_limit) {
|
|
|
speed_limit = v->cur_speed - max(1, ((v->cur_speed * v->cur_speed) / 16384) / _settings_game.vehicle.plane_speed);
|
|
|
speed_limit = v->cur_speed - std::max(1, ((v->cur_speed * v->cur_speed) / 16384) / _settings_game.vehicle.plane_speed);
|
|
|
}
|
|
|
|
|
|
spd = min(v->cur_speed + (spd >> 8) + (v->subspeed < t), speed_limit);
|
|
|
spd = std::min(v->cur_speed + (spd >> 8) + (v->subspeed < t), speed_limit);
|
|
|
|
|
|
/* updates statusbar only if speed have changed to save CPU time */
|
|
|
if (spd != v->cur_speed) {
|
|
|
v->cur_speed = spd;
|
|
|
SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, WID_VV_START_STOP);
|
|
|
}
|
|
@@ -734,13 +734,13 @@ void GetAircraftFlightLevelBounds(const
|
|
|
break;
|
|
|
|
|
|
default: break;
|
|
|
}
|
|
|
|
|
|
/* Make faster planes fly higher so that they can overtake slower ones */
|
|
|
base_altitude += min(20 * (v->vcache.cached_max_speed / 200) - 90, 0);
|
|
|
base_altitude += std::min(20 * (v->vcache.cached_max_speed / 200) - 90, 0);
|
|
|
|
|
|
if (min_level != nullptr) *min_level = base_altitude + AIRCRAFT_MIN_FLYING_ALTITUDE;
|
|
|
if (max_level != nullptr) *max_level = base_altitude + AIRCRAFT_MAX_FLYING_ALTITUDE;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -926,13 +926,13 @@ static bool AircraftController(Aircraft
|
|
|
|
|
|
/* Reached altitude? */
|
|
|
if (v->z_pos >= z_dest) {
|
|
|
v->cur_speed = 0;
|
|
|
return true;
|
|
|
}
|
|
|
SetAircraftPosition(v, v->x_pos, v->y_pos, min(v->z_pos + count, z_dest));
|
|
|
SetAircraftPosition(v, v->x_pos, v->y_pos, std::min(v->z_pos + count, z_dest));
|
|
|
}
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
/* Helicopter landing. */
|
|
@@ -972,15 +972,15 @@ static bool AircraftController(Aircraft
|
|
|
}
|
|
|
u->cur_speed += 4;
|
|
|
} else {
|
|
|
count = UpdateAircraftSpeed(v);
|
|
|
if (count > 0) {
|
|
|
if (v->z_pos > z) {
|
|
|
SetAircraftPosition(v, v->x_pos, v->y_pos, max(v->z_pos - count, z));
|
|
|
SetAircraftPosition(v, v->x_pos, v->y_pos, std::max(v->z_pos - count, z));
|
|
|
} else {
|
|
|
SetAircraftPosition(v, v->x_pos, v->y_pos, min(v->z_pos + count, z));
|
|
|
SetAircraftPosition(v, v->x_pos, v->y_pos, std::min(v->z_pos + count, z));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
@@ -1122,13 +1122,13 @@ static bool AircraftController(Aircraft
|
|
|
SetAircraftPosition(v, gp.x, gp.y, GetAircraftFlightLevel(v));
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
/* We're not flying below our destination, right? */
|
|
|
assert(airport_z <= z);
|
|
|
int t = max(1U, dist - 4);
|
|
|
int t = std::max(1U, dist - 4);
|
|
|
int delta = z - airport_z;
|
|
|
|
|
|
/* Only start lowering when we're sufficiently close for a 1:1 glide */
|
|
|
if (delta >= t) {
|
|
|
z -= CeilDiv(z - airport_z, t);
|
|
|
}
|