Skip to content

unify(selectionxlat): Merge SelectionXlat#2792

Open
xezon wants to merge 3 commits into
TheSuperHackers:mainfrom
xezon:xezon/unify-selectionxlat
Open

unify(selectionxlat): Merge SelectionXlat#2792
xezon wants to merge 3 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 the SelectionXlat translator from Zero Hour into Generals, porting drag/group selection fixes for AmericaBuildingFireBase and Alternate Mouse mode, and extending HandOfGodSelectionMode to _ALLOW_DEBUG_CHEATS_IN_RELEASE builds. It also ports a large block of CommandXlat changes that replace GUI_COMMAND_SPECIAL_POWER_FROM_COMMAND_CENTER with a generalized shortcut special power system and add double-click attack-move, sabotage building support, and several debug tools.

  • SelectionXlat (Generals): TheHandOfGodSelectionMode static is converted to m_HandOfGodSelectionMode member; new AmericaBuildingFireBase drag-select logic iterates riders to decide whether a lone building in a drag box is selectable; Alternate Mouse deselect now resets m_lastGroupSelGroup.
  • CommandXlat (Generals): GUI_COMMAND_SPECIAL_POWER_FROM_SHORTCUT replaces the old command-center enum; new GUI_COMMAND_SPECIAL_POWER_CONSTRUCT_FROM_SHORTCUT and GUICOMMANDMODE_SABOTAGE_BUILDING paths added; double-click right/left attack-move guard order added for both mouse modes; MSG_ADD_CASH and MSG_TOGGLE_HAND_OF_GOD_MODE guarded against multiplayer.
  • Zero Hour: The duplicate _ALLOW_DEBUG_CHEATS_IN_RELEASE block in SelectionXlat is removed now that the logic is unified via the shared member.

Confidence Score: 3/5

The selection and debug-mode changes are low risk, but the new evaluateContextCommand branch for construct-type shortcut special powers is broken by mismatched case labels and will never fire.

The switch inside the new GUI_COMMAND_SPECIAL_POWER_CONSTRUCT_FROM_SHORTCUT branch references GUI_COMMAND_SPECIAL_POWER_FROM_SHORTCUT and GUI_COMMAND_SPECIAL_POWER — values that can never be reached at that point. Any shortcut special power that uses the construction placement interface will silently skip issuing the command, making the feature non-functional until fixed.

Generals/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp — the new else if block at lines 1788–1811 needs corrected case labels before this feature can work.

Important Files Changed

