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 split vehicles always using the incorrect pivot point #73055

Merged
merged 3 commits into from
Apr 20, 2024

Conversation

Kamayana
Copy link
Contributor

Summary

Bugfixes "Fix split vehicles always using the incorrect pivot point"

Purpose of change

In vehicle::split_vehicles, every new vehicle created is supposed to get a new position and pivot based on the parts they have after the split. However, when the function checks to make sure the new pivot is a valid 0,0 part, it actually mistakenly assigns the pivot to the part index of the original vehicle, AKA the other half of the split. This makes both resulting halves of the vehicle end up with the same position and pivot points, which can cause issues with anything that relies on a vehicle's position, like vehicle::get_remote_part.

Describe the solution

Set split_part0 to the value inside the split_parts array, not to the index.

Describe alternatives you've considered

Testing

In debug mode, watch the position values of the split vehicles during the relevant functions. See that after splitting the vehicles up they both incorrectly have the same position in the end. Apply this fix, do it again, and see that both splits correctly end up with different positions.

Additional context

This is a cherry-picked commit from my larger power grid usability PR, since as a bug fix it deserves its own PR.

@github-actions github-actions bot added Vehicles Vehicles, parts, mechanics & interactions [C++] Changes (can be) made in C++. Previously named `Code` <Bugfix> This is a fix for a bug (or closes open issue) astyled astyled PR, label is assigned by github actions json-styled JSON lint passed, label assigned by github actions labels Apr 16, 2024
@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Apr 16, 2024
@Maleclypse Maleclypse merged commit 7531b85 into CleverRaven:master Apr 20, 2024
22 of 26 checks passed
@Procyonae
Copy link
Contributor

Does this want backporting to 0.H?

@Kamayana
Copy link
Contributor Author

Does this want backporting to 0.H?

It should, yeah. #73056 too, if possible. I was waiting to see if anyone submitted any issues with them but I haven't seen anything so I think it should be okay.

@GuardianDll GuardianDll added the 0.H Backport PR to backport to the 0.H stable release canddiate label May 12, 2024
Procyonae pushed a commit to Procyonae/Cataclysm-DDA that referenced this pull request May 17, 2024
…0_fix

Fix split vehicles always using the incorrect pivot point
@Procyonae Procyonae mentioned this pull request May 17, 2024
kevingranade pushed a commit that referenced this pull request May 17, 2024
Fix split vehicles always using the incorrect pivot point

Co-authored-by: Kamayana <pigbuster@gmail.com>
@Procyonae Procyonae added 0.H Backported and removed 0.H Backport PR to backport to the 0.H stable release canddiate labels May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.H Backported astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions <Bugfix> This is a fix for a bug (or closes open issue) [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.

4 participants