Add feature: realistic train braking
Add setting to select train braking model.
This commit is contained in:
@@ -794,13 +794,19 @@ static void RoadVehArrivesAt(const RoadVehicle *v, Station *st)
|
||||
*/
|
||||
int RoadVehicle::UpdateSpeed()
|
||||
{
|
||||
int max_speed = this->GetCurrentMaxSpeed();
|
||||
switch (_settings_game.vehicle.roadveh_acceleration_model) {
|
||||
default: NOT_REACHED();
|
||||
case AM_ORIGINAL:
|
||||
return this->DoUpdateSpeed(this->overtaking != 0 ? 512 : 256, 0, this->GetCurrentMaxSpeed());
|
||||
case AM_ORIGINAL: {
|
||||
int acceleration = this->overtaking != 0 ? 512 : 256;
|
||||
return this->DoUpdateSpeed({ acceleration, acceleration }, 0, max_speed, max_speed);
|
||||
}
|
||||
|
||||
case AM_REALISTIC:
|
||||
return this->DoUpdateSpeed(this->GetAcceleration() + (this->overtaking != 0 ? 256 : 0), this->GetAccelerationStatus() == AS_BRAKE ? 0 : 4, this->GetCurrentMaxSpeed());
|
||||
case AM_REALISTIC: {
|
||||
GroundVehicleAcceleration acceleration = this->GetAcceleration();
|
||||
if (this->overtaking != 0) acceleration.acceleration += 256;
|
||||
return this->DoUpdateSpeed(acceleration, this->GetAccelerationStatus() == AS_BRAKE ? 0 : 4, max_speed, max_speed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1021,7 +1027,7 @@ static void RoadVehCheckOvertake(RoadVehicle *v, RoadVehicle *u)
|
||||
/* Can't overtake a vehicle that is moving faster than us. If the vehicle in front is
|
||||
* accelerating, take the maximum speed for the comparison, else the current speed.
|
||||
* Original acceleration always accelerates, so always use the maximum speed. */
|
||||
int u_speed = (_settings_game.vehicle.roadveh_acceleration_model == AM_ORIGINAL || u->GetAcceleration() > 0) ? u->GetCurrentMaxSpeed() : u->cur_speed;
|
||||
int u_speed = (_settings_game.vehicle.roadveh_acceleration_model == AM_ORIGINAL || u->GetAcceleration().acceleration > 0) ? u->GetCurrentMaxSpeed() : u->cur_speed;
|
||||
if (u_speed >= v->GetCurrentMaxSpeed() &&
|
||||
!(u->vehstatus & VS_STOPPED) &&
|
||||
u->cur_speed != 0) {
|
||||
|
Reference in New Issue
Block a user