From 2d88189b4cf04e562a49b6761c70a74735e292a2 Mon Sep 17 00:00:00 2001 From: Ivan Sokolov Date: Fri, 16 Jun 2023 18:16:53 +0800 Subject: [PATCH] Clear input envents on combat turn Issue: if a user skips turn by clicking end a combat turn button the cursor becomes frozen in "watch" mode but all input events are queued. If a user clicked while the AI turn is not ended then the next user's turn is skipped. Fix: clear input queue each time before user's turn. --- src/combat.cc | 1 + src/input.cc | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/combat.cc b/src/combat.cc index 8548137..2cfe082 100644 --- a/src/combat.cc +++ b/src/combat.cc @@ -3223,6 +3223,7 @@ static int _combat_turn(Object* a1, bool a2) } else { if (a1 == gDude) { keyboardReset(); + inputEventQueueReset(); interfaceRenderArmorClass(true); _combat_free_move = 2 * perkGetRank(gDude, PERK_BONUS_MOVE); interfaceRenderActionPoints(gDude->data.critter.combat.ap, _combat_free_move); diff --git a/src/input.cc b/src/input.cc index ccfa5a6..837aa92 100644 --- a/src/input.cc +++ b/src/input.cc @@ -292,6 +292,8 @@ void inputEventQueueReset() { gInputEventQueueReadIndex = -1; gInputEventQueueWriteIndex = 0; + SDL_Event e; + while (SDL_PollEvent(&e)) {} // Clear all input events } // 0x4C8D1C