Skip to content

unify(update): Parse template references in the AssistedTargetingUpdate module by name#2809

Open
Stubbjax wants to merge 4 commits into
TheSuperHackers:mainfrom
Stubbjax:unify-assisted-targeting-update-module-template-parsing
Open

unify(update): Parse template references in the AssistedTargetingUpdate module by name#2809
Stubbjax wants to merge 4 commits into
TheSuperHackers:mainfrom
Stubbjax:unify-assisted-targeting-update-module-template-parsing

Conversation

@Stubbjax

@Stubbjax Stubbjax commented Jun 19, 2026

Copy link
Copy Markdown

This change improves the way in which the AssistedTargetingUpdate module 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 PatriotBinaryDataStream would have to be defined before any reference within an AssistedTargetingUpdate module (otherwise the LaserFromAssisted and LaserToTarget fields would be left unassigned).

Before

✅ Valid

Object PatriotBinaryDataStream
  ; ...
End

Object AmericaPatriotBattery
  Behavior = AssistedTargetingUpdate ModuleTag_XX
    LaserFromAssisted = PatriotBinaryDataStream
    LaserToTarget = PatriotBinaryDataStream
  End
End

❌ Invalid

Object AmericaPatriotBattery
  Behavior = AssistedTargetingUpdate ModuleTag_XX
    LaserFromAssisted = PatriotBinaryDataStream
    LaserToTarget = PatriotBinaryDataStream
  End
End

Object PatriotBinaryDataStream
  ; ...
End

After

✅ Valid

Object PatriotBinaryDataStream
  ; ...
End

Object AmericaPatriotBattery
  Behavior = AssistedTargetingUpdate ModuleTag_XX
    LaserFromAssisted = PatriotBinaryDataStream
    LaserToTarget = PatriotBinaryDataStream
  End
End

✅ Valid

Object AmericaPatriotBattery
  Behavior = AssistedTargetingUpdate ModuleTag_XX
    LaserFromAssisted = PatriotBinaryDataStream
    LaserToTarget = PatriotBinaryDataStream
  End
End

Object PatriotBinaryDataStream
  ; ...
End

@Stubbjax Stubbjax self-assigned this Jun 19, 2026
@Stubbjax Stubbjax added Gen Relates to Generals Fix Is fixing something, but is not user facing Unify Unifies code between Generals and Zero Hour labels Jun 19, 2026
@greptile-apps

greptile-apps Bot commented Jun 19, 2026

Copy link
Copy Markdown

Greptile Summary

This PR ports the Zero Hour (GeneralsMD) pattern of storing INI template references as name strings (AsciiString) to the vanilla Generals version of AssistedTargetingUpdate, deferring pointer resolution until after all objects are loaded. It also cleans up formatting (mixed indentation) in both codebases.

  • Generals: m_laserFromAssisted/m_laserToTarget are moved from AssistedTargetingUpdateModuleData (parse-time pointers) to AssistedTargetingUpdate instance members, resolved lazily in update() (first tick) and in loadPostProcess() for save-game loading. Constructor now initialises both pointers to nullptr.
  • GeneralsMD: Indentation and whitespace cleanup only; logic was already correct from a prior version.
  • All three P0 bugs flagged in the previous review (uninitialized members, copy-paste name mixup, missing resolution) are addressed in this revision.

Confidence Score: 5/5

Safe to merge. The change is logically correct, consistent between both game codebases, and all issues from the previous review have been resolved.

The refactoring is well-contained: name-to-pointer resolution is now deferred to update() (first tick) and loadPostProcess() (save-load path), exactly mirroring the pre-existing Zero Hour pattern. Both instance members are initialised to nullptr in the constructor, both use the correct name fields independently, and the assistAttack path guards each pointer before use. No unresolved bugs remain.

No files require special attention.

Important Files Changed

