Fix turret anim frame calculation to match game #219
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.
There is a discrepancy between the
TurretAnim
frame calculation between game (both TS and YR, I don't think this has been changed since TS since RA1 uses similar logic to calculate it) and the editor. This PR corrects that discrepancy by making it use same formula for frame calculation as game.Game does the calculation by normalizing the direction to range 0-31 and using that as index to access a lookup table containing the frame indices (starting from 28, decrementing and wrapping around to 31 after 0). The implementation here does not use lookup table but should give same results regardless. The shadow frame selector is currently unused but I corrected it to use the new formula as well.
This issue is not particularly noticeable most of the time but the directional alpha images from #218 made it so as rotating a building with turret and a directional alpha image had the turret frames and alpha image frames out of sync.