Skip to content

tweak(gamemessage): Remove unused MSG_AREA_SELECTION message from game logic#2667

Open
Caball009 wants to merge 2 commits intoTheSuperHackers:mainfrom
Caball009:tweak_msg_area_selection
Open

tweak(gamemessage): Remove unused MSG_AREA_SELECTION message from game logic#2667
Caball009 wants to merge 2 commits intoTheSuperHackers:mainfrom
Caball009:tweak_msg_area_selection

Conversation

@Caball009
Copy link
Copy Markdown

GameMessage::MSG_AREA_SELECTION is currently passed on to the game logic (and sent to other clients), but it isn't used for anything. This PR changes that so that it isn't sent to other clients anymore.

I've tested with two local clients in multiplayer (VS22 debug builds); one had this feature and one didn't, and everything worked fine.

TODO:

  • Replicate in Generals.

@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
Copy link
Copy Markdown

greptile-apps Bot commented Apr 30, 2026

Greptile Summary

This PR reclassifies the MSG_AREA_SELECTION message from a networked game-logic message to a local-only meta message (MSG_META_AREA_SELECTION) in the GeneralsMD/ codebase, since the message was never consumed by game logic or needed by other clients. The old enum value is preserved as MSG_AREA_SELECTION_DEPRECATED (with a removal TODO) to keep network/replay ordinal compatibility intact. An equivalent change in Generals/ is tracked as a follow-up in the PR TODO.

Confidence Score: 5/5

Safe to merge; all four call sites are correctly updated and enum ordinal compatibility is preserved.

Only a P2 style finding (stale comment in HintSpy.cpp). Logic is sound: META messages are client-local, deprecated slot keeps binary layout stable, and the PR author verified this with two-client multiplayer testing.

No files require special attention.

Important Files Changed

Filename Overview
GeneralsMD/Code/GameEngine/Include/Common/MessageStream.h Adds MSG_META_AREA_SELECTION to the META (client-local) section and renames MSG_AREA_SELECTION to MSG_AREA_SELECTION_DEPRECATED to preserve enum ordinals for network/replay compatibility.
GeneralsMD/Code/GameEngine/Source/Common/MessageStream.cpp Updates getCommandTypeAsString to register the new MSG_META_AREA_SELECTION label and rename MSG_AREA_SELECTION to MSG_AREA_SELECTION_DEPRECATED.
GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/HintSpy.cpp Updates case label from MSG_AREA_SELECTION to MSG_META_AREA_SELECTION; the adjacent comment still refers to the old name.
GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp Both appendMessage call sites updated from MSG_AREA_SELECTION to MSG_META_AREA_SELECTION, correctly preventing the selection message from being forwarded to other clients.

Sequence Diagram

sequenceDiagram
    participant User
    participant SelectionXlat
    participant MessageStream
    participant HintSpy
    participant Network

    User->>SelectionXlat: drag-select / click-select
    SelectionXlat->>MessageStream: appendMessage(MSG_AREA_SELECTION_HINT)
    MessageStream->>HintSpy: MSG_AREA_SELECTION_HINT
    HintSpy->>HintSpy: beginAreaSelectHint()

    User->>SelectionXlat: release / confirm
    SelectionXlat->>MessageStream: appendMessage(MSG_META_AREA_SELECTION)
    note over MessageStream: META messages stay local
    MessageStream->>HintSpy: MSG_META_AREA_SELECTION
    HintSpy->>HintSpy: endAreaSelectHint()
    MessageStream--xNetwork: NOT forwarded (was MSG_AREA_SELECTION before)
Loading
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/HintSpy.cpp:105
**Stale comment — enum name not updated**

The comment still says `AREA_SELECTION` but the case now matches `MSG_META_AREA_SELECTION`. It's a minor inaccuracy that could confuse future readers.

```suggestion
		// An AREA_SELECTION_HINT is always followed by a MSG_META_AREA_SELECTION, so
```

Reviews (2): Last reviewed commit: "Addressed feedback." | Re-trigger Greptile

Comment thread GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/HintSpy.cpp Outdated
MSG_COMBATDROP_AT_LOCATION, ///< dump out all rappellers
MSG_COMBATDROP_AT_OBJECT, ///< dump out all rappellers

// TheSuperHackers @todo MSG_AREA_SELECTION can be moved out of the network messages because it's currently unused by the game logic.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Can it already be moved out and then a MSG_AREA_SELECTION_DEPRECATED placed here to preserve the order?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

That sounds like a good idea. I'll check it out.

Copy link
Copy Markdown
Author

@Caball009 Caball009 Apr 30, 2026

Choose a reason for hiding this comment

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

Do you have a suggestion where the non-network version should go?

EDIT:

// "meta" messages should be thought of as "virtual keystrokes" -- they exist
// solely to provide an abstraction layer useful for keyboard/mouse remapping.
// they should NEVER be sent over the network.

I suppose it fits this description, because the client uses it for the selection of the drawables and then generates the necessary GameMessages to update the selection for the game logic.

MSG_META_SELECT_HERO,                       ///< selects player's hero character, if exists...
MSG_META_SELECT_ALL,                        ///< selects all units across screen
MSG_META_SELECT_ALL_AIRCRAFT,								///< selects all air units just like select all
MSG_META_SCATTER,

Perhaps between MSG_META_SELECT_ALL_AIRCRAFT and MSG_META_SCATTER?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

There is a MSG_AREA_SELECTION_HINT outside network messages.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

That has a distinct purpose, right?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I don't know.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

It's used when you start to create an area selection by dragging the mouse. When you release the mouse button a MSG_AREA_SELECTION message is created.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why can it not be grouped together with MSG_AREA_SELECTION_HINT ?

case GameMessage::MSG_AREA_SELECTION:
case GameMessage::MSG_META_AREA_SELECTION:
TheInGameUI->endAreaSelectHint( msg );
break;
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

FYI this message is now outside the network message range, so it'll get removed eventually, and won't be sent to other clients.

@Caball009
Copy link
Copy Markdown
Author

Caball009 commented Apr 30, 2026

I could make the following changes if that's cleaner:

  1. MSG_AREA_SELECTION_HINT -> MSG_BEGIN_AREA_SELECTION_HINT
  2. MSG_AREA_SELECTION -> MSG_END_AREA_SELECTION_HINT

Copy link
Copy Markdown

@xezon xezon left a comment

Choose a reason for hiding this comment

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

The disconnect in grouping for the 2 Area select messages is confusing.


// TheSuperHackers @todo MSG_AREA_SELECTION can be moved out of the network messages because it's currently unused by the game logic.
MSG_AREA_SELECTION, ///< (pixelRegion) rectangular selection area
// TheSuperHackers @todo Remove MSG_AREA_SELECTION_DEPRECATED when possible.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Todo comment is not necessary.

Instead

MSG_AREA_SELECTION_DEPRECATED, ///< TheSuperHackers @tweak former MSG_AREA_SELECTION is deprecated as network message

MSG_COMBATDROP_AT_LOCATION, ///< dump out all rappellers
MSG_COMBATDROP_AT_OBJECT, ///< dump out all rappellers

// TheSuperHackers @todo MSG_AREA_SELECTION can be moved out of the network messages because it's currently unused by the game logic.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why can it not be grouped together with MSG_AREA_SELECTION_HINT ?

@@ -104,12 +104,8 @@ GameMessageDisposition HintSpyTranslator::translateGameMessage(const GameMessage
//-----------------------------------------------------------------------------
// An AREA_SELECTION_HINT is always followed by an AREA_SELECTION, so
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Is text up-to-date?

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