Filename Overview
Generals/Code/GameEngine/Include/GameLogic/Module/AssistedTargetingUpdate.h Moves laser template pointers from ModuleData to AssistedTargetingUpdate instance; introduces AsciiString name fields in ModuleData. Constructor initialisation fix included.
Generals/Code/GameEngine/Source/GameLogic/Object/Update/AssistedTargetingUpdate.cpp Replaces INI::parseThingTemplate with INI::parseAsciiString; adds nullptr initialisation in constructor; resolves names to pointers in update() and loadPostProcess(). All previously flagged P0 bugs are addressed.
GeneralsMD/Code/GameEngine/Include/GameLogic/Module/AssistedTargetingUpdate.h Indentation cleanup (spaces→tabs) and removal of redundant AsciiString::clear() calls in constructor; no logic changes.
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AssistedTargetingUpdate.cpp Indentation cleanup and setPosition reorder (moved after LaserUpdate null-check, before initLaser — safe). Copy-paste bugs from previous review are fixed; both template names now resolve to their correct pointers.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant INI as INI Parser
    participant MD as ModuleData
    participant ATU as AssistedTargetingUpdate
    participant TF as TheThingFactory

    INI->>MD: parseAsciiString to m_laserFromAssistedName
    INI->>MD: parseAsciiString to m_laserToTargetName
    INI->>ATU: construct
    ATU->>ATU: "m_laserFromAssisted = nullptr"
    ATU->>ATU: "m_laserToTarget = nullptr"
    ATU->>ATU: update() on first tick
    ATU->>TF: findTemplate(m_laserFromAssistedName)
    TF-->>ATU: ThingTemplate ptr
    ATU->>TF: findTemplate(m_laserToTargetName)
    TF-->>ATU: ThingTemplate ptr
    ATU-->>ATU: return UPDATE_SLEEP_FOREVER
    ATU->>ATU: assistAttack called
    ATU->>ATU: makeFeedbackLaser if ptr set
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"}}}%%
sequenceDiagram
    participant INI as INI Parser
    participant MD as ModuleData
    participant ATU as AssistedTargetingUpdate
    participant TF as TheThingFactory

    INI->>MD: parseAsciiString to m_laserFromAssistedName
    INI->>MD: parseAsciiString to m_laserToTargetName
    INI->>ATU: construct
    ATU->>ATU: "m_laserFromAssisted = nullptr"
    ATU->>ATU: "m_laserToTarget = nullptr"
    ATU->>ATU: update() on first tick
    ATU->>TF: findTemplate(m_laserFromAssistedName)
    TF-->>ATU: ThingTemplate ptr
    ATU->>TF: findTemplate(m_laserToTargetName)
    TF-->>ATU: ThingTemplate ptr
    ATU-->>ATU: return UPDATE_SLEEP_FOREVER
    ATU->>ATU: assistAttack called
    ATU->>ATU: makeFeedbackLaser if ptr set
Loading

Reviews (4): Last reviewed commit: "refactor: Further reduce class divergenc..." | Re-trigger Greptile

@Stubbjax Stubbjax force-pushed the unify-assisted-targeting-update-module-template-parsing branch 2 times, most recently from 8e0db49 to 818dfe9 Compare June 19, 2026 07:43
Comment thread Generals/Code/GameEngine/Include/GameLogic/Module/AssistedTargetingUpdate.h Outdated
@Stubbjax Stubbjax added ZH Relates to Zero Hour Refactor Edits the code with insignificant behavior changes, is never user facing labels Jun 19, 2026

@xezon xezon left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest split merge from the other fix.

@Stubbjax Stubbjax marked this pull request as draft June 21, 2026 01:47
@Stubbjax Stubbjax force-pushed the unify-assisted-targeting-update-module-template-parsing branch from 720da12 to c603a48 Compare June 22, 2026 01:04
@Stubbjax Stubbjax marked this pull request as ready for review June 22, 2026 01:04
Comment thread Generals/Code/GameEngine/Include/GameLogic/Module/AssistedTargetingUpdate.h Outdated
@Stubbjax Stubbjax force-pushed the unify-assisted-targeting-update-module-template-parsing branch from c603a48 to 5791c2a Compare June 22, 2026 17:07
@xezon xezon changed the title unify: Parse template references in the AssistedTargetingUpdate module by name unify(update): Parse template references in the AssistedTargetingUpdate module by name Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Fix Is fixing something, but is not user facing Gen Relates to Generals Refactor Edits the code with insignificant behavior changes, is never user facing 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.

3 participants