fix(metaevent): Ignore order in which modifier keys are released to trigger meta events#2577
fix(metaevent): Ignore order in which modifier keys are released to trigger meta events#2577xezon wants to merge 3 commits intoTheSuperHackers:mainfrom
Conversation
…rigger meta events
|
| Filename | Overview |
|---|---|
| GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cpp | Core fix with one P1 regression: unconditional bottom KEY_UP block can erase the wrong modifier tracking on KEY_NONE when two modifiers are combined. |
| GeneralsMD/Code/GameEngine/Include/GameClient/MetaEvent.h | Introduces KeyDownInfo struct with compact UnsignedByte bitfield for 7 mod-state combinations; replaces m_lastKeyDown with m_keyDownInfos[KEY_COUNT]. |
| Core/Libraries/Include/Lib/BaseType.h | Adds BitsAreSet macro — straightforward and correctly placed. |
Prompt To Fix All With AI
This is a comment left during a code review.
Path: GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cpp
Line: 598-605
Comment:
**Unconditional KEY_UP block clears wrong modifier tracking on `KEY_NONE`**
When a modifier is released while another modifier remains held, `key` is `KEY_NONE` and `newModState` is the *still-held* modifier. This block calls `clearKeyModState(newModState)` on `KEY_NONE`, erasing the tracking bit that was set when the remaining modifier was originally pressed alone.
Concrete failure: SHIFT pressed alone (bit 2 set on `KEY_NONE`), then CTRL pressed (bit 4 set). When CTRL is released: the `modStateRemoved` path correctly preserves bit 2, but this block then calls `clearKeyModState(SHIFT)` — bit 2 is gone. When SHIFT is later released, `modStateRemoved` finds `KEY_NONE` empty and `SHIFT+MK_NONE UP` is never fired.
Adding `!modStateRemoved` as a guard fixes it.
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cpp
Line: 502-512
Comment:
**Missing `break` after firing meta-event**
The regular path breaks after the first matching `MetaMapRec`. The `modStateRemoved` loop fires all matching entries for a given `key + modState + UP` combination. Harmless in practice but inconsistent with the regular path.
How can I resolve this? If you propose a fix, please make it concise.Reviews (3): Last reviewed commit: "Flip args BitsAreSet" | Re-trigger Greptile
This change ignores the order in which keys are released to trigger meta events.
This is useful because players do not necessarily and intuitively release the keys in the expected strict order. For example CTRL + A press, A + CTRL release. Trouble can arise when releasing CTRL before A, because then the mapped meta event would not trigger.
This is no issue in the original game because it has no meta event mapping on Release and Modifier, but it can be on Mods or Debug builds, for example with #2546 adding a Comma + CTRL release event.
TODO