New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change: Gradually slow down aircraft speed on breakdown #6932
Change: Gradually slow down aircraft speed on breakdown #6932
Conversation
Gradually slows down aircraft speed on breakdown, towards the reduced speed, instead of instantly transitioning to that speed.
@@ -635,6 +635,12 @@ static int UpdateAircraftSpeed(Aircraft *v, uint speed_limit = SPEED_LIMIT_NONE, | |||
* 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) { | |||
speed_limit = min(speed_limit, SPEED_LIMIT_BROKEN); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs a similar condition as "(v->vcache.cached_max_speed < speed_limit)" in the case below.
hard_limit should only be set to false, if the new speed limit is the actual speed limit.
If the speed limit was already smaller than SPEED_LIMIT_BROKEN, then it continues to be a hard limit.
src/aircraft_cmd.cpp
Outdated
@@ -635,6 +635,12 @@ static int UpdateAircraftSpeed(Aircraft *v, uint speed_limit = SPEED_LIMIT_NONE, | |||
* 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 > SPEED_LIMIT_BROKEN) hard_limit = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please reverse the condition:
if (SPEED_LIMIT_BROKEN < speed_limit) hard_limit = false;
That way the code is symmetric to the code below ("new limit < old limit"), which makes the code is easier to read.
Gradually slows down aircraft speed on breakdown, towards the reduced speed, instead of instantly transitioning to that speed.
https://www.tt-forums.net/viewtopic.php?p=1193351