Filename Overview
Generals/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp Large port of shortcut special power system, double-click attack-move, sabotage building support, and debug tooling; contains a switch/case label mismatch that makes the CONSTRUCT_FROM_SHORTCUT path dead code.
Generals/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp Merges drag/group selection fixes and HandOfGodSelectionMode (now a member variable) from Zero Hour; adds AmericaBuildingFireBase drag-select logic and alternate mouse group-state reset.
Generals/Code/GameEngine/Include/GameClient/SelectionXlat.h Adds m_HandOfGodSelectionMode as a public member guarded by debug/release macros; encapsulation concern since the member is directly writable by any includer.
Generals/Code/GameEngine/Source/GameClient/InGameUI.cpp Adds double-click attack-move guard hint (radius cursor animation with a countdown timer) and a triggerDoubleClickAttackMoveGuardHint helper; changes are self-contained.
Generals/Code/GameEngine/Source/GameLogic/Object/Contain/OpenContain.cpp Adds getClosestRider() helper used by the new AmericaBuildingFireBase force-attack logic; straightforward distance iteration over the contain list.
GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp Zero Hour side simplified: removes the duplicate _ALLOW_DEBUG_CHEATS_IN_RELEASE block that was redundant now that HandOfGodSelectionMode is a shared member; cleans up stale preprocessor nesting.
GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp Minor rename of GUI_COMMAND_SPECIAL_POWER_FROM_COMMAND_CENTER to GUI_COMMAND_SPECIAL_POWER_FROM_SHORTCUT (alias kept) and whitespace cleanup.
Generals/Code/GameEngine/Include/GameClient/InGameUI.h Adds ACTIONTYPE_SABOTAGE_BUILDING, camera tracking drawable helpers, double-click hint timer members, and triggerDoubleClickAttackMoveGuardHint declaration.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[evaluateContextCommand called] --> B{areSelectedObjectsControllable or FROM_SHORTCUT command?}
    B -- Yes --> C{isContextCommand or SPECIAL_POWER or FROM_SHORTCUT?}
    C -- Yes --> D{GUICOMMANDMODE switch}
    D --> E[FROM_SHORTCUT: findMostReadyShortcutSpecialPower → issueSpecialPowerCommand]
    D --> F[SABOTAGE_BUILDING: canSelectedObjectsDoAction]
    D --> G[HIJACK/CARBOMB: createEnterMessage]
    C -- No --> H{SPECIAL_POWER_CONSTRUCT or CONSTRUCT_FROM_SHORTCUT?}
    H -- Yes, DO_COMMAND --> I{inner switch on getCommandType}
    I --> J[case CONSTRUCT_FROM_SHORTCUT was FROM_SHORTCUT - BROKEN: findMostReady → issueSpecialPowerCommand]
    I --> K[case CONSTRUCT was SPECIAL_POWER - BROKEN: issueSpecialPowerCommand nullptr]
    H -- No --> L{canSelectedObjectsOverrideSpecialPowerDestination?}
    L -- Yes --> M[MSG_DO_SPECIAL_POWER_OVERRIDE_DESTINATION]
    L -- No --> N[canSelectedObjectsDoAction SABOTAGE_BUILDING?]
    N -- Yes --> O[createEnterMessage / MSG_SABOTAGE_HINT]
    style J fill:#ffcccc
    style K fill:#ffcccc
Loading
Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 2
Generals/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp:1797-1809
Unreachable switch cases: the surrounding `else if` only runs when `getCommandType()` is `GUI_COMMAND_SPECIAL_POWER_CONSTRUCT` (212) or `GUI_COMMAND_SPECIAL_POWER_CONSTRUCT_FROM_SHORTCUT` (213), but the two `case` labels inside check `GUI_COMMAND_SPECIAL_POWER_FROM_SHORTCUT` (208) and `GUI_COMMAND_SPECIAL_POWER` (187). Neither value can ever match here, so `issueSpecialPowerCommand` is never called — the shortcut-construct special power silently does nothing on every placement click.

```suggestion
				switch( command->getCommandType() )
				{
					case GUI_COMMAND_SPECIAL_POWER_CONSTRUCT_FROM_SHORTCUT:
					{
						Object* unit = ThePlayerList->getLocalPlayer()->findMostReadyShortcutSpecialPowerOfType( command->getSpecialPowerTemplate()->getSpecialPowerType() );
						if( unit )
							msgType = issueSpecialPowerCommand( command, type, draw, pos, unit );
						break;
					}
					case GUI_COMMAND_SPECIAL_POWER_CONSTRUCT://lorenzen
						msgType = issueSpecialPowerCommand( command, type, draw, pos, nullptr );
						break;
				}
```

### Issue 2 of 2
Generals/Code/GameEngine/Include/GameClient/SelectionXlat.h:70-73
`m_HandOfGodSelectionMode` is exposed as a public data member, so any translation unit that includes this header can write to it directly without going through the toggle logic in `translateGameMessage`. The accessor `isHandOfGodSelectionMode()` is already there for read access; the member itself should be `private` to protect the invariant.

```suggestion
#if defined(RTS_DEBUG) || defined(_ALLOW_DEBUG_CHEATS_IN_RELEASE)
  Bool isHandOfGodSelectionMode() { return m_HandOfGodSelectionMode; };
private:
  Bool m_HandOfGodSelectionMode;
public:
#endif
```

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

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.

1 participant