-
Notifications
You must be signed in to change notification settings - Fork 151
feat(headless): Add GhostObjectManagerDummy for headless mode #2150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat(headless): Add GhostObjectManagerDummy for headless mode #2150
Conversation
|
| Filename | Overview |
|---|---|
| GeneralsMD/Code/GameEngine/Include/GameLogic/GhostObject.h | Added GhostObjectManagerDummy class that stubs out ghost object operations for headless mode while preserving save/load compatibility |
| GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameLogic/W3DGameLogic.h | Modified createGhostObjectManager to return GhostObjectManagerDummy when in headless mode, otherwise W3DGhostObjectManager |
Sequence Diagram
sequenceDiagram
participant GameLogic
participant W3DGameLogic
participant TheGlobalData
participant GhostObjectManagerDummy
participant W3DGhostObjectManager
participant PartitionData
GameLogic->>W3DGameLogic: createGhostObjectManager()
W3DGameLogic->>TheGlobalData: check m_headless flag
alt Headless Mode
W3DGameLogic->>GhostObjectManagerDummy: NEW GhostObjectManagerDummy
GhostObjectManagerDummy-->>GameLogic: return (as GhostObjectManager*)
Note over GhostObjectManagerDummy: All operations stubbed out<br/>Returns nullptr from addGhostObject
else Normal Mode
W3DGameLogic->>W3DGhostObjectManager: NEW W3DGhostObjectManager
W3DGhostObjectManager-->>GameLogic: return
Note over W3DGhostObjectManager: Full implementation<br/>Creates W3DGhostObject instances
end
Note over GameLogic: Later during gameplay...
PartitionData->>GameLogic: TheGhostObjectManager->addGhostObject(obj, pd)
alt Headless Mode
GameLogic->>GhostObjectManagerDummy: addGhostObject(obj, pd)
GhostObjectManagerDummy-->>PartitionData: return nullptr
Note over PartitionData: m_ghostObject = nullptr<br/>All subsequent uses check for null
else Normal Mode
GameLogic->>W3DGhostObjectManager: addGhostObject(obj, pd)
W3DGhostObjectManager-->>PartitionData: return W3DGhostObject*
Note over PartitionData: m_ghostObject = valid pointer<br/>Used for fog-of-war rendering
end
f48524e to
11152fa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4 files reviewed, 1 comment
| virtual TerrainLogic *createTerrainLogic( void ) { return NEW W3DTerrainLogic; }; | ||
| virtual GhostObjectManager *createGhostObjectManager(void) { return NEW W3DGhostObjectManager; } | ||
| // TheSuperHackers @feature bobtista 18/01/2026 Use dummy for headless mode | ||
| virtual GhostObjectManager *createGhostObjectManager(void) { return TheGlobalData->m_headless ? static_cast<GhostObjectManager*>(NEW GhostObjectManagerDummy) : NEW W3DGhostObjectManager; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: unnecessary static_cast since GhostObjectManagerDummy already inherits from GhostObjectManager
| virtual GhostObjectManager *createGhostObjectManager(void) { return TheGlobalData->m_headless ? static_cast<GhostObjectManager*>(NEW GhostObjectManagerDummy) : NEW W3DGhostObjectManager; } | |
| virtual GhostObjectManager *createGhostObjectManager(void) { return TheGlobalData->m_headless ? NEW GhostObjectManagerDummy : NEW W3DGhostObjectManager; } |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Prompt To Fix With AI
This is a comment left during a code review.
Path: GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameLogic/W3DGameLogic.h
Line: 64:64
Comment:
**style:** unnecessary `static_cast` since `GhostObjectManagerDummy` already inherits from `GhostObjectManager`
```suggestion
virtual GhostObjectManager *createGhostObjectManager(void) { return TheGlobalData->m_headless ? NEW GhostObjectManagerDummy : NEW W3DGhostObjectManager; }
```
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is required for VC6, it failed to build without it
52aa47b to
393f23b
Compare
|
Did you add this for performance reasons, or to reduce headless checks? I don't see any removed headless checks. |
Depends on #2137 (ParticleSystem use-after-free fix) to avoid crash during headless replay playback.
Summary
GhostObjectManagerDummyclass that stubs out ghost object operations for headless modeTheGlobalData->m_headlessis trueTesting
-headless -replay <file>and verify no crashes (cherry pick the particlesystem fix first)Todo
Notes
-I tried to add
InGameUIDummytoo, but it broke things.-The GhostObjectManagerDummy overrides only the operational methods (reset, addGhostObject, removeGhostObject, etc.) while inheriting crc/xfer/loadPostProcess from the base class to maintain save/load compatibility.