Skip to content

tweak(gamemessage): Reduce number of MSG_DESTROY_SELECTED_GROUP messages#2668

Merged
xezon merged 7 commits into
TheSuperHackers:mainfrom
Caball009:tweak_msg_destroy_sel_group_reduced
Jul 13, 2026
Merged

tweak(gamemessage): Reduce number of MSG_DESTROY_SELECTED_GROUP messages#2668
xezon merged 7 commits into
TheSuperHackers:mainfrom
Caball009:tweak_msg_destroy_sel_group_reduced

Conversation

@Caball009

@Caball009 Caball009 commented Apr 30, 2026

Copy link
Copy Markdown

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_GROUP messages 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:

  1. a new check to verify that the local player has objects selected before creating a MSG_DESTROY_SELECTED_GROUP message.
  2. Remove MSG_DESTROY_SELECTED_GROUP messages before other messages that already destroy group selection implicitly (MSG_CREATE_SELECTED_GROUP and GameMessage::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: 56985
  • MSG_LOGIC_CRC: 11601 (doesn't include 1785 for playback)
  • MSG_DO_MOVETO: 6888
  • MSG_AREA_SELECTION_DEPRECATED: 4476
  • MSG_QUEUE_UNIT_CREATE: 2225
  • MSG_DESTROY_SELECTED_GROUP: 17366
  • MSG_CREATE_SELECTED_GROUP_NO_SOUND: 317, new group: 88
  • MSG_CREATE_SELECTED_GROUP: 8299, new group: 8114
  • MSG_DESTROY_SELECTED_GROUP before new group creation: 8901 (more than 8114 + 88, because this message is used twice sometimes).

Just the MSG_DESTROY_SELECTED_GROUP message 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:

  • Replicate in Generals.
  • Do more thorough testing.

@Caball009 Caball009 added Enhancement Is new feature or request Minor Severity: Minor < Major < Critical < Blocker Gen Relates to Generals ZH Relates to Zero Hour labels Apr 30, 2026
@greptile-apps

greptile-apps Bot commented Apr 30, 2026

Copy link
Copy Markdown

Greptile Summary

This PR reduces redundant selection-group network messages. The main changes are:

  • Emit destroy-selection messages only for non-empty selections.
  • Remove destroy-selection messages superseded by group or team selection.
  • Mirror the message-stream and UI changes in Generals and Zero Hour.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
Generals/Code/GameEngine/Source/Common/MessageStream.cpp Filters destroy-selection messages that are immediately replaced by a new selection operation.
GeneralsMD/Code/GameEngine/Source/Common/MessageStream.cpp Mirrors the Generals message filtering behavior for Zero Hour.
Generals/Code/GameEngine/Source/GameClient/InGameUI.cpp Avoids emitting a destroy-selection message when no drawable was selected.
GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp Mirrors the conditional deselection message behavior for Zero Hour.
Core/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp Updates selection paths to use the revised deselection behavior.

Reviews (12): Last reviewed commit: "Replicated in Generals." | Re-trigger Greptile

Comment thread GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp Outdated
Comment thread GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp Outdated
Comment thread GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp Outdated
Comment thread GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp Outdated
Comment thread GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp Outdated
@Caball009 Caball009 force-pushed the tweak_msg_destroy_sel_group_reduced branch 2 times, most recently from 2a1e6c7 to fcb6ef1 Compare May 3, 2026 18:48

@xezon xezon left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How confident are we that this will cause no gameplay issues?

Comment thread GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp Outdated
Comment thread GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp Outdated
Comment thread GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp Outdated
Comment thread GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp Outdated
Comment thread GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp Outdated
Comment thread GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp Outdated
Comment thread GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp Outdated
Comment thread GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp Outdated
@Caball009 Caball009 force-pushed the tweak_msg_destroy_sel_group_reduced branch 2 times, most recently from 8baab11 to 219fa73 Compare June 30, 2026 04:39
Comment thread GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp Outdated
Comment thread GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
Comment thread Core/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp Outdated
Comment thread GeneralsMD/Code/GameEngine/Source/Common/MessageStream.cpp Outdated
Comment thread GeneralsMD/Code/GameEngine/Source/Common/MessageStream.cpp Outdated
@Caball009 Caball009 force-pushed the tweak_msg_destroy_sel_group_reduced branch from 40d5547 to e4af41b Compare July 8, 2026 19:35
@xezon

xezon commented Jul 8, 2026

Copy link
Copy Markdown

Needs rebasing.

Comment thread GeneralsMD/Code/GameEngine/Source/Common/MessageStream.cpp
Comment thread GeneralsMD/Code/GameEngine/Source/Common/MessageStream.cpp Outdated
Comment thread GeneralsMD/Code/GameEngine/Source/Common/MessageStream.cpp Outdated
@Caball009 Caball009 force-pushed the tweak_msg_destroy_sel_group_reduced branch from e4af41b to b642d9a Compare July 8, 2026 20:45
@Caball009

Caball009 commented Jul 8, 2026

Copy link
Copy Markdown
Author

Needs rebasing.

I just rebased. I held off on rebasing because I wanted to make it obvious to you (and myself) what the new changes were.

@Caball009 Caball009 force-pushed the tweak_msg_destroy_sel_group_reduced branch from b642d9a to 78d3981 Compare July 8, 2026 21:08
@Caball009

Copy link
Copy Markdown
Author

Replicated in Generals.

@xezon xezon merged commit ca9358f into TheSuperHackers:main Jul 13, 2026
17 checks passed
@Caball009 Caball009 deleted the tweak_msg_destroy_sel_group_reduced branch July 13, 2026 11:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement Is new feature or request Gen Relates to Generals Minor Severity: Minor < Major < Critical < Blocker ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants