Skip to content

Commit f5b8563

Browse files
authored
[GEN][ZH] Fix infinite loop in ParticleSystemManager::update (#877)
1 parent e61cef2 commit f5b8563

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3036,21 +3036,19 @@ void ParticleSystemManager::update( void )
30363036
m_lastLogicFrameUpdate = TheGameLogic->getFrame();
30373037

30383038
//USE_PERF_TIMER(ParticleSystemManager)
3039-
ParticleSystem *sys;
3040-
3041-
for(ParticleSystemListIt it = m_allParticleSystemList.begin(); it != m_allParticleSystemList.end();)
3039+
ParticleSystemListIt it = m_allParticleSystemList.begin();
3040+
while( it != m_allParticleSystemList.end() )
30423041
{
3043-
sys = (*it);
3042+
// TheSuperHackers @info Must increment the list iterator before potential element erasure from the list.
3043+
ParticleSystem* sys = *it++;
3044+
30443045
if (!sys) {
30453046
continue;
30463047
}
30473048

30483049
if (sys->update(m_localPlayerIndex) == false)
30493050
{
3050-
++it;
30513051
deleteInstance(sys);
3052-
} else {
3053-
++it;
30543052
}
30553053
}
30563054
}

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2938,21 +2938,19 @@ void ParticleSystemManager::update( void )
29382938
m_lastLogicFrameUpdate = TheGameLogic->getFrame();
29392939

29402940
//USE_PERF_TIMER(ParticleSystemManager)
2941-
ParticleSystem *sys;
2942-
2943-
for(ParticleSystemListIt it = m_allParticleSystemList.begin(); it != m_allParticleSystemList.end();)
2941+
ParticleSystemListIt it = m_allParticleSystemList.begin();
2942+
while( it != m_allParticleSystemList.end() )
29442943
{
2945-
sys = (*it);
2944+
// TheSuperHackers @info Must increment the list iterator before potential element erasure from the list.
2945+
ParticleSystem* sys = *it++;
2946+
29462947
if (!sys) {
29472948
continue;
29482949
}
29492950

29502951
if (sys->update(m_localPlayerIndex) == false)
29512952
{
2952-
++it;
29532953
deleteInstance(sys);
2954-
} else {
2955-
++it;
29562954
}
29572955
}
29582956
}

0 commit comments

Comments
 (0)