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 some uses of part_at() to use precalc positions #72658

Merged
merged 2 commits into from
Mar 28, 2024

Conversation

Kamayana
Copy link
Contributor

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 of part_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 with get_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:
image

After:
image

Additional context

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
@github-actions github-actions bot added Vehicles Vehicles, parts, mechanics & interactions [C++] Changes (can be) made in C++. Previously named `Code` Appliance/Power Grid Anything to do with appliances and power grid json-styled JSON lint passed, label assigned by github actions astyled astyled PR, label is assigned by github actions labels Mar 27, 2024
@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Mar 27, 2024
@Maleclypse Maleclypse merged commit c6b68ab into CleverRaven:master Mar 28, 2024
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Appliance/Power Grid Anything to do with appliances and power grid 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.

2 participants