unify(selectionxlat): Merge SelectionXlat#2792
Conversation
|
| 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
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
The change is a follow up for #2765 and merges SelectionXlat (see last commit)
Generals gets
Zero Hour gets