refactor(gamelogic): Break switch cases of GameLogic::logicMessageDispatcher into separate functions#2702
Conversation
…patcher into separate functions
|
| Filename | Overview |
|---|---|
| Core/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp | ~1600-line refactor extracting all switch-case bodies into named on* member functions; all player-ownership guards, msgPlayer lookups via getMessagePlayer, AIGroupPtr parameters, and ALLOW_SURRENDER guards are correctly reproduced. |
| Generals/Code/GameEngine/Include/GameLogic/GameLogic.h | Adds the full on* declaration block matching the implementations, including properly guarded ALLOW_SURRENDER and debug-only declarations; adds #include "GameLogic/AI.h" for AIGroupPtr. |
| GeneralsMD/Code/GameEngine/Include/GameLogic/GameLogic.h | Mirror of the Generals header change; declaration set and preprocessor guards are consistent with the implementations. |
Sequence Diagram
sequenceDiagram
participant Caller
participant logicMessageDispatcher
participant on_Handler as on*() handler
participant AIGroup
participant TheNetwork
Caller->>logicMessageDispatcher: msg, userData
logicMessageDispatcher->>logicMessageDispatcher: getMessagePlayer(msg)
logicMessageDispatcher->>logicMessageDispatcher: switch(msgType)
logicMessageDispatcher->>on_Handler: onXxx(msg [, currentlySelectedGroup])
alt needs player
on_Handler->>on_Handler: getMessagePlayer(msg)
end
alt needs AI group
on_Handler->>AIGroup: groupXxx(...)
end
alt MSG_LOGIC_CRC
on_Handler->>TheNetwork: getPlayerName / isPlayerConnected
on_Handler-->>logicMessageDispatcher: false (disconnected) or true (CRC written)
end
on_Handler-->>logicMessageDispatcher: bool result (unused)
logicMessageDispatcher->>logicMessageDispatcher: break (exits switch)
logicMessageDispatcher-->>Caller: (cleanup continues)
Reviews (4): Last reviewed commit: "Fix compile error" | Re-trigger Greptile
|
Generals fails to compile until replicated. |
|
Do we need the braces per case? It makes the function a lot longer. |
Is not strictly necessary. Braces are only needed if a variable needs declaration in the top switch case scope. Do you want it removed? |
91c7c5d to
5d14b30
Compare
|
I don't have a strong opinion on it either way, but I lean toward removing them to make the function shorter. |
This change breaks all switch cases of
GameLogic::logicMessageDispatcherinto separate functions for ease of readability and maintainability.The logic is unchanged.
TODO