Skip to content
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

Merged

Conversation

SamuXarick
Copy link
Contributor

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

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);
Copy link
Member

@frosch123 frosch123 Oct 7, 2018

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.

@LordAro LordAro dismissed frosch123’s stale review October 12, 2018 18:00

Updated, new review required

@@ -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;
Copy link
Member

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.

@frosch123 frosch123 merged commit 264e605 into OpenTTD:master Oct 31, 2018
@SamuXarick SamuXarick deleted the smooth-aircraft-speed-on-breakdown branch January 14, 2019 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants