Page 1 of 1

BUG: checkpoint reset not working properly

PostPosted: 26 May 2013, 12:06
by Tedium
Hello everyone,

Sadly I have another bug to report :cry:. This one is also very odd. You can try it on level 19 "Volcano" of the default levelpack:

1. Move the main character to the checkpoint. Save when the moving spike is at it's highest position!
2. Now step on the pressure pad and immediately press F3 to reset. When timed correctly, the moving spike will no longer move. Touching the pressure pad will "fix" the moving spike.
3. You can now finish this level without your shadow.

The level replay will result in the death of your main character.
Good luck with debugging ;)!

Re: BUG: checkpoint reset not working properly

PostPosted: 27 May 2013, 15:35
by acme_pjz
Bug confirmed :| But I don't have spare time in this week :|

Re: BUG: checkpoint reset not working properly

PostPosted: 27 May 2013, 21:36
by Edward_Lii
Hello Tedium,

Thanks for reporting this bug, I'm able to reproduce this bug.
I've found the source of the problem, when the game state is loaded the eventQueue isn't cleared.
A simple eventQueue.clear() in the loadState solves this problem, but is by no means good. :|

We need to set the state back to how it was when the state was saved.
So we need to have the exact same eventQueue before and after.
We could store a copy of the eventQueue OR we somehow make sure the queue is empty before saving... :think:

Any suggestions?

Re: BUG: checkpoint reset not working properly

PostPosted: 28 May 2013, 11:10
by acme_pjz
Hi Edward_Lii,

I think the event queue should be empty when saving :| Maybe you can add some test code to print out whether the event queue is empty when saving :|

Re: BUG: checkpoint reset not working properly

PostPosted: 28 May 2013, 14:39
by Edward_Lii
Hello acme_pjz,

acme_pjz {l Wrote}:I think the event queue should be empty when saving :| Maybe you can add some test code to print out whether the event queue is empty when saving :|

At the moment the eventQueue is almost always filled with one or two events when saving at a checkpoint (PlayerIsOn events).
One way to be sure that the eventQueue is empty, is by moving the save/load code after the event handling code.

This works reasonable and probably flawless for the default block event handling, but with scripting there might be some problems.
If a block moves "into" the player through scripting at the same moment the player saves, he will get squashed instead of pushed when the state is loaded.
This is because there are no save variables for dy/dx, which can easily be solved by adding them, but I'm afraid there might be more similar problems with this approach... :|

Anyway, it should work, so I've committed a fix to svn, it's in svn revision 667. ;)