preble / JD-pyprocgame

New software for the Judge Dredd pinball machine, written against pyprocgame.
http://www.pinballcontrollers.com/
MIT License
16 stars 4 forks source link

delayed gunshot task never cancelled in Sniper mode #6

Open clempo2 opened 2 years ago

clempo2 commented 2 years ago

Sniper mode registers a delayed task in its constructor. This delayed task reschedules itself forever. The task is never cancelled because delayed_cancel() is called with the wrong name.

This bug is not very apparent because delayed tasks are not running when the mode is not present in the ModeQueue.

The fix is to register the delayed handler in mode_started() and cancel the handler with the right name in mode_stopped().

clempo2 commented 2 years ago

You can experiment with this test program but be aware it does not simulate the ticking of delayed tasks the same way the run loop and the ModeQueue does. test.zip