Skip to content

refactor(metaevent): Move meta event type asserts from key event update to engine initialization#2590

Open
xezon wants to merge 2 commits intoTheSuperHackers:mainfrom
xezon:xezon/refactor-metaevent-assert
Open

refactor(metaevent): Move meta event type asserts from key event update to engine initialization#2590
xezon wants to merge 2 commits intoTheSuperHackers:mainfrom
xezon:xezon/refactor-metaevent-assert

Conversation

@xezon
Copy link
Copy Markdown

@xezon xezon commented Apr 12, 2026

This change moves the meta event type asserts from the key event update to engine initialization.

Additionally function MetaMap::generateMetaMap is no longer static. It never was supposed to be.

TODO

  • Replicate in Generals

@xezon xezon added Minor Severity: Minor < Major < Critical < Blocker Gen Relates to Generals ZH Relates to Zero Hour Refactor Edits the code with insignificant behavior changes, is never user facing Debug Is mostly debug functionality labels Apr 12, 2026
@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Apr 12, 2026

Greptile Summary

This PR moves the meta event type assertion from the hot translateGameMessage gameplay loop to a dedicated verifyMetaMap() called once at engine initialization, and fixes generateMetaMap() to be a non-static instance method. Both calls now correctly land after the debug and demo CommandMap INI files are loaded, so all records are covered at verification time.

Confidence Score: 5/5

Safe to merge — the refactor is mechanically correct, the ordering fix is sound, and no P0/P1 issues remain.

All three changes (de-static-ifying generateMetaMap, removing the hot-path assert, adding verifyMetaMap post-INI-load) are logically correct. The previous reviewer concern about verifyMetaMap running before debug INI loads is directly resolved by the new call site on lines 638-639, which is after both CommandMapDebug and CommandMapDemo are loaded. No regressions or new issues identified.

No files require special attention.

Important Files Changed

Filename Overview
GeneralsMD/Code/GameEngine/Include/GameClient/MetaEvent.h Removes static from generateMetaMap() declaration and adds new verifyMetaMap() method; straightforward and correct.
GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp Moves generateMetaMap() to after debug/demo INI loads and adds verifyMetaMap() call — ordering is correct and directly addresses the previous review concern.
GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cpp Removes hot-path assertion from translateGameMessage, de-static-ifies generateMetaMap() (replacing TheMetaMap-> with this->), and adds verifyMetaMap() with the equivalent #ifdef DEBUG_CRASHING guard.

Sequence Diagram

sequenceDiagram
    participant GE as GameEngine::init()
    participant MM as TheMetaMap (MetaMap)
    participant INI as INI Loader

    GE->>MM: initSubsystem (loads CommandMap.ini)
    GE->>INI: loadFileDirectory(CommandMapDebug) [#ifdef RTS_DEBUG]
    GE->>INI: loadFileDirectory(CommandMapDemo) [#ifdef _ALLOW_DEBUG_CHEATS_IN_RELEASE]
    GE->>MM: generateMetaMap()
    Note over MM: Fills default key bindings using this->getMetaMapRec()
    GE->>MM: verifyMetaMap()
    Note over MM: Asserts all records have valid meta msg types [#ifdef DEBUG_CRASHING]
Loading

Reviews (2): Last reviewed commit: "Fix placement of generateMetaMap and ver..." | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Debug Is mostly debug functionality Gen Relates to Generals Minor Severity: Minor < Major < Critical < Blocker Refactor Edits the code with insignificant behavior changes, is never user facing ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant