Skip to content

feat(headless): Implement ViewDummy#2246

Merged
xezon merged 10 commits intoTheSuperHackers:mainfrom
bobtista:bobtista/view-dummy
Mar 19, 2026
Merged

feat(headless): Implement ViewDummy#2246
xezon merged 10 commits intoTheSuperHackers:mainfrom
bobtista:bobtista/view-dummy

Conversation

@bobtista
Copy link

@bobtista bobtista commented Feb 2, 2026

Summary

  • Adds ViewDummy class in Core/GameEngine/Include/GameClient/View.h with no-op implementations for headless mode
  • Factory in W3DInGameUI returns dummy when m_headless is true
  • Refactors InGameUI::init() to always create TheTacticalView, but only init/attach to display when TheDisplay exists
  • Empty xfer() to skip view block in saves

Related

Split from #2139 per @xezon's suggestion to review each dummy class separately.

@greptile-apps
Copy link

greptile-apps bot commented Feb 2, 2026

Greptile Summary

This PR introduces ViewDummy, a no-op implementation of the View base class used when running in headless mode. InGameUI::init() is refactored to always allocate TheTacticalView (returning ViewDummy when TheGlobalData->m_headless is set), and the init/attachView/resize/setDefaultView steps are gated on TheDisplay being present. The createView() factory virtual is widened with a bool dummy parameter so W3DInGameUI can dispatch to the correct concrete type.

Key observations:

  • The ViewDummy class correctly implements all pure-virtual methods from View, and deliberately does not override xfer() so the base serialization runs for save-file compatibility — the intent is documented with an inline comment.
  • isDoingScriptedCamera() and stopDoingScriptedCamera() in ViewDummy are marked override, but neither method exists anywhere in the View base class. The C++ override specifier causes a hard compile-time error when no matching virtual is found in the base. These two methods should either have the override specifier removed (and the corresponding virtual declarations added to View), or be deleted entirely if headless mode has no scripted-camera behaviour.
  • The same ViewDummy class is defined in Core/ and shared by both Generals/ and GeneralsMD/, which is the correct approach for avoiding duplication.

Confidence Score: 1/5

  • Not safe to merge — ViewDummy contains invalid override specifiers that are hard compile errors in C++.
  • The isDoingScriptedCamera() and stopDoingScriptedCamera() methods in ViewDummy carry the override specifier, but neither method is declared as virtual anywhere in the View base class. In standard C++, override on a method with no matching virtual in any base class is a compile-time error (not a warning), meaning the project will fail to build as-is. This single issue blocks the PR from merging.
  • Core/GameEngine/Include/GameClient/View.h — the two invalid override declarations on lines 363–364 must be resolved before this can compile.

Important Files Changed

Filename Overview
Core/GameEngine/Include/GameClient/View.h Adds ViewDummy class to serve as a headless no-op view. Has outstanding compile errors: isDoingScriptedCamera() and stopDoingScriptedCamera() are marked override but neither method exists in the View base class.
Generals/Code/GameEngine/Source/GameClient/InGameUI.cpp Refactors tactical view creation to always allocate TheTacticalView (via createView), then conditionally init/attach only when TheDisplay exists. setDefaultView moved inside the display guard. TheGlobalData is already assumed non-null throughout this function.
GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp Mirror of Generals InGameUI.cpp changes — same refactoring for tactical view creation in Zero Hour. No distinct issues beyond those in the Generals copy.
Generals/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DInGameUI.h createView() factory refactored to accept a bool dummy parameter and dispatch to ViewDummy or W3DView accordingly. TheGlobalData access correctly moved to the caller (InGameUI::init).
GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DInGameUI.h Identical change to the Generals W3DInGameUI.h — same dummy-dispatch factory pattern, same assessment.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["InGameUI::init()"] --> B["createView(TheGlobalData->m_headless)"]
    B --> C{dummy == true?}
    C -- Yes --> D["new ViewDummy\n(no-op headless view)"]
    C -- No --> E["new W3DView\n(full rendering view)"]
    D --> F["TheTacticalView = view"]
    E --> F
    F --> G{TheTacticalView &&\nTheDisplay?}
    G -- No --> H["Skip display init\n(headless path)"]
    G -- Yes --> I["TheTacticalView->init()"]
    I --> J["TheDisplay->attachView(TheTacticalView)"]
    J --> K["setWidth / setHeight"]
    K --> L["setDefaultView(0,0,1)"]
Loading

Last reviewed commit: "refactor(headless): ..."

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

5 files reviewed, 5 comments

Edit Code Review Agent Settings | Greptile

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

5 files reviewed, 5 comments

Edit Code Review Agent Settings | Greptile

@bobtista bobtista force-pushed the bobtista/view-dummy branch from e30fa7a to e241df5 Compare February 24, 2026 14:57
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

5 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@bobtista bobtista force-pushed the bobtista/view-dummy branch from e241df5 to e439eee Compare February 24, 2026 23:52
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

5 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@xezon xezon added Enhancement Is new feature or request Debug Is mostly debug functionality labels Mar 10, 2026
@xezon
Copy link

xezon commented Mar 18, 2026

has left over comments

Copy link

@xezon xezon left a comment

Choose a reason for hiding this comment

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

OK

@xezon xezon changed the title feature(headless): Add ViewDummy for headless mode feat(headless): Add ViewDummy for headless mode Mar 19, 2026
@xezon xezon changed the title feat(headless): Add ViewDummy for headless mode feat(headless): Implement ViewDummy Mar 19, 2026
@xezon xezon merged commit 2b6c729 into TheSuperHackers:main Mar 19, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Debug Is mostly debug functionality Enhancement Is new feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants