Skip to content

Commit

Permalink
bugfix, sprayEmit() would not return and get stuck
Browse files Browse the repository at this point in the history
- forgot default return value...
  • Loading branch information
DedeHai committed May 5, 2024
1 parent 2558156 commit 0b45f66
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions wled00/FXparticleSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,10 @@ void ParticleSystem::enableParticleCollisions(bool enable, uint8_t hardness) //
collisionHardness = hardness + 1;
}

// emit one particle with variation, returns index of emitted particle
uint32_t ParticleSystem::sprayEmit(PSsource &emitter)
// emit one particle with variation, returns index of emitted particle (or -1 if no particle emitted)
int32_t ParticleSystem::sprayEmit(PSsource &emitter)
{
for (uint32_t i = 0; i < usedParticles; i++)
for (int32_t i = 0; i < usedParticles; i++)
{
emitIndex++;
if (emitIndex >= usedParticles)
Expand All @@ -239,6 +239,7 @@ uint32_t ParticleSystem::sprayEmit(PSsource &emitter)
return i;
}
}
return -1;
}

// Spray emitter for particles used for flames (particle TTL depends on source TTL)
Expand Down
2 changes: 1 addition & 1 deletion wled00/FXparticleSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class ParticleSystem
void updateSystem(void); // call at the beginning of every FX, updates pointers and dimensions

// particle emitters
uint32_t sprayEmit(PSsource &emitter);
int32_t sprayEmit(PSsource &emitter);
void flameEmit(PSsource &emitter);
void angleEmit(PSsource& emitter, uint16_t angle, int8_t speed);

Expand Down

0 comments on commit 0b45f66

Please sign in to comment.