JD-pyprocgame
JD-pyprocgame copied to clipboard
delayed gunshot task never cancelled in Sniper mode
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().
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