Skip to content

Commit dd894c2

Browse files
authored
feat(headless): Implement GhostObjectManagerDummy (#2244)
1 parent e550dfe commit dd894c2

10 files changed

Lines changed: 52 additions & 10 deletions

File tree

Generals/Code/GameEngine/Include/GameLogic/GameLogic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ class GameLogic : public SubsystemInterface, public Snapshot
348348

349349
/// factory for TheTerrainLogic, called from init()
350350
virtual TerrainLogic *createTerrainLogic();
351-
virtual GhostObjectManager *createGhostObjectManager();
351+
virtual GhostObjectManager *createGhostObjectManager(bool dummy = false);
352352

353353
GameMode m_gameMode;
354354
Int m_rankLevelLimit;

Generals/Code/GameEngine/Include/GameLogic/GhostObject.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,5 +108,19 @@ inline Bool GhostObjectManager::trackAllPlayers() const
108108
#endif
109109
}
110110

111+
// TheSuperHackers @feature bobtista 19/01/2026
112+
// GhostObjectManager that does nothing for headless mode.
113+
// Note: Does NOT override crc/xfer/loadPostProcess to maintain save compatibility.
114+
class GhostObjectManagerDummy : public GhostObjectManager
115+
{
116+
public:
117+
virtual void reset() override {}
118+
virtual GhostObject *addGhostObject(Object *object, PartitionData *pd) override { return nullptr; }
119+
virtual void removeGhostObject(GhostObject *mod) override {}
120+
virtual void updateOrphanedObjects(int *playerIndexList, int playerIndexCount) override {}
121+
virtual void releasePartitionData() override {}
122+
virtual void restorePartitionData() override {}
123+
};
124+
111125
// the singleton
112126
extern GhostObjectManager *TheGhostObjectManager;

Generals/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ void GameLogic::init()
353353
// Create system for holding deleted objects that are
354354
// still in the partition manager because player has a fogged
355355
// view of them.
356-
TheGhostObjectManager = createGhostObjectManager();
356+
TheGhostObjectManager = createGhostObjectManager(TheGlobalData->m_headless);
357357

358358
// create the terrain logic
359359
TheTerrainLogic = createTerrainLogic();
@@ -3935,8 +3935,10 @@ UnsignedInt GameLogic::getObjectCount()
39353935

39363936
// ------------------------------------------------------------------------------------------------
39373937
// ------------------------------------------------------------------------------------------------
3938-
GhostObjectManager *GameLogic::createGhostObjectManager()
3938+
GhostObjectManager *GameLogic::createGhostObjectManager(bool dummy)
39393939
{
3940+
if (dummy)
3941+
return NEW GhostObjectManagerDummy;
39403942
return NEW GhostObjectManager;
39413943
}
39423944

Generals/Code/GameEngineDevice/Include/W3DDevice/GameLogic/W3DGameLogic.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ class W3DGameLogic : public GameLogic
5959

6060
/// factory for TheTerrainLogic, called from init()
6161
virtual TerrainLogic *createTerrainLogic() { return NEW W3DTerrainLogic; };
62-
virtual GhostObjectManager *createGhostObjectManager() { return NEW W3DGhostObjectManager; }
62+
virtual GhostObjectManager *createGhostObjectManager(bool dummy)
63+
{
64+
if (dummy)
65+
return NEW GhostObjectManagerDummy;
66+
return NEW W3DGhostObjectManager;
67+
}
6368

6469
};

