Skip to content

Enforce stricter checks on sequence Facings.#21135

Merged
PunkPun merged 1 commit into
OpenRA:bleedfrom
pchote:facings-check
Oct 21, 2023
Merged

Enforce stricter checks on sequence Facings.#21135
PunkPun merged 1 commit into
OpenRA:bleedfrom
pchote:facings-check

Conversation

@pchote

@pchote pchote commented Oct 19, 2023

Copy link
Copy Markdown
Member

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.

@pchote

pchote commented Oct 19, 2023

Copy link
Copy Markdown
Member Author

Testcase: https://resource.openra.net/maps/54794

@PunkPun
PunkPun merged commit 20c683f into OpenRA:bleed Oct 21, 2023
@PunkPun

PunkPun commented Oct 21, 2023

Copy link
Copy Markdown
Member

changelog

@pchote
pchote deleted the facings-check branch October 29, 2023 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants