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

Refactor autodrive and not allow unsafe autodrive speed #46317

Merged

Conversation

RoyBerube
Copy link
Contributor

@RoyBerube RoyBerube commented Dec 25, 2020

Summary

SUMMARY: Bugfixes "Refactor autodrive activity and not allow unsafe autodrive speed"

Purpose of change

Fixes #45260
Also erases drawn path on overmap screen when cancelling autodrive.

Describe the solution

When autodrive is enabled, the vehicle max speed is limited to the safe speed.

The fix to control the autodrive speed was simple, but the problem was the boolean is_autodriving was not being reset on cancelling the activity. So the speed limit would be enforced even after cancelling - not good.

For an elegant solution I wanted to use a cancel method but activity handlers do not have them, and since handlers are deprecated I did not want to rewrite any of that code. So I refactored the autodrive activity to be an activity actor instead.

Cancelling autodrive disables the is_autodriving boolean so the speed limiting code properly reflects either manual or autodrive control.

I also took the opportunity to erase the overmap character path which was persisting after cancelling an autodrive.

Describe alternatives you've considered

Handling the code similar to how foot travel is cancelled. It would have worked but the refactor to an activity actor needed to be done eventually anyway.

Also had coded in a cancel activity into the existing handler and it worked fine, but decided that deprecated code should not be expanded upon.

Testing

Full test program: no faults found.

Tested with a mountain bike and a 4 by 4 car.

Mountain bike before the fix: The bike would often exceed the safe limit of 15 mph and would tire out the player character.
Mountain bike after the fix: the bike speed never exceeds 15 mph and is easier on the player character.

4 by 4 car before and after the fix: the max autodrive speed is limited to 35 mph. No difference noticed.

Additional context

No serialize support included - the activity is not saved.

@RoyBerube RoyBerube force-pushed the autodrive_activity_refactor branch from 5d93996 to 7c4bb83 Compare December 25, 2020 18:11
@RoyBerube RoyBerube force-pushed the autodrive_activity_refactor branch from 7c4bb83 to 2a6e0e9 Compare December 25, 2020 18:17
Co-authored-by: actual-nh <74678550+actual-nh@users.noreply.github.com>
Co-authored-by: Anton Burmistrov <Night_Pryanik@mail.ru>
@anothersimulacrum anothersimulacrum added the [C++] Changes (can be) made in C++. Previously named `Code` label Dec 26, 2020
@kevingranade kevingranade merged commit 4b61507 into CleverRaven:master Dec 30, 2020
@RoyBerube RoyBerube deleted the autodrive_activity_refactor branch December 30, 2020 02:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code`
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Auto-travel uses vehicle unsafe speed
5 participants