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

Fix rearward towing #74916

Merged
merged 3 commits into from
Jul 7, 2024
Merged

Fix rearward towing #74916

merged 3 commits into from
Jul 7, 2024

Conversation

PatrikLundell
Copy link
Contributor

@PatrikLundell PatrikLundell commented Jul 5, 2024

Summary

None

Purpose of change

Fix #74907, i.e. towing a vehicle rearwards causes it to instantly accelerate to a very high velocity, smash into the towing vehicle, and shoot off into the distance.

Describe the solution

Remove a weird line that destroys the logic by replacing a value that's expected to be either 1 or -1 with 10. I have no idea what this line is supposed to achieve (or how it was tested...), but the operation called immediately after setting the value makes the assumption the value is either 1 or -1 to indicate it breaking or accelerating (0 might be steady: I didn't look for that case), so instead of accelerating as the code leading up to this had concluded, 10 resulted in it not being 1, and so had to be breaking. This, in turn seems to have resulted in code for breaking being called with acceleration values, which, in turn, gave bizarre results when feeding into what what supposed to be a limiting operation (min of two negative values does NOT result in the one closest to zero...).

Describe alternatives you've considered

Try to figure out why this "random" line was entered. However, I don't know how to search for where and when code was changed.

Testing

  • Got into the towing car and towed the vehicle a bit, noting that towing behaved as I expected from previous towing experience.
  • Reloaded the bug report save and moved the towing vehicle and cable to the front and towed forwards, again noting that towing behaved as I expected (and as it did with the same save before the change).

Based on @RenechCDDA's archeology dig, I tested the bug report save to see what happened if I attached the cable to the side of the pulled vehicle (I tried both of the two middle tiles at one side):

  • The results weren't quite intuitive in that it mostly was turned and pulled either forwards or backwards, with only one case where I managed to drag it sideways. I would have wanted a bit more sideways dragging. However, it's far superior to the absolutely crazy and unpredictable flipping towing of wrecks has had in the past. It should be noted that the dragged vehicle has enough wheels, so the result might be different when it hasn't got those (as is the case with most wreck participants).

Additional context

@github-actions github-actions bot added Vehicles Vehicles, parts, mechanics & interactions [C++] Changes (can be) made in C++. Previously named `Code` json-styled JSON lint passed, label assigned by github actions labels Jul 5, 2024
@github-actions github-actions bot added BasicBuildPassed This PR builds correctly, label assigned by github actions astyled astyled PR, label is assigned by github actions labels Jul 5, 2024
@RenechCDDA
Copy link
Member

RenechCDDA commented Jul 5, 2024

Try to figure out why this "random" line was entered. However, I don't know how to search for where and when code was changed.

The line in question is from commit e29a5af, I think the commit message is on the mark. There's a way to track it back to the actual PR but I don't recall offhand.

Normally you can use the github.com's actual browser "blame" feature which activates git blame, but it'll time out if the file is too long/has too much history like vehicle.cpp does. Past that you can do the same thing locally with command line options or various other utilities. I used VS2019's Blame (Annotate) feature, which does much the same.

@Maleclypse Maleclypse merged commit d4ba756 into CleverRaven:master Jul 7, 2024
29 checks passed
@PatrikLundell PatrikLundell deleted the fix_tow branch July 7, 2024 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions [C++] Changes (can be) made in C++. Previously named `Code` json-styled JSON lint passed, label assigned by github actions Vehicles Vehicles, parts, mechanics & interactions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Towing a bogged down vehicle results in high speed rubberbanding
3 participants