-
Notifications
You must be signed in to change notification settings - Fork 190
tweak(gamemessage): Reduce number of MSG_DESTROY_SELECTED_GROUP messages #2668
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
6c8d336
db6a8e6
4c917cd
4453191
8c156f6
fcb6ef1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3553,9 +3553,10 @@ void InGameUI::deselectDrawable( Drawable *draw ) | |
| //------------------------------------------------------------------------------------------------- | ||
| /** Clear all drawables' "select" status */ | ||
| //------------------------------------------------------------------------------------------------- | ||
| void InGameUI::deselectAllDrawables( Bool postMsg ) | ||
| void InGameUI::deselectAllDrawables( Bool updateGameLogic ) | ||
| { | ||
| const DrawableList *selected = getAllSelectedDrawables(); | ||
| const Bool emptySelectedDrawables = selected->empty(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe flip meaning to Then it is a positive meaning |
||
|
|
||
| // loop through all the selected drawables | ||
| for ( DrawableListCIt it = selected->begin(); it != selected->end(); ) | ||
|
|
@@ -3576,16 +3577,14 @@ void InGameUI::deselectAllDrawables( Bool postMsg ) | |
| // our selection can no longer consist of exactly one angry mob | ||
| m_soloNexusSelectedDrawableID = INVALID_DRAWABLE_ID; | ||
|
|
||
|
|
||
| ///@todo don't we want to not emit this message if there wasn't a group at all? (CBD) | ||
| /** @todo also, we probably are sending this message too much, we should come up with | ||
| some kind of "selections are dirty" status that we can check once per frame and send | ||
| the correct group info over the network ... could be tricky tho (or impossible) given | ||
| the order of operations of things happening in the code (CBD) */ | ||
| if( postMsg ) | ||
| if (updateGameLogic) | ||
| { | ||
| // TheSuperHackers @tweak Originally this message had one boolean argument, but it wasn't used for anything. | ||
| TheMessageStream->appendMessage( GameMessage::MSG_DESTROY_SELECTED_GROUP ); | ||
| // TheSuperHackers @tweak Only send this message when objects are currently selected. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "were previously selected". They are no longer selected now. |
||
| if (!emptySelectedDrawables) | ||
| { | ||
| // TheSuperHackers @tweak Originally this message had one boolean argument, but it wasn't used for anything. | ||
| TheMessageStream->appendMessage(GameMessage::MSG_DESTROY_SELECTED_GROUP); | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -5888,7 +5887,7 @@ void InGameUI::selectNextIdleWorker() | |
| if(selectThisObject) | ||
| { | ||
| DEBUG_ASSERTCRASH(selectThisObject->getContainedBy() == nullptr, ("InGameUI::selectNextIdleWorker Selected idle object should not be contained")); | ||
| deselectAllDrawables(); | ||
| deselectAllDrawables(FALSE); | ||
| GameMessage *teamMsg = TheMessageStream->appendMessage( GameMessage::MSG_CREATE_SELECTED_GROUP ); | ||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -216,18 +216,6 @@ static Bool canSelectWrapper( Drawable *draw, void *userData ) | |
| return CanSelectDrawable( draw, dragSelecting ); | ||
| } | ||
|
|
||
| //----------------------------------------------------------------------------- | ||
| /** | ||
| * Deselect all drawables, and emit a "TEAM_DESTROY" message, since | ||
| * the "team" was the group of currently selected units. | ||
| */ | ||
| static void deselectAll() | ||
| { | ||
|
|
||
| // deselect it all | ||
| TheInGameUI->deselectAllDrawables(); | ||
| } | ||
|
|
||
| //----------------------------------------------------------------------------- | ||
| /** | ||
| * Select the given drawable, without playing its sound. | ||
|
|
@@ -237,7 +225,7 @@ static Bool selectSingleDrawableWithoutSound( Drawable *draw ) | |
| { | ||
|
|
||
| // since we are single selecting a drawable, unselect everything else | ||
| deselectAll(); | ||
| TheInGameUI->deselectAllDrawables(); | ||
|
|
||
| // do the drawable selection | ||
| TheInGameUI->selectDrawable( draw ); | ||
|
|
@@ -261,6 +249,7 @@ SelectionTranslator *TheSelectionTranslator = nullptr; | |
| //----------------------------------------------------------------------------- | ||
| SelectionTranslator::SelectionTranslator() | ||
| { | ||
| m_pendingDeselection = FALSE; | ||
| m_leftMouseButtonIsDown = FALSE; | ||
| m_dragSelecting = FALSE; | ||
| m_lastGroupSelTime = 0; | ||
|
|
@@ -750,7 +739,8 @@ GameMessageDisposition SelectionTranslator::translateGameMessage(const GameMessa | |
| { | ||
| if (!addToGroup) | ||
| { | ||
| deselectAll(); | ||
|
Caball009 marked this conversation as resolved.
|
||
| m_pendingDeselection = FALSE; | ||
| TheInGameUI->deselectAllDrawables(FALSE); | ||
| } | ||
|
|
||
| GameMessage *newMsg = TheMessageStream->appendMessage(GameMessage::MSG_CREATE_SELECTED_GROUP); | ||
|
|
@@ -951,7 +941,7 @@ GameMessageDisposition SelectionTranslator::translateGameMessage(const GameMessa | |
| { | ||
| if( !TheInGameUI->getPreventLeftClickDeselectionInAlternateMouseModeForOneClick() ) | ||
| { | ||
| deselectAll(); | ||
| m_pendingDeselection = TRUE; | ||
| m_lastGroupSelGroup = -1; | ||
| } | ||
| else | ||
|
|
@@ -1018,7 +1008,7 @@ GameMessageDisposition SelectionTranslator::translateGameMessage(const GameMessa | |
| else if (!TheGlobalData->m_useAlternateMouse) | ||
| { | ||
| //No GUI command mode, so deselect everyone if we're in regular mouse mode. | ||
| deselectAll(); | ||
| TheInGameUI->deselectAllDrawables(); | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -1330,6 +1320,14 @@ GameMessageDisposition SelectionTranslator::translateGameMessage(const GameMessa | |
| #endif | ||
| } | ||
|
|
||
| // TheSuperHackers @tweak Avoid double deselection when selecting a new object with another object selected, | ||
| // originally triggered by RAW_MOUSE_LEFT_BUTTON_UP and MOUSE_LEFT_CLICK, respectively. | ||
| if (msg->getType() == GameMessage::MSG_MOUSE_LEFT_CLICK && m_pendingDeselection) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe it is not worth it to go through all this additional logic and new complexity just to save one small network message?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's worth it if there are no gameplay issues. This small message is the most frequently used network message currently, probably by a large margin. At a quick glance it takes >20 bytes of data across the network for this particular message. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How much data is then saved across a full match? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not quite understand this condition.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
So I checked the Golden Replay 1 and counted some messages.
For replays this message is currently 13 bytes (now that the unused argument is removed). With the number above it comes down 131807 bytes, so roughly 128KB. For perspective, the replay size is 1.23MB. What's curious is that the game appears to write the frame for every message, and uses 4 bytes for the player index instead of 1. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this be moved into a switch case? |
||
| { | ||
| m_pendingDeselection = FALSE; | ||
| TheInGameUI->deselectAllDrawables(); | ||
| } | ||
|
|
||
| return disp; | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.