increpare / PuzzleScript

Open Source HTML5 Puzzle Game Engine
MIT License
903 stars 159 forks source link

Bug when undoing a restart into an again loop #1026

Open beekie18 opened 3 weeks ago

beekie18 commented 3 weeks ago

Hello,

I ran into a bug in a scenario like this:

  1. the engine is hitting an 'again' loop through the rules
  2. the user hits the restart key
  3. the user hits the undo key

Here's a minimal reproducible example: https://www.puzzlescript.net/editor.html?hack=d0132c7f27dc5c3e8d0bc97d05fea328 The goal is to get to the flag. Pressing right puts the crate onto the conveyor belts, which puts the game in an infinite 'again' loop. This should make this level impossible. However, restarting and then undoing the restart allows the user to press right again, interrupting the conveyor belts.

As far as I can tell, what should happen is what happens with a normal undo while in an again loop: the game goes back to the state before the 'again' was started. In the example above, the player character should end up on the tile it was on before the crate ended up on the arrows.

I was working on a game when I found this bug, and the bug is completely game-breaking. I want an infinite loop to be a failure state the user can undo out of, but with this bug, they can bypass it.

Let me know if you need any more information from me.

Thanks!

Edit: minimized the code even more. Edit: I thought for a bit it was maybe the late-ness of the again rules that are the problem, but you can cause a similar issue even if the two late rules are made not late: https://www.puzzlescript.net/editor.html?hack=c8145ab64c0a75ea2a46b8c1ec347352 (you'll need to press right and then down to cause the infinite loop, and then restart and undo the restart to cause the bug, and then you can get out of the infinite loop when you shouldn't be able to)

david-pfx commented 3 weeks ago

Looks to me like this might be a problem in restart going back to the wrong place when again is happening.