From 7cbe0ab06ccb60a1931187672dffe8123192395b Mon Sep 17 00:00:00 2001 From: stm <14291421+stephanmeesters@users.noreply.github.com> Date: Mon, 16 Feb 2026 13:27:12 +0100 Subject: [PATCH 1/6] bugfix(savegame): Restore particle system IDs before registation with ParticleSystemManager --- .../Source/GameClient/System/ParticleSys.cpp | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/Core/GameEngine/Source/GameClient/System/ParticleSys.cpp b/Core/GameEngine/Source/GameClient/System/ParticleSys.cpp index bb6350dbf27..64156b90e50 100644 --- a/Core/GameEngine/Source/GameClient/System/ParticleSys.cpp +++ b/Core/GameEngine/Source/GameClient/System/ParticleSys.cpp @@ -1215,7 +1215,10 @@ ParticleSystem::ParticleSystem( const ParticleSystemTemplate *sysTemplate, m_personalityStore = 0; m_controlParticle = nullptr; - TheParticleSystemManager->friend_addParticleSystem(this); + if ( m_systemID != INVALID_PARTICLE_SYSTEM_ID ) + { + TheParticleSystemManager->friend_addParticleSystem(this); + } //DEBUG_ASSERTLOG(!(m_totalParticleSystemCount % 10 == 0), ( "TotalParticleSystemCount = %d", m_totalParticleSystemCount )); } @@ -3364,22 +3367,28 @@ void ParticleSystemManager::xfer( Xfer *xfer ) } // create system - system = createParticleSystem( systemTemplate, FALSE ); + // TheSuperHackers @bugfix stephanmeesters 16/02/2026 + // Particle systems originally were assigned an incrementing system ID in the constructor that did not + // always match the ID that was xfer'd. When using findParticleSystem this would cause master/slave lookups to fail. + // Defer registering particle systems to ParticleSys until the system ID is properly restored. + system = newInstance(ParticleSystem)( systemTemplate, INVALID_PARTICLE_SYSTEM_ID, FALSE ); - if( system == nullptr ) - { + // read system data + xfer->xferSnapshot( system ); - DEBUG_CRASH(( "ParticleSystemManager::xfer - Unable to allocate particle system '%s'", + if( system->getSystemID() == INVALID_PARTICLE_SYSTEM_ID ) + { + DEBUG_CRASH(( "ParticleSystemManager::xfer - Unable to restore system ID to particle system '%s'", systemName.str() )); throw SC_INVALID_DATA; - } - // read system data - xfer->xferSnapshot( system ); + friend_addParticleSystem(system); + // TheSuperHackers @bugfix stephanmeesters 16/02/2026 + // Ensure that particle systems created later in the game won't collide with the xfer'd systems. + m_uniqueSystemID = MAX(m_uniqueSystemID, system->getSystemID()); } - } } From bb08bcea93474fab0f8a0a08eeb458aaa2af3a45 Mon Sep 17 00:00:00 2001 From: stm <14291421+stephanmeesters@users.noreply.github.com> Date: Tue, 17 Feb 2026 10:26:57 +0100 Subject: [PATCH 2/6] Remove unnecessary uniqueSystemID assignment --- Core/GameEngine/Source/GameClient/System/ParticleSys.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Core/GameEngine/Source/GameClient/System/ParticleSys.cpp b/Core/GameEngine/Source/GameClient/System/ParticleSys.cpp index 64156b90e50..3ba7753c5f5 100644 --- a/Core/GameEngine/Source/GameClient/System/ParticleSys.cpp +++ b/Core/GameEngine/Source/GameClient/System/ParticleSys.cpp @@ -3384,10 +3384,6 @@ void ParticleSystemManager::xfer( Xfer *xfer ) } friend_addParticleSystem(system); - - // TheSuperHackers @bugfix stephanmeesters 16/02/2026 - // Ensure that particle systems created later in the game won't collide with the xfer'd systems. - m_uniqueSystemID = MAX(m_uniqueSystemID, system->getSystemID()); } } From e962c0512e5cc3dedd82c43d364fe5b201fc6cca Mon Sep 17 00:00:00 2001 From: stm <14291421+stephanmeesters@users.noreply.github.com> Date: Tue, 17 Feb 2026 10:28:50 +0100 Subject: [PATCH 3/6] Style touchup --- Core/GameEngine/Source/GameClient/System/ParticleSys.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Core/GameEngine/Source/GameClient/System/ParticleSys.cpp b/Core/GameEngine/Source/GameClient/System/ParticleSys.cpp index 3ba7753c5f5..17c5e81f167 100644 --- a/Core/GameEngine/Source/GameClient/System/ParticleSys.cpp +++ b/Core/GameEngine/Source/GameClient/System/ParticleSys.cpp @@ -3385,6 +3385,7 @@ void ParticleSystemManager::xfer( Xfer *xfer ) friend_addParticleSystem(system); } + } } From 5299ad11d4b61970b03191605a1fd06ce9d63e8a Mon Sep 17 00:00:00 2001 From: stm <14291421+stephanmeesters@users.noreply.github.com> Date: Wed, 18 Feb 2026 00:22:58 +0100 Subject: [PATCH 4/6] Ensure proper cleanup on throw --- Core/GameEngine/Source/GameClient/System/ParticleSys.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Core/GameEngine/Source/GameClient/System/ParticleSys.cpp b/Core/GameEngine/Source/GameClient/System/ParticleSys.cpp index 17c5e81f167..0c5f98c9af0 100644 --- a/Core/GameEngine/Source/GameClient/System/ParticleSys.cpp +++ b/Core/GameEngine/Source/GameClient/System/ParticleSys.cpp @@ -3370,11 +3370,12 @@ void ParticleSystemManager::xfer( Xfer *xfer ) // TheSuperHackers @bugfix stephanmeesters 16/02/2026 // Particle systems originally were assigned an incrementing system ID in the constructor that did not // always match the ID that was xfer'd. When using findParticleSystem this would cause master/slave lookups to fail. - // Defer registering particle systems to ParticleSys until the system ID is properly restored. + // Defer registering particle systems to ParticleSystemManager until the system ID is properly restored. system = newInstance(ParticleSystem)( systemTemplate, INVALID_PARTICLE_SYSTEM_ID, FALSE ); // read system data xfer->xferSnapshot( system ); + friend_addParticleSystem(system); if( system->getSystemID() == INVALID_PARTICLE_SYSTEM_ID ) { @@ -3383,7 +3384,6 @@ void ParticleSystemManager::xfer( Xfer *xfer ) throw SC_INVALID_DATA; } - friend_addParticleSystem(system); } } From fd2589276b7972989d31f2d09fb04c970b4bd5de Mon Sep 17 00:00:00 2001 From: stm <14291421+stephanmeesters@users.noreply.github.com> Date: Wed, 18 Feb 2026 17:10:50 +0100 Subject: [PATCH 5/6] Better cleanup code --- Core/GameEngine/Source/GameClient/System/ParticleSys.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Core/GameEngine/Source/GameClient/System/ParticleSys.cpp b/Core/GameEngine/Source/GameClient/System/ParticleSys.cpp index 0c5f98c9af0..7ebb76291d4 100644 --- a/Core/GameEngine/Source/GameClient/System/ParticleSys.cpp +++ b/Core/GameEngine/Source/GameClient/System/ParticleSys.cpp @@ -1263,7 +1263,8 @@ ParticleSystem::~ParticleSystem() m_controlParticle = nullptr; - TheParticleSystemManager->friend_removeParticleSystem(this); + if (m_systemID != INVALID_PARTICLE_SYSTEM_ID) + TheParticleSystemManager->friend_removeParticleSystem(this); //DEBUG_ASSERTLOG(!(m_totalParticleSystemCount % 10 == 0), ( "TotalParticleSystemCount = %d", m_totalParticleSystemCount )); } @@ -3375,15 +3376,16 @@ void ParticleSystemManager::xfer( Xfer *xfer ) // read system data xfer->xferSnapshot( system ); - friend_addParticleSystem(system); if( system->getSystemID() == INVALID_PARTICLE_SYSTEM_ID ) { DEBUG_CRASH(( "ParticleSystemManager::xfer - Unable to restore system ID to particle system '%s'", systemName.str() )); + deleteInstance(system); throw SC_INVALID_DATA; } + friend_addParticleSystem(system); } } From 154276aa9e58a787e1e59c18a20ede1dec98d742 Mon Sep 17 00:00:00 2001 From: stm <14291421+stephanmeesters@users.noreply.github.com> Date: Wed, 18 Feb 2026 21:17:35 +0100 Subject: [PATCH 6/6] Formatting --- Core/GameEngine/Source/GameClient/System/ParticleSys.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Core/GameEngine/Source/GameClient/System/ParticleSys.cpp b/Core/GameEngine/Source/GameClient/System/ParticleSys.cpp index 7ebb76291d4..4f464610f10 100644 --- a/Core/GameEngine/Source/GameClient/System/ParticleSys.cpp +++ b/Core/GameEngine/Source/GameClient/System/ParticleSys.cpp @@ -1263,8 +1263,10 @@ ParticleSystem::~ParticleSystem() m_controlParticle = nullptr; - if (m_systemID != INVALID_PARTICLE_SYSTEM_ID) + if ( m_systemID != INVALID_PARTICLE_SYSTEM_ID ) + { TheParticleSystemManager->friend_removeParticleSystem(this); + } //DEBUG_ASSERTLOG(!(m_totalParticleSystemCount % 10 == 0), ( "TotalParticleSystemCount = %d", m_totalParticleSystemCount )); }