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.
This commit is contained in:
Ivan Sokolov 2023-06-16 18:16:53 +08:00
parent fe035d8514
commit 2d88189b4c
2 changed files with 3 additions and 0 deletions

View File

@ -3223,6 +3223,7 @@ static int _combat_turn(Object* a1, bool a2)
} else { } else {
if (a1 == gDude) { if (a1 == gDude) {
keyboardReset(); keyboardReset();
inputEventQueueReset();
interfaceRenderArmorClass(true); interfaceRenderArmorClass(true);
_combat_free_move = 2 * perkGetRank(gDude, PERK_BONUS_MOVE); _combat_free_move = 2 * perkGetRank(gDude, PERK_BONUS_MOVE);
interfaceRenderActionPoints(gDude->data.critter.combat.ap, _combat_free_move); interfaceRenderActionPoints(gDude->data.critter.combat.ap, _combat_free_move);

View File

@ -292,6 +292,8 @@ void inputEventQueueReset()
{ {
gInputEventQueueReadIndex = -1; gInputEventQueueReadIndex = -1;
gInputEventQueueWriteIndex = 0; gInputEventQueueWriteIndex = 0;
SDL_Event e;
while (SDL_PollEvent(&e)) {} // Clear all input events
} }
// 0x4C8D1C // 0x4C8D1C