Skip to content

Commit 7b4b2fd

Browse files
bugfix(particlesys): Delay creation of particle emitters until postProcess
1 parent 3ddec3a commit 7b4b2fd

6 files changed

Lines changed: 62 additions & 35 deletions

File tree

Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTankDraw.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "Common/Thing.h"
3535
#include "Common/ThingFactory.h"
3636
#include "Common/GameAudio.h"
37+
#include "Common/GameState.h"
3738
#include "Common/ThingTemplate.h"
3839
#include "Common/Xfer.h"
3940
#include "GameLogic/Weapon.h"
@@ -106,7 +107,12 @@ W3DTankDraw::W3DTankDraw( Thing *thing, const ModuleData* moduleData )
106107
m_lastDirection.y=0.0f;
107108
m_lastDirection.z=0.0f;
108109

109-
createTreadEmitters();
110+
// TheSuperHackers @bugfix stephanmeesters 20/02/2026
111+
// If loading from savegame, delay non-saveable emitter creation until postProcess.
112+
if (TheGameState == nullptr || TheGameState->isInLoadGame() == FALSE)
113+
{
114+
createTreadEmitters();
115+
}
110116
}
111117

112118
//-------------------------------------------------------------------------------------------------
@@ -435,8 +441,6 @@ void W3DTankDraw::loadPostProcess( void )
435441
// extend base class
436442
W3DModelDraw::loadPostProcess();
437443

438-
// toss any existing tread emitters and re-create 'em (since this module expects 'em to always be around)
439-
tossTreadEmitters();
440444
createTreadEmitters();
441445

442446
}

Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTankTruckDraw.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "Common/Thing.h"
3333
#include "Common/ThingFactory.h"
3434
#include "Common/GameAudio.h"
35+
#include "Common/GameState.h"
3536
#include "Common/GlobalData.h"
3637
#include "Common/ThingTemplate.h"
3738
#include "Common/Xfer.h"
@@ -119,7 +120,12 @@ m_prevRenderObj(nullptr)
119120

120121
m_treadCount=0;
121122

122-
createTreadEmitters();
123+
// TheSuperHackers @bugfix stephanmeesters 20/02/2026
124+
// If loading from savegame, delay non-saveable emitter creation until postProcess.
125+
if (TheGameState == nullptr || TheGameState->isInLoadGame() == FALSE)
126+
{
127+
createTreadEmitters();
128+
}
123129
}
124130

125131
//-------------------------------------------------------------------------------------------------
@@ -761,8 +767,6 @@ void W3DTankTruckDraw::loadPostProcess( void )
761767
// toss any existing wheel emitters (no need to re-create; we'll do that on demand)
762768
tossWheelEmitters();
763769

764-
// toss any existing tread emitters and re-create 'em (since this module expects 'em to always be around)
765-
tossTreadEmitters();
766770
createTreadEmitters();
767771

