Skip to content

Commit 92df977

Browse files
authored
fix(particlesys): Simplify ParticleSystemManagerDummy setup (TheSuperHackers#2740)
1 parent 9a402fb commit 92df977

8 files changed

Lines changed: 19 additions & 31 deletions

File tree

Core/GameEngine/Include/GameClient/ParticleSys.h

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,8 @@ class ParticleSystemManager : public SubsystemInterface,
753753
virtual void reset() override; ///< reset the manager and all particle systems
754754
virtual void update() override; ///< update all particle systems
755755

756+
virtual Bool isDummy() const { return false; }
757+
756758
virtual Int getOnScreenParticleCount() = 0; ///< returns the number of particles on screen
757759
virtual void setOnScreenParticleCount(int count);
758760

@@ -761,8 +763,7 @@ class ParticleSystemManager : public SubsystemInterface,
761763
ParticleSystemTemplate *newTemplate( const AsciiString &name );
762764

763765
/// given a template, instantiate a particle system
764-
ParticleSystem *createParticleSystem( const ParticleSystemTemplate *sysTemplate,
765-
Bool createSlaves = TRUE );
766+
ParticleSystem *createParticleSystem( const ParticleSystemTemplate *sysTemplate, Bool createSlaves = TRUE );
766767

767768
/** given a template, instantiate a particle system.
768769
if attachTo is not null, attach the particle system to the given object.
@@ -835,11 +836,24 @@ class ParticleSystemManager : public SubsystemInterface,
835836
ParticleSystemIDMap m_systemMap; ///< a hash map of all particle systems
836837
};
837838

839+
838840
// TheSuperHackers @feature bobtista 31/01/2026
839841
// ParticleSystemManager that does nothing. Used for Headless Mode.
842+
// Generally does not load particle system templates. Certainly does not create particle systems.
840843
class ParticleSystemManagerDummy : public ParticleSystemManager
841844
{
842845
public:
846+
#if RETAIL_COMPATIBLE_CRC
847+
// Must not overload init to keep loading the particle system templates,
848+
// which are unfortunately needed to preserve the correct logic crc.
849+
#else
850+
virtual void init() override {}
851+
virtual void reset() override {}
852+
#endif
853+
virtual void update() override {}
854+
855+
virtual Bool isDummy() const override { return true; }
856+
843857
virtual Int getOnScreenParticleCount() override { return 0; }
844858
virtual void doParticles(RenderInfoClass &rinfo) override {}
845859
virtual void queueParticleRender() override {}

Core/GameEngine/Source/Common/ReplaySimulation.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,6 @@ int ReplaySimulation::simulateReplaysInThisProcess(const std::vector<AsciiString
8686
UnsignedInt totalTimeSec = TheRecorder->getPlaybackFrameCount() / LOGICFRAMES_PER_SECOND;
8787
while (TheRecorder->isPlaybackInProgress())
8888
{
89-
TheGameClient->updateHeadless();
90-
9189
const int progressFrameInterval = 10*60*LOGICFRAMES_PER_SECOND;
9290
if (TheGameLogic->getFrame() != 0 && TheGameLogic->getFrame() % progressFrameInterval == 0)
9391
{

Core/GameEngine/Source/GameClient/Drawable/Update/BeaconClientUpdate.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,7 @@ static ParticleSystem* createParticleSystem( Drawable *draw )
9494
AsciiString templateName;
9595
templateName.format("BeaconSmoke%6.6X", (0xffffff & obj->getIndicatorColor()));
9696
const ParticleSystemTemplate *particleTemplate = TheParticleSystemManager->findTemplate( templateName );
97-
98-
DEBUG_ASSERTCRASH(particleTemplate, ("Could not find particle system %s", templateName.str()));
99-
97+
DEBUG_ASSERTCRASH(TheParticleSystemManager->isDummy() || particleTemplate, ("Could not find particle system %s", templateName.str()));
10098
if (particleTemplate)
10199
{
102100
system = TheParticleSystemManager->createParticleSystem( particleTemplate );
@@ -107,7 +105,7 @@ static ParticleSystem* createParticleSystem( Drawable *draw )
107105
{// THis this will whip up a new particle system to match the house color provided
108106
templateName.format("BeaconSmokeFFFFFF");
109107
const ParticleSystemTemplate *failsafeTemplate = TheParticleSystemManager->findTemplate( templateName );
110-
DEBUG_ASSERTCRASH(failsafeTemplate, ("Doh, this is bad \n I Could not even find the white particle system to make a failsafe system out of."));
108+
DEBUG_ASSERTCRASH(TheParticleSystemManager->isDummy() || failsafeTemplate, ("Doh, this is bad \n I Could not even find the white particle system to make a failsafe system out of."));
111109
system = TheParticleSystemManager->createParticleSystem( failsafeTemplate );
112110
if (system)
113111
{

Core/GameEngine/Source/GameClient/FXList.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ class ParticleSystemFXNugget : public FXNugget
600600
}
601601

602602
const ParticleSystemTemplate *tmp = TheParticleSystemManager->findTemplate(m_name);
603-
DEBUG_ASSERTCRASH(tmp, ("ParticleSystem %s not found",m_name.str()));
603+
DEBUG_ASSERTCRASH(TheParticleSystemManager->isDummy() || tmp, ("ParticleSystem %s not found",m_name.str()));
604604
if (tmp)
605605
{
606606
for (Int i = 0; i < m_count; i++ )

Generals/Code/GameEngine/Include/GameClient/GameClient.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,6 @@ class GameClient : public SubsystemInterface,
9494

9595
void step(); ///< Do one fixed time step
9696

97-
void updateHeadless();
98-
9997
void addDrawableToLookupTable( Drawable *draw ); ///< add drawable ID to hash lookup table
10098
void removeDrawableFromLookupTable( Drawable *draw ); ///< remove drawable ID from hash lookup table
10199

Generals/Code/GameEngine/Source/GameClient/GameClient.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -750,15 +750,6 @@ void GameClient::step()
750750
TheDisplay->step();
751751
}
752752

753-
void GameClient::updateHeadless()
754-
{
755-
// TheSuperHackers @info helmutbuhler 03/05/2025 bobtista 02/02/2026
756-
// Update particles to prevent accumulation in headless mode. Particles are generated
757-
// during GameLogic and only cleaned up during rendering. update() lets particles finish
758-
// their lifecycle naturally instead of abruptly removing them with reset().
759-
TheParticleSystemManager->update();
760-
}
761-
762753
Bool GameClient::isMovieAbortRequested()
763754
{
764755
if (TheGameEngine)

GeneralsMD/Code/GameEngine/Include/GameClient/GameClient.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,6 @@ class GameClient : public SubsystemInterface,
9898

9999
void step(); ///< Do one fixed time step
100100

101-
void updateHeadless();
102-
103101
void addDrawableToLookupTable( Drawable *draw ); ///< add drawable ID to hash lookup table
104102
void removeDrawableFromLookupTable( Drawable *draw ); ///< remove drawable ID from hash lookup table
105103

GeneralsMD/Code/GameEngine/Source/GameClient/GameClient.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -787,15 +787,6 @@ void GameClient::step()
787787
TheDisplay->step();
788788
}
789789

790-
void GameClient::updateHeadless()
791-
{
792-
// TheSuperHackers @info helmutbuhler 03/05/2025 bobtista 02/02/2026
793-
// Update particles to prevent accumulation in headless mode. Particles are generated
794-
// during GameLogic and only cleaned up during rendering. update() lets particles finish
795-
// their lifecycle naturally instead of abruptly removing them with reset().
796-
TheParticleSystemManager->update();
797-
}
798-
799790
Bool GameClient::isMovieAbortRequested()
800791
{
801792
if (TheGameEngine)

0 commit comments

Comments
 (0)