Skip to content

Commit ad7c518

Browse files
committed
xrParticles: use range-based for
1 parent 21686b8 commit ad7c518

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

src/xrParticles/particle_actions.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ class ParticleActions
4242
void clear()
4343
{
4444
R_ASSERT(!m_bLocked);
45-
for (PAVecIt it = actions.begin(); it != actions.end(); ++it)
46-
xr_delete(*it);
45+
for (auto& it : actions)
46+
xr_delete(it);
4747
actions.clear();
4848
}
4949

src/xrParticles/particle_manager.cpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,16 @@ void CParticleManager::PlayEffect(int effect_id, int alist_id)
9494
return; // ERROR
9595
pa->lock();
9696
// Step through all the actions in the action list.
97-
for (PAVecIt it = pa->begin(); it != pa->end(); ++it)
97+
for (auto& it : *pa)
9898
{
99-
VERIFY((*it));
100-
switch ((*it)->type)
99+
VERIFY(it);
100+
switch (it->type)
101101
{
102-
case PASourceID: static_cast<PASource*>(*it)->m_Flags.set(PASource::flSilent, false);
102+
case PASourceID: static_cast<PASource*>(it)->m_Flags.set(PASource::flSilent, false);
103103
break;
104-
case PAExplosionID: static_cast<PAExplosion*>(*it)->age = 0.f;
104+
case PAExplosionID: static_cast<PAExplosion*>(it)->age = 0.f;
105105
break;
106-
case PATurbulenceID: static_cast<PATurbulence*>(*it)->age = 0.f;
106+
case PATurbulenceID: static_cast<PATurbulence*>(it)->age = 0.f;
107107
break;
108108
}
109109
}
@@ -120,11 +120,11 @@ void CParticleManager::StopEffect(int effect_id, int alist_id, bool deffered)
120120
pa->lock();
121121

122122
// Step through all the actions in the action list.
123-
for (PAVecIt it = pa->begin(); it != pa->end(); ++it)
123+
for (auto& it : *pa)
124124
{
125-
switch ((*it)->type)
125+
switch (it->type)
126126
{
127-
case PASourceID: static_cast<PASource*>(*it)->m_Flags.set(PASource::flSilent, true);
127+
case PASourceID: static_cast<PASource*>(it)->m_Flags.set(PASource::flSilent, true);
128128
break;
129129
}
130130
}
@@ -150,10 +150,10 @@ void CParticleManager::Update(int effect_id, int alist_id, float dt)
150150

151151
// Step through all the actions in the action list.
152152
float kill_old_time = 1.0f;
153-
for (PAVecIt it = pa->begin(); it != pa->end(); ++it)
153+
for (auto& it : *pa)
154154
{
155-
VERIFY((*it));
156-
(*it)->Execute(pe, dt, kill_old_time);
155+
VERIFY(it);
156+
it->Execute(pe, dt, kill_old_time);
157157
}
158158
pa->unlock();
159159
}
@@ -177,16 +177,16 @@ void CParticleManager::Transform(int alist_id, const Fmatrix& full, const Fvecto
177177
mT.translate(full.c);
178178

179179
// Step through all the actions in the action list.
180-
for (PAVecIt it = pa->begin(); it != pa->end(); ++it)
180+
for (auto& it : *pa)
181181
{
182-
bool r = (*it)->m_Flags.is(ParticleAction::ALLOW_ROTATE);
182+
bool r = it->m_Flags.is(ParticleAction::ALLOW_ROTATE);
183183
const Fmatrix& m = r ? full : mT;
184-
(*it)->Transform(m);
185-
switch ((*it)->type)
184+
it->Transform(m);
185+
switch (it->type)
186186
{
187187
case PASourceID:
188-
static_cast<PASource*>(*it)->parent_vel =
189-
pVector(vel.x, vel.y, vel.z) * static_cast<PASource*>(*it)->parent_motion;
188+
static_cast<PASource*>(it)->parent_vel =
189+
pVector(vel.x, vel.y, vel.z) * static_cast<PASource*>(it)->parent_motion;
190190
break;
191191
}
192192
}
@@ -328,7 +328,7 @@ void CParticleManager::SaveActions(int alist_id, IWriter& W)
328328
VERIFY(pa);
329329
pa->lock();
330330
W.w_u32(pa->size());
331-
for (PAVecIt it = pa->begin(); it != pa->end(); ++it)
332-
(*it)->Save(W);
331+
for (auto& it : *pa)
332+
it->Save(W);
333333
pa->unlock();
334334
}

0 commit comments

Comments
 (0)