refactor: Refactor evaluateContextCommand phase 1 (#1192)#2714
Conversation
|
| Filename | Overview |
|---|---|
| GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp | Three helpers extracted from evaluateContextCommand; previously-reported regressions (missing normalizeGuiCommandTarget call, waypoint non-return, orphaned else-if) are resolved in this revision. Logic is semantically equivalent to the original. |
| GeneralsMD/Code/GameEngine/Include/GameClient/CommandXlat.h | Three new private method declarations added matching the extracted implementations; minor blank-line removal. No structural concerns. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[evaluateContextCommand] --> B[normalizeContextInputs]
B --> C{preferSelection?}
C -- yes --> RET0[return MSG_INVALID]
C -- no --> D{PLACE_BEACON?}
D -- yes --> RET1[return MSG_VALID_GUICOMMAND_HINT]
D -- no --> E{canPerformActions?}
E -- no --> RET2[return MSG_INVALID]
E -- yes --> F{isInWaypointMode?}
F -- yes --> G[handleWaypointModeCommand]
G --> RET3[return msgType]
F -- no --> H{command context/SP?}
H -- yes --> I[normalizeGuiCommandTarget]
I --> J[switch/issue command]
H -- no --> K{CONSTRUCT?}
K -- yes --> L[issue SP construct]
K -- no --> M[natural action cascade]
M --> N[issueMoveToLocationCommand]
J --> RET4[return msgType]
L --> RET4
N --> RET4
Reviews (3): Last reviewed commit: "refactor: move brackets to their own lin..." | Re-trigger Greptile
- Refactor context input normalization into separate function - Refactor GUI command target normalization into separate function - Refactor waypoint mode command into separate function - Clarify intent of early returns
3712493 to
4fd400f
Compare
|
Brackets need to be on their own line. |
…ctor_evaluateContextCommand_phase1
xezon
left a comment
There was a problem hiding this comment.
We first need to merge CommandXlat from Generals and Zero Hour because there are a number of differences and it will be easier to make the refactor just once. I have already started that and can try to finish it next days.
| return msgType; | ||
| } | ||
|
|
||
| // TheSuperHackers @refactor RiQQ 15/5/2026 Extracted from evaluateContextCommand monolith. Preparation for proper refactor |
Relates to: #1192
Initial plan is to extract the context command handling into focused sub-functions, so the decision path in
evaluateContextCommandbecomes immediately legible as a dispatcher. Once the structure is clear, the aim is to simplify the logical flow by eliminating redundant branching and guard conditions that no longer need to live at the top levelTODO: