NagyD / SDLPoP

An open-source port of Prince of Persia, based on the disassembly of the DOS version.
GNU General Public License v3.0
1.1k stars 140 forks source link

Fixed a turn-run bug that causes trick 1 and trick 2 to work. #312

Closed dstarosta closed 5 months ago

dstarosta commented 5 months ago

I stumbled on this issue when looking at PoP2 bug where Prince can turn-run into walls and use sword to push himself through. The walls there act differently because they are considered floors. But the general issue has been there since PoP1.

If you stay within 8 pixels or less from the wall/gate/tapestry when facing it and hold the forward arrow, Prince is going to do a safe step. But if you face in the opposite direction and hold the back arrow, the game starts the "turnrun" sequence without doing that check. That sequence pushes Prince back one pixel then jumps to the start of the "startrun" sequence. I assume that was done to make the animation a tiny bit smoother as 1 pixel shift is not going to fix bugs that are caused by running frames with a large weight offset value.

I added the wall distance check in the turn-run logic of the code and let the control_forward() method handle the safe step normally if Prince is close to a wall. I also corrected one of the edge_type enum names.

The configurable fix prevents trick 1 and trick 2 on popot.org as well as fixes the issue where Prince can fall back trying to do those tricks when there is an empty tile to the left of the gate.

NagyD commented 5 months ago

Merged, thank you!

For the record, the tricks can be seen here: https://www.popot.org/documentation.php?doc=Tricks#1 https://www.popot.org/documentation.php?doc=Tricks#2