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] 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()); } - } }