mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 14:51:51 +00:00
Replaced memset for particles as recommended by dpJudas
This commit is contained in:
parent
f044695d28
commit
a483ad20be
1 changed files with 4 additions and 3 deletions
|
@ -130,9 +130,10 @@ inline particle_t *NewParticle (FLevelLocals *Level, bool replace = false)
|
||||||
particle_t* ntop = &Level->Particles[result->tnext];
|
particle_t* ntop = &Level->Particles[result->tnext];
|
||||||
ntop->tprev = Level->ActiveParticles;
|
ntop->tprev = Level->ActiveParticles;
|
||||||
}
|
}
|
||||||
|
// [MC] Future proof this by resetting everything when replacing a particle.
|
||||||
auto tnext = result->tnext;
|
auto tnext = result->tnext;
|
||||||
auto tprev = result->tprev;
|
auto tprev = result->tprev;
|
||||||
memset(result, 0, sizeof(particle_t));
|
*result = {};
|
||||||
result->tnext = tnext;
|
result->tnext = tnext;
|
||||||
result->tprev = tprev;
|
result->tprev = tprev;
|
||||||
}
|
}
|
||||||
|
@ -185,12 +186,12 @@ void P_InitParticles (FLevelLocals *Level)
|
||||||
void P_ClearParticles (FLevelLocals *Level)
|
void P_ClearParticles (FLevelLocals *Level)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
memset (Level->Particles.Data(), 0, Level->Particles.Size() * sizeof(particle_t));
|
|
||||||
Level->OldestParticle = NO_PARTICLE;
|
Level->OldestParticle = NO_PARTICLE;
|
||||||
Level->ActiveParticles = NO_PARTICLE;
|
Level->ActiveParticles = NO_PARTICLE;
|
||||||
Level->InactiveParticles = 0;
|
Level->InactiveParticles = 0;
|
||||||
for (auto &p : Level->Particles)
|
for (auto &p : Level->Particles)
|
||||||
{
|
{
|
||||||
|
p = {};
|
||||||
p.tprev = i - 1;
|
p.tprev = i - 1;
|
||||||
p.tnext = ++i;
|
p.tnext = ++i;
|
||||||
}
|
}
|
||||||
|
@ -281,7 +282,7 @@ void P_ThinkParticles (FLevelLocals *Level)
|
||||||
particle->size += particle->sizestep;
|
particle->size += particle->sizestep;
|
||||||
if (particle->alpha <= 0 || oldtrans < particle->alpha || --particle->ttl <= 0 || (particle->size <= 0))
|
if (particle->alpha <= 0 || oldtrans < particle->alpha || --particle->ttl <= 0 || (particle->size <= 0))
|
||||||
{ // The particle has expired, so free it
|
{ // The particle has expired, so free it
|
||||||
memset (particle, 0, sizeof(particle_t));
|
*particle = {};
|
||||||
if (prev)
|
if (prev)
|
||||||
prev->tnext = i;
|
prev->tnext = i;
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue