tweak(gamemessage): Reduce number of MSG_DESTROY_SELECTED_GROUP messages#2668
tweak(gamemessage): Reduce number of MSG_DESTROY_SELECTED_GROUP messages#2668Caball009 wants to merge 6 commits into
Conversation
|
| Filename | Overview |
|---|---|
| GeneralsMD/Code/GameEngine/Source/Common/MessageStream.cpp | Adds isRedundantMessage() and integrates it into the propagateMessages() inner loop; logic handles all expected MSG_DESTROY chains correctly. |
| GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp | Removes postMsg parameter, adds hadSelectedDrawables guard so MSG_DESTROY_SELECTED_GROUP is only appended when something was actually selected. |
| Core/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp | Removes the deselectAll() wrapper and updates all call sites. Refactors selectSingleDrawableWithoutSound so deselect/select only happen when the drawable has an associated game object. |
| GeneralsMD/Code/GameEngine/Include/Common/MessageStream.h | Adds const overloads for next()/prev() and declares isRedundantMessage as a protected const method. |
| GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h | Removes Bool postMsg = true parameter from deselectAllDrawables() declaration. |
| Core/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarBeacon.cpp | Removes the now-gone TRUE argument from deselectAllDrawables(). Behaviour is identical since TRUE was the old default. |
| Core/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp | Comment text normalisation and minor whitespace cleanup. No logic changes. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[deselectAllDrawables called] --> B{hadSelectedDrawables?}
B -- No --> C[No message emitted]
B -- Yes --> D[Append MSG_DESTROY_SELECTED_GROUP]
D --> E[propagateMessages loop]
E --> F{isRedundantMessage?}
F -- Yes: next is MSG_DESTROY_SELECTED_GROUP --> G[Delete duplicate destroy]
F -- Yes: next is MSG_CREATE_SELECTED_GROUP newGroup=true --> H[Delete CREATE implies new group]
F -- Yes: next is MSG_SELECT_TEAM* --> I[Delete team select implies deselect]
F -- No: standalone deselect or add-to-group --> J[Pass to translators]
J --> K{Translator disposition}
K -- DESTROY_MESSAGE --> L[Delete message]
K -- Other --> M[Forward to CommandList / network]
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
A[deselectAllDrawables called] --> B{hadSelectedDrawables?}
B -- No --> C[No message emitted]
B -- Yes --> D[Append MSG_DESTROY_SELECTED_GROUP]
D --> E[propagateMessages loop]
E --> F{isRedundantMessage?}
F -- Yes: next is MSG_DESTROY_SELECTED_GROUP --> G[Delete duplicate destroy]
F -- Yes: next is MSG_CREATE_SELECTED_GROUP newGroup=true --> H[Delete CREATE implies new group]
F -- Yes: next is MSG_SELECT_TEAM* --> I[Delete team select implies deselect]
F -- No: standalone deselect or add-to-group --> J[Pass to translators]
J --> K{Translator disposition}
K -- DESTROY_MESSAGE --> L[Delete message]
K -- Other --> M[Forward to CommandList / network]
Reviews (11): Last reviewed commit: "Added function 'MessageStream::isRedunda..." | Re-trigger Greptile
2a1e6c7 to
fcb6ef1
Compare
xezon
left a comment
There was a problem hiding this comment.
How confident are we that this will cause no gameplay issues?
8baab11 to
219fa73
Compare
40d5547 to
e4af41b
Compare
|
Needs rebasing. |
| ) | ||
| { | ||
| GameMessageDisposition disp = ss->m_translator->translateGameMessage(msg); | ||
| next = msg->next(); |
There was a problem hiding this comment.
I also considered this previously but I did not execute on simplifying that because of MessageStream::insertMessage
There was a problem hiding this comment.
Good point. I didn't think about that. I'll change it back.
There was a problem hiding this comment.
I changed it back but with a small refactor to make both delete branches identical:
next = msg->next();
deleteInstance(msg);
continue;e4af41b to
b642d9a
Compare
I just rebased. I held off on rebasing because I wanted to make it obvious to you (and myself) what the new changes were. |
b642d9a to
78d3981
Compare
The client considers primary mouse clicks in the game world as a deselection, and will also update the game logic. This means that
GameMessage::MSG_DESTROY_SELECTED_GROUPmessages are sent frequently, even if no objects are currently selected. There's actually an old EA comment on this issue. It's also unnecessary to send this message prior to the creation or selection of a new group.This PR makes the following two changes:
MSG_DESTROY_SELECTED_GROUPmessage.MSG_DESTROY_SELECTED_GROUPmessages before other messages that already destroy group selection implicitly (MSG_CREATE_SELECTED_GROUPandGameMessage::MSG_SELECT_TEAM).I've tested with two local clients in multiplayer (VS22 debug builds); one had this feature and one didn't, and everything worked fine.
See commits for cleaner diffs.
Results for Golden Replay 1:
MSG_NETWORK_MESSAGES: 56985MSG_LOGIC_CRC: 11601 (doesn't include 1785 for playback)MSG_DO_MOVETO: 6888MSG_AREA_SELECTION_DEPRECATED: 4476MSG_QUEUE_UNIT_CREATE: 2225MSG_DESTROY_SELECTED_GROUP: 17366MSG_CREATE_SELECTED_GROUP_NO_SOUND: 317, new group: 88MSG_CREATE_SELECTED_GROUP: 8299, new group: 8114MSG_DESTROY_SELECTED_GROUPbefore new group creation: 8901 (more than 8114 + 88, because this message is used twice sometimes ).Just the
MSG_DESTROY_SELECTED_GROUPmessage before the creation of a new group accounts for 15% (8901 / 56985) of all network game messages in this replay. That doesn't even take into account how many times this message was used when no units were selected.TODO: