Skip to content

unify(selectionxlat): Merge SelectionXlat#2792

Merged
xezon merged 2 commits into
TheSuperHackers:mainfrom
xezon:xezon/unify-selectionxlat
Jun 18, 2026
Merged

unify(selectionxlat): Merge SelectionXlat#2792
xezon merged 2 commits into
TheSuperHackers:mainfrom
xezon:xezon/unify-selectionxlat

Conversation

@xezon

@xezon xezon commented Jun 14, 2026

Copy link
Copy Markdown

The change is a follow up for #2765 and merges SelectionXlat (see last commit)

Generals gets

  • Drag selection fix for AmericaBuildingFireBase
  • Group selection fix for Alternate Mouse
  • HandOfGodSelectionMode with _ALLOW_DEBUG_CHEATS_IN_RELEASE

Zero Hour gets

  • Simplified code for HandOfGodSelectionMode

@xezon xezon added Gen Relates to Generals ZH Relates to Zero Hour Unify Unifies code between Generals and Zero Hour labels Jun 14, 2026
@greptile-apps

greptile-apps Bot commented Jun 14, 2026

Copy link
Copy Markdown

Greptile Summary

This PR merges SelectionXlat between Generals and Zero Hour (GeneralsMD), unifying the two diverged implementations while backporting several fixes from Zero Hour to Generals.

  • Drag selection fix (Generals): Adds a new code path that detects when a drag selection contains exactly one building but mixed-in non-selectable units (e.g. contained units in AmericaBuildingFireBase), correctly reducing the result to that single building.
  • Alternate Mouse group reset fix (Generals): Adds m_lastGroupSelGroup = -1 on left-click deselect in alternate mouse mode, matching the existing behavior in Zero Hour.
  • HandOfGodSelectionMode expanded (Generals): Promotes m_HandOfGodSelectionMode from static file-scope to a class member and gates it under RTS_DEBUG || _ALLOW_DEBUG_CHEATS_IN_RELEASE, mirroring the Zero Hour implementation.
  • Zero Hour simplification: Removes the duplicate #if _ALLOW_DEBUG_CHEATS_IN_RELEASE block for HandOfGodSelectionMode in SelectionXlat.cpp, consolidating into a single #if RTS_DEBUG || _ALLOW_DEBUG_CHEATS_IN_RELEASE guard.

Confidence Score: 5/5

Safe to merge — the logic changes are well-scoped, the Generals/GeneralsMD unification is consistent, and the only finding is a style nit about a public member variable in debug-only code.

All substantive changes are guarded by preprocessor conditionals (RTS_DEBUG or _ALLOW_DEBUG_CHEATS_IN_RELEASE) and the runtime behavior differences are intentional unification with the already-shipping Zero Hour implementation. The AmericaBuildingFireBase drag-select path is additive and protected by the existing building-count guard. No correctness or data-integrity issues were found.

Generals/Code/GameEngine/Include/GameClient/SelectionXlat.h — m_HandOfGodSelectionMode is declared public; same pattern in the GeneralsMD header.

Important Files Changed

Filename Overview
Generals/Code/GameEngine/Include/GameClient/SelectionXlat.h Adds m_HandOfGodSelectionMode member and isHandOfGodSelectionMode() accessor under RTS_DEBUG
GeneralsMD/Code/GameEngine/Include/GameClient/SelectionXlat.h Removes two stray blank lines before the public: section; otherwise unchanged — m_HandOfGodSelectionMode was already present here before this PR.
Generals/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp Adds AmericaBuildingFireBase drag-select fix, alternate-mouse group reset fix, moves recordDragSelection() before single-select debug block, and promotes HandOfGodSelectionMode to _ALLOW_DEBUG_CHEATS_IN_RELEASE; code is now functionally aligned with GeneralsMD.
GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp Removes stale commented-out static variable block and simplifies the debug selection guard to a single unified #if, eliminating the duplicated _ALLOW_DEBUG_CHEATS_IN_RELEASE block.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[MSG_MOUSE_LEFT_CLICK / area selection ends] --> B{newCountMine > 0?}
    B -- No --> C[Check enemies/civilians/friends mix]
    B -- Yes --> D{newCountMineBuildings == 1\nAND newCountMine == 1?}
    D -- Yes --> E[addToGroup = FALSE\nselectMineBuildings = TRUE\none exact building clicked]
    D -- No --> F{newCountMineBuildings > 0?}
    F -- No --> G[Normal unit selection]
    F -- Yes --> H[Iterate drawablesThatWillSelect\nlooking for non-selectable units]
    H --> I{All non-building entries\nnon-selectable AND\nexactly one building ID?}
    I -- Yes --> J[addToGroup = FALSE\nselectMineBuildings = TRUE\nAmericaBuildingFireBase fix]
    I -- No --> G
    G --> K{newDrawablesSelected > 1?}
    K -- Yes --> L[recordDragSelection]
    K -- No --> M{newDrawablesSelected == 1?}
    L --> M
    M -- Yes --> N{HandOfGodSelectionMode?\nRTS_DEBUG or _ALLOW_DEBUG_CHEATS}
    N -- Yes --> O[Kill object via MSG_DEBUG_KILL_OBJECT]
    N -- No --> P{TheHurtSelectionMode?\nRTS_DEBUG only}
    P -- Yes --> Q[Hurt object via MSG_DEBUG_HURT_OBJECT]
    P -- No --> R[Normal single-select handling]
Loading
%%{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[MSG_MOUSE_LEFT_CLICK / area selection ends] --> B{newCountMine > 0?}
    B -- No --> C[Check enemies/civilians/friends mix]
    B -- Yes --> D{newCountMineBuildings == 1\nAND newCountMine == 1?}
    D -- Yes --> E[addToGroup = FALSE\nselectMineBuildings = TRUE\none exact building clicked]
    D -- No --> F{newCountMineBuildings > 0?}
    F -- No --> G[Normal unit selection]
    F -- Yes --> H[Iterate drawablesThatWillSelect\nlooking for non-selectable units]
    H --> I{All non-building entries\nnon-selectable AND\nexactly one building ID?}
    I -- Yes --> J[addToGroup = FALSE\nselectMineBuildings = TRUE\nAmericaBuildingFireBase fix]
    I -- No --> G
    G --> K{newDrawablesSelected > 1?}
    K -- Yes --> L[recordDragSelection]
    K -- No --> M{newDrawablesSelected == 1?}
    L --> M
    M -- Yes --> N{HandOfGodSelectionMode?\nRTS_DEBUG or _ALLOW_DEBUG_CHEATS}
    N -- Yes --> O[Kill object via MSG_DEBUG_KILL_OBJECT]
    N -- No --> P{TheHurtSelectionMode?\nRTS_DEBUG only}
    P -- Yes --> Q[Hurt object via MSG_DEBUG_HURT_OBJECT]
    P -- No --> R[Normal single-select handling]
Loading

Reviews (2): Last reviewed commit: "unify(selectionxlat): Merge SelectionXla..." | Re-trigger Greptile

@xezon xezon force-pushed the xezon/unify-selectionxlat branch from 52ad9e3 to 898d0ef Compare June 18, 2026 16:44
@xezon xezon merged commit 70c7f0f into TheSuperHackers:main Jun 18, 2026
17 checks passed
@xezon xezon deleted the xezon/unify-selectionxlat branch June 18, 2026 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Gen Relates to Generals Unify Unifies code between Generals and Zero Hour ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants