#1869 closed defect (fixed)
[PATCH] Hotkey detection fails under heavy load
Reported by: | zoot | Owned by: | philip |
---|---|---|---|
Priority: | Nice to Have | Milestone: | Alpha 15 |
Component: | UI & Simulation | Keywords: | patch, performance, memory |
Cc: | Patch: |
Description (last modified by )
Steps to reproduce (YMMV):
- Start a match against 7 Aegis bots and set the sim rate to 10x or higher to cause heavy load. The game should be stuttering.
- Use cheats to stock up on resources and population capacity.
- Select the civic center, hold the batch train hotkey (Shift), press Z twice and immediately release the batch train hotkey.
What happens: Training of two female citizens is queued.
What should happen: Since the batch train hotkey was held down, training of two batches of female citizens should have been queued.
Attachments (1)
Change History (10)
comment:1 by , 11 years ago
Description: | modified (diff) |
---|
comment:2 by , 11 years ago
Description: | modified (diff) |
---|
comment:3 by , 11 years ago
Priority: | Should Have → Nice to Have |
---|
comment:4 by , 11 years ago
Keywords: | patch review performance memory added |
---|---|
Milestone: | Backlog → Alpha 14 |
Summary: | Hotkey detection fails under heavy load → [PATCH] Hotkey detection fails under heavy load |
RedFox redid the hotkey system to use a more efficient memory profile and apparently fixed this issue in his memory patch. I have separated out the relevant changes and attached them.
comment:5 by , 11 years ago
Milestone: | Alpha 14 → Alpha 15 |
---|
comment:6 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
I think it's safe to close this ticket, since the code will be committed to A15 anyways. Thanks for opening a ticket for it though.
comment:7 by , 11 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Not fixed - I can reproduce this even with the megapatch applied.
The problem is that the hotkey system receives key up/down events from the SDL event queue, updates its g_HotkeyStatus immediately, and pushes the hotkey up/down onto the back of the event queue. If the queue starts as [shift-down, z-press, shift-up], the hotkey triggered by z-press will go onto the end of the queue, and be processed after g_HotkeyStatus has been updated by the shift-up.
A similar problem occurs when hotkeys are interleaved with mouse events - if the key event is before the mouse event but in the same frame, the key's hotkey event will be pushed after the mouse event.
Hotkey events ought to be processed immediately, not pushed to the end of the queue.
comment:9 by , 8 years ago
Keywords: | review removed |
---|
I imagine some kludgy use of
Engine.HotkeyIsPressed()
is at fault here. You press Z, but due to the stuttering, by the time the game gets around to processing the key press, you have already released the batch train hotkey and soEngine.HotkeyIsPressed()
returns false.It would probably be better to detect "Shift+Z" as one event than just detecting "Z", then waiting, and then checking whether "Shift" is pressed.
On a more general note, it should be considered whether other situations where
Engine.HotkeyIsPressed()
is used are also affected.