Enforce stricter checks on sequence Facings. #21135
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.
This prevents modders from setting Facings values that can cause the game to crash with an unhelpful
IndexOutOfRangeException
.Consider
Facings: 5
. 1024 / 5 = 204.8 WAngle units for each sprite. The frame selection code rounds this down to 204 per frame, which then leaves angles 204 * 5 = 1020 through 1023 without associated artwork, causing a crash when something asks for that.An alternative solution would be to non-uniformly map the facings to the angle range (4 of the 5 frames have 205 units, 1 with 204, or 5 with 204 and 1 with 208), but this would add a lot of complexity and probably a measurable performance hit. The responsibility is on modders to not pick silly frame values, but this does rely on the game telling them when they do it wrong.