Generals/Code/GameEngineDevice/Source/W3DDevice/GameLogic/W3DGhostObject.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ void W3DRenderObjectSnapshot::update(RenderObjClass *robj, DrawableInfo *drawInf
153153
// ------------------------------------------------------------------------------------------------
154154
Bool W3DRenderObjectSnapshot::addToScene()
155155
{
156-
if (W3DDisplay::m_3DScene != nullptr && !m_robj->Is_In_Scene())
156+
if (!m_robj->Is_In_Scene())
157157
{
158158
W3DDisplay::m_3DScene->Add_Render_Object(m_robj);
159159
return true;

GeneralsMD/Code/GameEngine/Include/GameLogic/GameLogic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ class GameLogic : public SubsystemInterface, public Snapshot
359359

360360
/// factory for TheTerrainLogic, called from init()
361361
virtual TerrainLogic *createTerrainLogic();
362-
virtual GhostObjectManager *createGhostObjectManager();
362+
virtual GhostObjectManager *createGhostObjectManager(bool dummy = false);
363363

364364
GameMode m_gameMode;
365365
Int m_rankLevelLimit;

GeneralsMD/Code/GameEngine/Include/GameLogic/GhostObject.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,5 +108,19 @@ inline Bool GhostObjectManager::trackAllPlayers() const
108108
#endif
109109
}
110110

111+
// TheSuperHackers @feature bobtista 19/01/2026
112+
// GhostObjectManager that does nothing for headless mode.
113+
// Note: Does NOT override crc/xfer/loadPostProcess to maintain save compatibility.
114+
class GhostObjectManagerDummy : public GhostObjectManager
115+
{
116+
public:
117+
virtual void reset() override {}
118+
virtual GhostObject *addGhostObject(Object *object, PartitionData *pd) override { return nullptr; }
119+
virtual void removeGhostObject(GhostObject *mod) override {}
120+
virtual void updateOrphanedObjects(int *playerIndexList, int playerIndexCount) override {}
121+
virtual void releasePartitionData() override {}
122+
virtual void restorePartitionData() override {}
123+
};
124+
111125
// the singleton
112126
extern GhostObjectManager *TheGhostObjectManager;

GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ void GameLogic::init()
364364
// Create system for holding deleted objects that are
365365
// still in the partition manager because player has a fogged
366366
// view of them.
367-
TheGhostObjectManager = createGhostObjectManager();
367+
TheGhostObjectManager = createGhostObjectManager(TheGlobalData->m_headless);
368368

369369
// create the terrain logic
370370
TheTerrainLogic = createTerrainLogic();
@@ -4492,8 +4492,10 @@ UnsignedInt GameLogic::getObjectCount()
44924492

44934493
// ------------------------------------------------------------------------------------------------
44944494
// ------------------------------------------------------------------------------------------------
4495-
GhostObjectManager *GameLogic::createGhostObjectManager()
4495+
GhostObjectManager *GameLogic::createGhostObjectManager(bool dummy)
44964496
{
4497+
if (dummy)
4498+
return NEW GhostObjectManagerDummy;
44974499
return NEW GhostObjectManager;
44984500
}
44994501

GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameLogic/W3DGameLogic.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ class W3DGameLogic : public GameLogic
5959

6060
/// factory for TheTerrainLogic, called from init()
6161
virtual TerrainLogic *createTerrainLogic() { return NEW W3DTerrainLogic; };
62-
virtual GhostObjectManager *createGhostObjectManager() { return NEW W3DGhostObjectManager; }
62+
virtual GhostObjectManager *createGhostObjectManager(bool dummy)
63+
{
64+
if (dummy)
65+
return NEW GhostObjectManagerDummy;
66+
return NEW W3DGhostObjectManager;
67+
}
6368

6469
};

GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameLogic/W3DGhostObject.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ void W3DRenderObjectSnapshot::update(RenderObjClass *robj, DrawableInfo *drawInf
157157
// ------------------------------------------------------------------------------------------------
158158
Bool W3DRenderObjectSnapshot::addToScene()
159159
{
160-
if (W3DDisplay::m_3DScene != nullptr && !m_robj->Is_In_Scene())
160+
if (!m_robj->Is_In_Scene())
161161
{
162162
W3DDisplay::m_3DScene->Add_Render_Object(m_robj);
163163
return true;

0 commit comments

Comments
 (0)