fix(actionmanager): Improve validation of Sneak Attack placement legality#2533
Conversation
|
| Filename | Overview |
|---|---|
| GeneralsMD/Code/GameEngine/Source/Common/RTS/ActionManager.cpp | Core anti-cheat fix: SPECIAL_SNEAK_ATTACK moved from shroud-only check to full isLocationLegalToBuild validation mirroring InGameUI:1688; bib cleanup side effect not addressed |
| GeneralsMD/Code/GameEngine/Include/Common/BuildAssistant.h | Const-correctness: builderObject parameter tightened from Object* to const Object* |
| GeneralsMD/Code/GameEngine/Source/Common/System/BuildAssistant.cpp | Const propagation: builderObject and AIUpdateInterface* now const-qualified |
| Generals/Code/GameEngine/Include/Common/BuildAssistant.h | Same const-correctness fix applied to vanilla Generals header |
| Generals/Code/GameEngine/Source/Common/System/BuildAssistant.cpp | Same const-correctness propagation applied to vanilla Generals BuildAssistant |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[canDoSpecialPowerAtLocation] --> B{mod != nullptr?}
B -- No --> Z[return false]
B -- Yes --> C[Switch 1: Terrain check\ne.g. paradrop on water]
C --> D[Switch 2: Shroud check\nfor damaging powers]
D -- other powers --> Y[return shroud/map result]
D -- SNEAK_ATTACK removed --> E[Switch 3: Building placement NEW]
E --> F{RETAIL_COMPATIBLE_CRC?}
F -- Yes --> G[Shroud-only check\nold behavior preserved]
F -- No --> H[getReferenceThingTemplate]
H -- null --> I[return FALSE]
H -- valid --> J[isLocationLegalToBuild\nUSE_QUICK_PATHFIND\nTERRAIN_RESTRICTIONS\nCLEAR_PATH\nNO_OBJECT_OVERLAP\nSHROUD_REVEALED\nIGNORE_STEALTHED\nSame flags as InGameUI:1688]
J --> K{== LBC_OK?}
K -- Yes --> L[return true]
K -- No --> M[return false]
Prompt To Fix All With AI
This is a comment left during a code review.
Path: GeneralsMD/Code/GameEngine/Source/Common/RTS/ActionManager.cpp
Line: 1605-1613
Comment:
**Missing `removeAllBibs()` cleanup after `isLocationLegalToBuild`**
`isLocationLegalToBuild` adds bib visual feedback as a documented side effect — `AIPlayer.cpp:694` notes: `// isLocationLegalToBuild adds bib feedback, turn it off. jba.` Every other call site in `AIPlayer` and `AISkirmishPlayer` follows up with `TheTerrainVisual->removeAllBibs()`. Since `canDoSpecialPowerAtLocation` runs on all clients (per the PR description), stray bibs will briefly appear on every client's screen each time a Sneak Attack placement is validated.
```suggestion
Bool const result = TheBuildAssistant->isLocationLegalToBuild(
loc, referenceThing, angle,
BuildAssistant::USE_QUICK_PATHFIND |
BuildAssistant::TERRAIN_RESTRICTIONS |
BuildAssistant::CLEAR_PATH |
BuildAssistant::NO_OBJECT_OVERLAP |
BuildAssistant::SHROUD_REVEALED |
BuildAssistant::IGNORE_STEALTHED,
obj, nullptr) == LBC_OK;
TheTerrainVisual->removeAllBibs();
return result;
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (4): Last reviewed commit: "Replicate to Generals" | Re-trigger Greptile
b6b2dfa to
8e5fd24
Compare
This PR fixes potential cheating in the placement of a Sneak Attack, where the validity of the building placement was only checked locally. This means a Sneak Attack could be placed in the fog, on top of any other building, steep mountain slope, water etc. A second check is placed that runs on all clients and mirrors the first check at
InGameUI:1688.Todo