unify: Parse template references in the AssistedTargetingUpdate module by name#2809
Conversation
|
| Filename | Overview |
|---|---|
| Generals/Code/GameEngine/Include/GameLogic/Module/AssistedTargetingUpdate.h | Moves ThingTemplate pointers from ModuleData to the instance class and adds AsciiString name fields; new fields use spaces instead of tabs, inconsistent with the rest of the file. |
| Generals/Code/GameEngine/Source/GameLogic/Object/Update/AssistedTargetingUpdate.cpp | Switches INI parsing to AsciiString, initialises pointers in the constructor, and resolves templates by name in both update() and loadPostProcess(); logic is correct and mirrors the Zero Hour implementation. |
| GeneralsMD/Code/GameEngine/Include/GameLogic/Module/AssistedTargetingUpdate.h | Trivial whitespace-only change (removes two trailing blank lines); no functional change. |
| GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AssistedTargetingUpdate.cpp | Fixes the previous copy-paste bug in both update() and loadPostProcess() where m_laserToTarget was incorrectly resolved from m_laserFromAssistedName; both lookups now use the correct name fields. |
Sequence Diagram
%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant INI as INI Parser
participant MD as AssistedTargetingUpdateModuleData
participant ATU as AssistedTargetingUpdate
participant TF as TheThingFactory
INI->>MD: parseAsciiString to m_laserFromAssistedName
INI->>MD: parseAsciiString to m_laserToTargetName
Note over ATU: Constructor
ATU->>ATU: "m_laserFromAssisted = nullptr"
ATU->>ATU: "m_laserToTarget = nullptr"
Note over ATU: First update() tick
ATU->>TF: findTemplate(m_laserFromAssistedName)
TF-->>ATU: m_laserFromAssisted
ATU->>TF: findTemplate(m_laserToTargetName)
TF-->>ATU: m_laserToTarget
ATU-->>ATU: return UPDATE_SLEEP_FOREVER
Note over ATU: On save/load
ATU->>TF: findTemplate(m_laserFromAssistedName)
TF-->>ATU: m_laserFromAssisted
ATU->>TF: findTemplate(m_laserToTargetName)
TF-->>ATU: m_laserToTarget
Note over ATU: assistAttack()
ATU->>ATU: makeFeedbackLaser(m_laserFromAssisted)
ATU->>ATU: makeFeedbackLaser(m_laserToTarget)
%%{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"}}}%%
sequenceDiagram
participant INI as INI Parser
participant MD as AssistedTargetingUpdateModuleData
participant ATU as AssistedTargetingUpdate
participant TF as TheThingFactory
INI->>MD: parseAsciiString to m_laserFromAssistedName
INI->>MD: parseAsciiString to m_laserToTargetName
Note over ATU: Constructor
ATU->>ATU: "m_laserFromAssisted = nullptr"
ATU->>ATU: "m_laserToTarget = nullptr"
Note over ATU: First update() tick
ATU->>TF: findTemplate(m_laserFromAssistedName)
TF-->>ATU: m_laserFromAssisted
ATU->>TF: findTemplate(m_laserToTargetName)
TF-->>ATU: m_laserToTarget
ATU-->>ATU: return UPDATE_SLEEP_FOREVER
Note over ATU: On save/load
ATU->>TF: findTemplate(m_laserFromAssistedName)
TF-->>ATU: m_laserFromAssisted
ATU->>TF: findTemplate(m_laserToTargetName)
TF-->>ATU: m_laserToTarget
Note over ATU: assistAttack()
ATU->>ATU: makeFeedbackLaser(m_laserFromAssisted)
ATU->>ATU: makeFeedbackLaser(m_laserToTarget)
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/Include/GameLogic/Module/AssistedTargetingUpdate.h:42-51
Mixed indentation in the new fields: the two `AsciiString` members use 2-space indentation while every other member in the class uses a tab, and the constructor initializers use 4-space indentation while the existing initializers use two tabs. This creates visible inconsistency in the same file.
```suggestion
AsciiString m_laserFromAssistedName;
AsciiString m_laserToTargetName;
AssistedTargetingUpdateModuleData()
{
m_clipSize = 1;
m_weaponSlot = PRIMARY_WEAPON;
m_laserFromAssistedName.clear();
m_laserToTargetName.clear();
}
```
### Issue 2 of 2
Generals/Code/GameEngine/Source/GameLogic/Object/Update/AssistedTargetingUpdate.cpp:140-148
Same indentation inconsistency in `update()` and `loadPostProcess()`: the `const AssistedTargetingUpdateModuleData *d` line uses 2-space indentation while all other statements in the function body use tabs. This matches the GeneralsMD copy, but is still inconsistent with the rest of the file.
```suggestion
UpdateSleepTime AssistedTargetingUpdate::update()
{
const AssistedTargetingUpdateModuleData *d = getAssistedTargetingUpdateModuleData();
m_laserFromAssisted = TheThingFactory->findTemplate( d->m_laserFromAssistedName );
m_laserToTarget = TheThingFactory->findTemplate( d->m_laserToTargetName );
return UPDATE_SLEEP_FOREVER;
}
```
Reviews (2): Last reviewed commit: "unity: Init instance members" | Re-trigger Greptile
7913420 to
13b1161
Compare
8e0db49 to
818dfe9
Compare
|
Greptile encountered an error while reviewing this PR. Please reach out to support@greptile.com for assistance. |
This change improves the way in which the
AssistedTargetingUpdatemodule parses template reference fields in Generals by standardising the logic with Zero Hour.As a result, the respective objects can be defined in any order, whereas previously e.g. the
PatriotBinaryDataStreamwould have to be defined before any reference within anAssistedTargetingUpdatemodule (otherwise theLaserFromAssistedandLaserToTargetfields would be left unassigned).This change also corrects an inconsequential copy-and-paste error where the
LaserToTargetwas always assigned to theLaserFromAssistedvalue.Before
✅ Valid
❌ Invalid
After
✅ Valid
✅ Valid