768772
}

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,7 @@ class AutoHealBehaviorModuleData : public UpdateModuleData
108108
//-------------------------------------------------------------------------------------------------
109109
class AutoHealBehavior : public UpdateModule,
110110
public UpgradeMux,
111-
public DamageModuleInterface
112-
{
113-
111+
public DamageModuleInterface {
114112
MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( AutoHealBehavior, "AutoHealBehavior" )
115113
MAKE_STANDARD_MODULE_MACRO_WITH_MODULE_DATA( AutoHealBehavior, AutoHealBehaviorModuleData )
116114

@@ -174,6 +172,7 @@ class AutoHealBehavior : public UpdateModule,
174172
private:
175173

176174
void pulseHealObject( Object *obj );
175+
void createEmitters();
177176

178177
ParticleSystemID m_radiusParticleSystemID;
179178

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ class GrantStealthBehavior : public UpdateModule
101101
private:
102102

103103
void grantStealthToObject( Object *obj );
104+
void createEmitters();
105+
104106
ParticleSystemID m_radiusParticleSystemID;
105107
Real m_currentScanRadius;
106108
};

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/AutoHealBehavior.cpp

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "Common/ThingTemplate.h"
3535
#include "Common/INI.h"
3636
#include "Common/Player.h"
37+
#include "Common/GameState.h"
3738
#include "Common/Xfer.h"
3839
#include "GameClient/ParticleSys.h"
3940
#include "GameClient/Anim2D.h"
@@ -94,20 +95,12 @@ AutoHealBehavior::AutoHealBehavior( Thing *thing, const ModuleData* moduleData )
9495
m_radiusParticleSystemID = INVALID_PARTICLE_SYSTEM_ID;
9596
m_soonestHealFrame = 0;
9697
m_stopped = false;
97-
Object *obj = getObject();
9898

99+
// TheSuperHackers @bugfix stephanmeesters 20/02/2026
100+
// If loading from savegame, delay non-saveable emitter creation until postProcess.
101+
if (TheGameState == nullptr || TheGameState->isInLoadGame() == FALSE)
99102
{
100-
if( d->m_radiusParticleSystemTmpl )
101-
{
102-
ParticleSystem *particleSystem;
103-
104-
particleSystem = TheParticleSystemManager->createParticleSystem( d->m_radiusParticleSystemTmpl );
105-
if( particleSystem )
106-
{
107-
particleSystem->setPosition( obj->getPosition() );
108-
m_radiusParticleSystemID = particleSystem->getSystemID();
109-
}
110-
}
103+
createEmitters();
111104
}
112105

113106
if (d->m_initiallyActive)
@@ -373,4 +366,22 @@ void AutoHealBehavior::loadPostProcess( void )
373366
// extend base class
374367
UpgradeMux::upgradeMuxLoadPostProcess();
375368

369+
createEmitters();
370+
371+
}
372+
373+
// ------------------------------------------------------------------------------------------------
374+
// ------------------------------------------------------------------------------------------------
375+
void AutoHealBehavior::createEmitters( void )
376+
{
377+
const AutoHealBehaviorModuleData *d = getAutoHealBehaviorModuleData();
378+
if( d->m_radiusParticleSystemTmpl )
379+
{
380+
ParticleSystem *particleSystem = TheParticleSystemManager->createParticleSystem(d->m_radiusParticleSystemTmpl);
381+
if( particleSystem )
382+
{
383+
particleSystem->setPosition( getObject()->getPosition() );
384+
m_radiusParticleSystemID = particleSystem->getSystemID();
385+
}
386+
}
376387
}

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/GrantStealthBehavior.cpp

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "Common/ThingTemplate.h"
3434
#include "Common/INI.h"
3535
#include "Common/Player.h"
36+
#include "Common/GameState.h"
3637
#include "Common/Xfer.h"
3738
#include "GameClient/ParticleSys.h"
3839
#include "GameClient/Anim2D.h"
@@ -96,21 +97,11 @@ GrantStealthBehavior::GrantStealthBehavior( Thing *thing, const ModuleData* modu
9697

9798
m_currentScanRadius = d->m_startRadius;
9899

99-
100-
Object *obj = getObject();
101-
100+
// TheSuperHackers @bugfix stephanmeesters 20/02/2026
101+
// If loading from savegame, delay non-saveable emitter creation until postProcess.
102+
if ( TheGameState == nullptr || TheGameState->isInLoadGame() == FALSE )
102103
{
103-
if( d->m_radiusParticleSystemTmpl )
104-
{
105-
ParticleSystem *particleSystem;
106-
107-
particleSystem = TheParticleSystemManager->createParticleSystem( d->m_radiusParticleSystemTmpl );
108-
if( particleSystem )
109-
{
110-
particleSystem->setPosition( obj->getPosition() );
111-
m_radiusParticleSystemID = particleSystem->getSystemID();
112-
}
113-
}
104+
createEmitters();
114105
}
115106

116107
setWakeFrame( getObject(), UPDATE_SLEEP_NONE );
@@ -246,5 +237,21 @@ void GrantStealthBehavior::loadPostProcess( void )
246237
// extend base class
247238
UpdateModule::loadPostProcess();
248239

240+
createEmitters();
241+
}
249242

243+
// ------------------------------------------------------------------------------------------------
244+
// ------------------------------------------------------------------------------------------------
245+
void GrantStealthBehavior::createEmitters( void )
246+
{
247+
const GrantStealthBehaviorModuleData *d = getGrantStealthBehaviorModuleData();
248+
if( d->m_radiusParticleSystemTmpl )
249+
{
250+
ParticleSystem *particleSystem = TheParticleSystemManager->createParticleSystem(d->m_radiusParticleSystemTmpl);
251+
if( particleSystem )
252+
{
253+
particleSystem->setPosition( getObject()->getPosition() );
254+
m_radiusParticleSystemID = particleSystem->getSystemID();
255+
}
256+
}
250257
}

0 commit comments

Comments
 (0)