Skip to content

refactor(view): Simplify code to set location for Replay Camera#2353

Merged
xezon merged 2 commits into
TheSuperHackers:mainfrom
xezon:xezon/refactor-replay-player-cam-setlocation
Feb 26, 2026
Merged

refactor(view): Simplify code to set location for Replay Camera#2353
xezon merged 2 commits into
TheSuperHackers:mainfrom
xezon:xezon/refactor-replay-player-cam-setlocation

Conversation

@xezon

@xezon xezon commented Feb 25, 2026

Copy link
Copy Markdown

This change simplifies the code to set the location for the Replay Camera.

Note that the Replay Camera currently does not work, which will be fixed soon.

To test the Replay Camera, the following line needs to be commented:

TheTacticalView->lockViewUntilFrame( getFrame() + 1 );

TODO

  • Replicate in Generals

@xezon xezon added Minor Severity: Minor < Major < Critical < Blocker Gen Relates to Generals ZH Relates to Zero Hour Refactor Edits the code with insignificant behavior changes, is never user facing labels Feb 25, 2026
@greptile-apps

greptile-apps Bot commented Feb 25, 2026

Copy link
Copy Markdown

Greptile Summary

This PR simplifies the replay camera location-setting code by replacing the intermediate ViewLocation object and its init/setLocation round-trip with direct calls to setPosition, setAngle, setPitch, and setZoom on TheTacticalView. The change is applied to both the Generals and GeneralsMD variants of GameLogicDispatch.cpp.

In View.h, setPosition is promoted from protected to public (necessary for the new call sites), getPosition(Coord3D*) drops its virtual keyword (no subclass overrides it), whitespace is cleaned up, and the ViewLocation constructor initializers are corrected from 0.0 (double) to 0.0f (float) to match the Real (float) type.

  • The behavioral difference from bypassing View::setLocation (which calls forceRedraw()) has already been discussed and confirmed acceptable by a senior developer in a prior thread.
  • No subclass overrides getPosition(Coord3D*) or setPosition, so removing virtual and changing visibility is safe.
  • Local variables are now const-qualified, improving clarity.

Confidence Score: 4/5

  • This PR is safe to merge — it's a straightforward refactor with no functional risk beyond the already-discussed forceRedraw() omission.
  • Score of 4 reflects a clean, well-scoped refactor. The only behavioral change (skipping forceRedraw) has been acknowledged and confirmed acceptable. No subclass overrides are broken by the virtual/visibility changes. The replay camera feature is noted as not yet working, so the risk surface is minimal. Deducted one point because the feature is not yet testable end-to-end.
  • No files require special attention.

Important Files Changed

Filename Overview
Core/GameEngine/Include/GameClient/View.h Moves setPosition from protected to public, removes virtual from getPosition(Coord3D*), cleans up whitespace, and initializes ViewLocation members with 0.0f instead of 0.0.
Generals/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp Replaces ViewLocation intermediate object with direct calls to setPosition, setAngle, setPitch, setZoom on the tactical view. Adds const qualifiers to local variables.
GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp Same simplification as the Generals variant — replaces ViewLocation with direct camera property setters. Identical change pattern.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[MSG_SET_REPLAY_CAMERA received] --> B{isPlaybackMode &\nuseCameraInReplay &\nobserverMatch?}
    B -- No --> Z[Skip]
    B -- Yes --> C{isCameraMovementFinished?}
    C -- No --> Z
    C -- Yes --> D[Extract pos, angle, pitch, zoom from message]

    subgraph Before[Before - Using ViewLocation]
        D1[Create ViewLocation] --> D2["loc.init(pos, angle, pitch, zoom)"]
        D2 --> D3["setLocation(&loc)"]
        D3 --> D4["Internally calls setPosition, setAngle, setPitch, setZoom, forceRedraw"]
    end

    subgraph After[After - Direct Calls]
        E1["setPosition(&pos)"] --> E2["setAngle(angle)"]
        E2 --> E3["setPitch(pitch)"]
        E3 --> E4["setZoom(zoom)"]
    end

    D --> After
    E4 --> F["lockViewUntilFrame(frame + 1)"]
Loading

Last reviewed commit: 64f8d56

@greptile-apps greptile-apps Bot 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.

2 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@Mauller Mauller 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.

looks okay

@xezon

xezon commented Feb 26, 2026

Copy link
Copy Markdown
Author

Replicated in Generals without conflicts.

@xezon xezon merged commit cf96141 into TheSuperHackers:main Feb 26, 2026
25 checks passed
@xezon xezon deleted the xezon/refactor-replay-player-cam-setlocation branch February 26, 2026 18:48
@xezon xezon added this to the Camera Rework milestone Feb 26, 2026
Okladnoj pushed a commit to Okladnoj/GeneralsGameCode that referenced this pull request Mar 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Gen Relates to Generals Minor Severity: Minor < Major < Critical < Blocker Refactor Edits the code with insignificant behavior changes, is never user facing ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants