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.
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.