Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Fix Saving and Loading of panning chunks #1498
Don't merge until #1502 is merged
Fixes saving and loading games in the following conditions. Saves were tested to be compatible between
I also tested these scenarios
This patch uses
I tested some HH3 intro scenes and they work with this branch.
Another test case is you can produce diagonal panning using a no-wait scroll followed by a wait scroll. For example Up (no-wait), and Right (wait). I checked and this case works in Player.
Ghabry left a comment •
This PR breaks indeed the test case in #1169 (comment)
Go to the right until you reach the "mouse ate the tile" msgbox, then go down until you can't go down anymore and then hold right. Wait for the Pan to finish, the "faceset" is gone. This is because the screen is not aligned to the 16-pixel grid anymore
This also reintroduces the "Pan too far" in Razas:
Game download: https://razas.itch.io/razas
Load the save and on the next map in that cutscene there is pan downwards which goes too far until it reaches the map border.
You guys are going to hate me for this.
Previously I was converting panning from (9,7) internally to (0,0) externally in order to minimize code changes. In order to fix these panning problems and get panning implemented the right way, I've had to completely refactor how player scrolling works from scratch.
Panning has a special behavior I didn't notice before. Lets say you are 2 tiles from the right edge of the map, and then you do a panning command to move to the right by 5. What actually happens is
Before we tracked how much we actually panned in a local variable (actual_pan_x/y) and kept incrementing pan_current each frame. This is wrong, pan_current is stops when it hits the edge of the map. We don't need a local variable to track this.
This behavior can be confirmed by saving your game and looking at the chunks. You'll see pan_current = +2 * 256 and pan_finish = +5 * 256.
Finally, we had invented 2 member variables
The panning refactor removes these 2 local variables. Once #1502 is in and
I apologize in advance for the code review this is going to need...