Skip to content

Commit 8f73d9e

Browse files
authored
[GEN][ZH] Remove unnecessary ParticleSystem null tests in ParticleSystemManager (#1322)
1 parent d83fca1 commit 8f73d9e

File tree

2 files changed

+24
-34
lines changed

2 files changed

+24
-34
lines changed

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

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2986,11 +2986,12 @@ void ParticleSystemManager::init( void )
29862986
// ------------------------------------------------------------------------------------------------
29872987
void ParticleSystemManager::reset( void )
29882988
{
2989-
while (getParticleSystemCount()) {
2990-
if (m_allParticleSystemList.front()) {
2991-
deleteInstance(m_allParticleSystemList.front());
2992-
}
2989+
while (!m_allParticleSystemList.empty())
2990+
{
2991+
DEBUG_ASSERTCRASH(m_allParticleSystemList.front() != NULL, ("ParticleSystemManager::reset: ParticleSystem is null"));
2992+
deleteInstance(m_allParticleSystemList.front());
29932993
}
2994+
DEBUG_ASSERTCRASH(m_particleSystemCount == 0, ("ParticleSystemManager::reset: m_particleSystemCount is %u, not 0", m_particleSystemCount));
29942995

29952996
// sanity, our lists must be empty!!
29962997
for( Int i = 0; i < NUM_PARTICLE_PRIORITIES; ++i )
@@ -3035,10 +3036,7 @@ void ParticleSystemManager::update( void )
30353036
{
30363037
// TheSuperHackers @info Must increment the list iterator before potential element erasure from the list.
30373038
ParticleSystem* sys = *it++;
3038-
3039-
if (!sys) {
3040-
continue;
3041-
}
3039+
DEBUG_ASSERTCRASH(sys != NULL, ("ParticleSystemManager::update: ParticleSystem is null"));
30423040

30433041
if (sys->update(m_localPlayerIndex) == false)
30443042
{
@@ -3095,9 +3093,7 @@ ParticleSystem *ParticleSystemManager::findParticleSystem( ParticleSystemID id )
30953093

30963094
for( ParticleSystemListIt it = m_allParticleSystemList.begin(); it != m_allParticleSystemList.end(); ++it ) {
30973095
system = *it;
3098-
if (!system) {
3099-
continue;
3100-
}
3096+
DEBUG_ASSERTCRASH(system != NULL, ("ParticleSystemManager::findParticleSystem: ParticleSystem is null"));
31013097

31023098
if( system->getSystemID() == id ) {
31033099
return system;
@@ -3185,16 +3181,13 @@ void ParticleSystemManager::destroyAttachedSystems( Object *obj )
31853181
return;
31863182

31873183
// iterate through all systems
3188-
ParticleSystem *system = NULL;
3189-
31903184
for( ParticleSystemListIt it = m_allParticleSystemList.begin();
31913185
it != m_allParticleSystemList.end();
31923186
++it )
31933187
{
31943188

3195-
system = *it;
3196-
if( system == NULL )
3197-
continue;
3189+
ParticleSystem *system = *it;
3190+
DEBUG_ASSERTCRASH(system != NULL, ("ParticleSystemManager::destroyAttachedSystems: ParticleSystem is null"));
31983191

31993192
if( system->getAttachedObject() == obj->getID() )
32003193
system->destroy();
@@ -3270,6 +3263,7 @@ void ParticleSystemManager::removeParticle( Particle *particleToRemove)
32703263
// ------------------------------------------------------------------------------------------------
32713264
void ParticleSystemManager::friend_addParticleSystem( ParticleSystem *particleSystemToAdd )
32723265
{
3266+
DEBUG_ASSERTCRASH(particleSystemToAdd != NULL, ("ParticleSystemManager::friend_addParticleSystem: ParticleSystem is null"));
32733267
m_allParticleSystemList.push_back(particleSystemToAdd);
32743268
++m_particleSystemCount;
32753269
}
@@ -3283,8 +3277,9 @@ void ParticleSystemManager::friend_removeParticleSystem( ParticleSystem *particl
32833277
if (it != m_allParticleSystemList.end()) {
32843278
m_allParticleSystemList.erase(it);
32853279
--m_particleSystemCount;
3280+
} else {
3281+
DEBUG_CRASH(("ParticleSystemManager::friend_removeParticleSystem: ParticleSystem to remove was not recognized"));
32863282
}
3287-
32883283
}
32893284

32903285
// ------------------------------------------------------------------------------------------------

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

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2888,11 +2888,12 @@ void ParticleSystemManager::init( void )
28882888
// ------------------------------------------------------------------------------------------------
28892889
void ParticleSystemManager::reset( void )
28902890
{
2891-
while (getParticleSystemCount()) {
2892-
if (m_allParticleSystemList.front()) {
2893-
deleteInstance(m_allParticleSystemList.front());
2894-
}
2891+
while (!m_allParticleSystemList.empty())
2892+
{
2893+
DEBUG_ASSERTCRASH(m_allParticleSystemList.front() != NULL, ("ParticleSystemManager::reset: ParticleSystem is null"));
2894+
deleteInstance(m_allParticleSystemList.front());
28952895
}
2896+
DEBUG_ASSERTCRASH(m_particleSystemCount == 0, ("ParticleSystemManager::reset: m_particleSystemCount is %u, not 0", m_particleSystemCount));
28962897

28972898
// sanity, our lists must be empty!!
28982899
for( Int i = 0; i < NUM_PARTICLE_PRIORITIES; ++i )
@@ -2937,10 +2938,7 @@ void ParticleSystemManager::update( void )
29372938
{
29382939
// TheSuperHackers @info Must increment the list iterator before potential element erasure from the list.
29392940
ParticleSystem* sys = *it++;
2940-
2941-
if (!sys) {
2942-
continue;
2943-
}
2941+
DEBUG_ASSERTCRASH(sys != NULL, ("ParticleSystemManager::update: ParticleSystem is null"));
29442942

29452943
if (sys->update(m_localPlayerIndex) == false)
29462944
{
@@ -2997,9 +2995,7 @@ ParticleSystem *ParticleSystemManager::findParticleSystem( ParticleSystemID id )
29972995

29982996
for( ParticleSystemListIt it = m_allParticleSystemList.begin(); it != m_allParticleSystemList.end(); ++it ) {
29992997
system = *it;
3000-
if (!system) {
3001-
continue;
3002-
}
2998+
DEBUG_ASSERTCRASH(system != NULL, ("ParticleSystemManager::findParticleSystem: ParticleSystem is null"));
30032999

30043000
if( system->getSystemID() == id ) {
30053001
return system;
@@ -3087,16 +3083,13 @@ void ParticleSystemManager::destroyAttachedSystems( Object *obj )
30873083
return;
30883084

30893085
// iterate through all systems
3090-
ParticleSystem *system = NULL;
3091-
30923086
for( ParticleSystemListIt it = m_allParticleSystemList.begin();
30933087
it != m_allParticleSystemList.end();
30943088
++it )
30953089
{
30963090

3097-
system = *it;
3098-
if( system == NULL )
3099-
continue;
3091+
ParticleSystem *system = *it;
3092+
DEBUG_ASSERTCRASH(system != NULL, ("ParticleSystemManager::destroyAttachedSystems: ParticleSystem is null"));
31003093

31013094
if( system->getAttachedObject() == obj->getID() )
31023095
system->destroy();
@@ -3172,6 +3165,7 @@ void ParticleSystemManager::removeParticle( Particle *particleToRemove)
31723165
// ------------------------------------------------------------------------------------------------
31733166
void ParticleSystemManager::friend_addParticleSystem( ParticleSystem *particleSystemToAdd )
31743167
{
3168+
DEBUG_ASSERTCRASH(particleSystemToAdd != NULL, ("ParticleSystemManager::friend_addParticleSystem: ParticleSystem is null"));
31753169
m_allParticleSystemList.push_back(particleSystemToAdd);
31763170
++m_particleSystemCount;
31773171
}
@@ -3185,8 +3179,9 @@ void ParticleSystemManager::friend_removeParticleSystem( ParticleSystem *particl
31853179
if (it != m_allParticleSystemList.end()) {
31863180
m_allParticleSystemList.erase(it);
31873181
--m_particleSystemCount;
3182+
} else {
3183+
DEBUG_CRASH(("ParticleSystemManager::friend_removeParticleSystem: ParticleSystem to remove was not recognized"));
31883184
}
3189-
31903185
}
31913186

31923187
// ------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)