forked from Mirrorlandia_minetest/minetest
ParticleManager::handleParticleEvent: use switch
Use a proper switch with breaks.
This commit is contained in:
parent
0aac1b7403
commit
e082c7766a
@ -346,7 +346,7 @@ void ParticleManager::step(float dtime)
|
|||||||
void ParticleManager::stepSpawners (float dtime)
|
void ParticleManager::stepSpawners (float dtime)
|
||||||
{
|
{
|
||||||
MutexAutoLock lock(m_spawner_list_lock);
|
MutexAutoLock lock(m_spawner_list_lock);
|
||||||
for(std::map<u32, ParticleSpawner*>::iterator i =
|
for (std::map<u32, ParticleSpawner*>::iterator i =
|
||||||
m_particle_spawners.begin();
|
m_particle_spawners.begin();
|
||||||
i != m_particle_spawners.end();)
|
i != m_particle_spawners.end();)
|
||||||
{
|
{
|
||||||
@ -408,29 +408,27 @@ void ParticleManager::clearAll ()
|
|||||||
void ParticleManager::handleParticleEvent(ClientEvent *event, IGameDef *gamedef,
|
void ParticleManager::handleParticleEvent(ClientEvent *event, IGameDef *gamedef,
|
||||||
scene::ISceneManager* smgr, LocalPlayer *player)
|
scene::ISceneManager* smgr, LocalPlayer *player)
|
||||||
{
|
{
|
||||||
if (event->type == CE_DELETE_PARTICLESPAWNER) {
|
switch (event->type) {
|
||||||
|
case CE_DELETE_PARTICLESPAWNER: {
|
||||||
MutexAutoLock lock(m_spawner_list_lock);
|
MutexAutoLock lock(m_spawner_list_lock);
|
||||||
if (m_particle_spawners.find(event->delete_particlespawner.id) !=
|
if (m_particle_spawners.find(event->delete_particlespawner.id) !=
|
||||||
m_particle_spawners.end())
|
m_particle_spawners.end()) {
|
||||||
{
|
|
||||||
delete m_particle_spawners.find(event->delete_particlespawner.id)->second;
|
delete m_particle_spawners.find(event->delete_particlespawner.id)->second;
|
||||||
m_particle_spawners.erase(event->delete_particlespawner.id);
|
m_particle_spawners.erase(event->delete_particlespawner.id);
|
||||||
}
|
}
|
||||||
// no allocated memory in delete event
|
// no allocated memory in delete event
|
||||||
return;
|
break;
|
||||||
}
|
}
|
||||||
|
case CE_ADD_PARTICLESPAWNER: {
|
||||||
if (event->type == CE_ADD_PARTICLESPAWNER) {
|
|
||||||
|
|
||||||
{
|
{
|
||||||
MutexAutoLock lock(m_spawner_list_lock);
|
MutexAutoLock lock(m_spawner_list_lock);
|
||||||
if (m_particle_spawners.find(event->add_particlespawner.id) !=
|
if (m_particle_spawners.find(event->add_particlespawner.id) !=
|
||||||
m_particle_spawners.end())
|
m_particle_spawners.end()) {
|
||||||
{
|
|
||||||
delete m_particle_spawners.find(event->add_particlespawner.id)->second;
|
delete m_particle_spawners.find(event->add_particlespawner.id)->second;
|
||||||
m_particle_spawners.erase(event->add_particlespawner.id);
|
m_particle_spawners.erase(event->add_particlespawner.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
video::ITexture *texture =
|
video::ITexture *texture =
|
||||||
gamedef->tsrc()->getTextureForMesh(*(event->add_particlespawner.texture));
|
gamedef->tsrc()->getTextureForMesh(*(event->add_particlespawner.texture));
|
||||||
|
|
||||||
@ -469,11 +467,9 @@ void ParticleManager::handleParticleEvent(ClientEvent *event, IGameDef *gamedef,
|
|||||||
event->add_particlespawner.id,
|
event->add_particlespawner.id,
|
||||||
toadd));
|
toadd));
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
case CE_SPAWN_PARTICLE: {
|
||||||
if (event->type == CE_SPAWN_PARTICLE) {
|
|
||||||
video::ITexture *texture =
|
video::ITexture *texture =
|
||||||
gamedef->tsrc()->getTextureForMesh(*(event->spawn_particle.texture));
|
gamedef->tsrc()->getTextureForMesh(*(event->spawn_particle.texture));
|
||||||
|
|
||||||
@ -495,7 +491,9 @@ void ParticleManager::handleParticleEvent(ClientEvent *event, IGameDef *gamedef,
|
|||||||
delete event->spawn_particle.vel;
|
delete event->spawn_particle.vel;
|
||||||
delete event->spawn_particle.acc;
|
delete event->spawn_particle.acc;
|
||||||
|
|
||||||
return;
|
break;
|
||||||
|
}
|
||||||
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user