Skip to content

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

Merged
xezon merged 8 commits intoTheSuperHackers:mainfrom
Caball009:tweak_msg_area_selection
May 3, 2026
Merged

tweak(gamemessage): Remove unused MSG_AREA_SELECTION message from game logic#2667
xezon merged 8 commits intoTheSuperHackers:mainfrom
Caball009:tweak_msg_area_selection

Conversation

@Caball009
Copy link
Copy Markdown

@Caball009 Caball009 commented Apr 30, 2026

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 prevents MSG_AREA_SELECTION from propagating to the network by splitting it into two new hint-only messages (MSG_BEGIN_AREA_SELECTION_HINT / MSG_END_AREA_SELECTION_HINT) that are destroyed by HintSpy before reaching the network layer. The network message enum safety is preserved by the existing MSG_BEGIN_NETWORK_MESSAGES = 1000 fixed-value anchor, so replay and network serialization are unaffected. Changes are mirrored correctly across both Generals/ and GeneralsMD/.

Confidence Score: 5/5

Safe to merge — the enum anchoring at 1000 protects replay/network compatibility, selection logic is unaffected, and cross-version testing was performed.

Only a P2 style finding (tab/space alignment) exists. The design correctly relies on the fixed-value network enum anchor to avoid any binary compatibility concerns. All sites are updated consistently in both Generals and GeneralsMD.

No files require special attention.

Important Files Changed

Filename Overview
Generals/Code/GameEngine/Include/Common/MessageStream.h Splits MSG_AREA_SELECTION_HINT into MSG_BEGIN/END_AREA_SELECTION_HINT (hints section) and renames MSG_AREA_SELECTION to MSG_AREA_SELECTION_DEPRECATED (network section). Network enum safety preserved by fixed-value anchor at 1000. Minor tab/space alignment inconsistency on new lines.
GeneralsMD/Code/GameEngine/Include/Common/MessageStream.h Mirror of Generals header changes. Same alignment inconsistency on new enum entries.
Generals/Code/GameEngine/Source/GameClient/MessageStream/HintSpy.cpp Updates case handlers to MSG_BEGIN/END_AREA_SELECTION_HINT and correctly adds DESTROY_MESSAGE to both, preventing hint messages from propagating to the network layer. Comment updated to reflect new naming.
GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/HintSpy.cpp Mirror of Generals HintSpy changes — correct and clean.
Generals/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp Replaces all MSG_AREA_SELECTION_HINT emissions with MSG_BEGIN_AREA_SELECTION_HINT and MSG_AREA_SELECTION emissions with MSG_END_AREA_SELECTION_HINT. Selection logic completes before messages are appended, so DESTROY_MESSAGE in HintSpy is safe.
GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp Mirror of Generals SelectionXlat changes — correct and clean.
Generals/Code/GameEngine/Source/Common/MessageStream.cpp Updates getCommandTypeAsString to reflect new enum names — straightforward and correct.
GeneralsMD/Code/GameEngine/Source/Common/MessageStream.cpp Mirror of Generals MessageStream.cpp changes — straightforward and correct.

Sequence Diagram

sequenceDiagram
    participant User as Mouse Input
    participant SX as SelectionXlat
    participant HS as HintSpy
    participant UI as InGameUI
    participant Net as Network Layer

    Note over SX,Net: During drag (mouse move)
    User->>SX: Mouse drag event
    SX->>SX: appendMessage(MSG_BEGIN_AREA_SELECTION_HINT)
    SX->>HS: MSG_BEGIN_AREA_SELECTION_HINT
    HS->>UI: beginAreaSelectHint()
    HS-->>Net: DESTROY_MESSAGE (never reaches network)

    Note over SX,Net: On mouse release (area confirmed)
    User->>SX: Mouse up event
    SX->>SX: Perform selection logic
    SX->>SX: appendMessage(MSG_END_AREA_SELECTION_HINT)
    SX->>HS: MSG_END_AREA_SELECTION_HINT
    HS->>UI: endAreaSelectHint()
    HS-->>Net: DESTROY_MESSAGE (never reaches network)

    Note over Net: MSG_AREA_SELECTION_DEPRECATED remains in enum (value ge 1000) but is never emitted
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
Generals/Code/GameEngine/Include/Common/MessageStream.h:419
**Inconsistent whitespace alignment in new enum entries**

The two new lines use spaces for column-alignment instead of tabs, breaking consistency with surrounding entries. `MSG_END_AREA_SELECTION_HINT` uses 4 spaces before `///<` while every other entry in this block uses a tab. Similarly, `MSG_AREA_SELECTION_DEPRECATED` uses spaces. The same pattern appears in `GeneralsMD/Code/GameEngine/Include/Common/MessageStream.h`.

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

Comment thread GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/HintSpy.cpp Outdated
Comment thread GeneralsMD/Code/GameEngine/Include/Common/MessageStream.h Outdated
@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.

Comment thread GeneralsMD/Code/GameEngine/Include/Common/MessageStream.h Outdated
Comment thread GeneralsMD/Code/GameEngine/Include/Common/MessageStream.h Outdated
Comment thread GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/HintSpy.cpp Outdated
@Caball009
Copy link
Copy Markdown
Author

Replicated in Generals.

@xezon xezon merged commit adc77cc into TheSuperHackers:main May 3, 2026
17 checks passed
@Caball009 Caball009 deleted the tweak_msg_area_selection branch May 3, 2026 17:49
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