Fix some uses of part_at() to use precalc positions #72658
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
part_at() refers to parts by precalc, unlike most other vehicle functions that go by mount, so part_at was always returning -1 in some places
Summary
None
Purpose of change
While most vehicle functions that fetch a part need the mount point as a parameter,
part_at()
uniquely needs to be given the part's precalc position. This made some uses ofpart_at
always return -1 in some places, such as for appliances (which can have inaccurate precalcs because they never move and thus, never update them).Describe the solution
Add a
coord_translate
to convert the mount point to a facing-relative direction, which is equivalent to precalc[0].Describe alternatives you've considered
Rewrite
part_at
to use mount points instead. It gets used in tandem withget_points()
though, which also uses facing-relative positions, and that's a much wider-used function.Testing
Added a debug message, checked the part index found:
Before:
After:
Additional context