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)
|
||||
{
|
||||
MutexAutoLock lock(m_spawner_list_lock);
|
||||
for(std::map<u32, ParticleSpawner*>::iterator i =
|
||||
for (std::map<u32, ParticleSpawner*>::iterator i =
|
||||
m_particle_spawners.begin();
|
||||
i != m_particle_spawners.end();)
|
||||
{
|
||||
@ -408,94 +408,92 @@ void ParticleManager::clearAll ()
|
||||
void ParticleManager::handleParticleEvent(ClientEvent *event, IGameDef *gamedef,
|
||||
scene::ISceneManager* smgr, LocalPlayer *player)
|
||||
{
|
||||
if (event->type == CE_DELETE_PARTICLESPAWNER) {
|
||||
MutexAutoLock lock(m_spawner_list_lock);
|
||||
if (m_particle_spawners.find(event->delete_particlespawner.id) !=
|
||||
m_particle_spawners.end())
|
||||
{
|
||||
delete m_particle_spawners.find(event->delete_particlespawner.id)->second;
|
||||
m_particle_spawners.erase(event->delete_particlespawner.id);
|
||||
}
|
||||
// no allocated memory in delete event
|
||||
return;
|
||||
}
|
||||
|
||||
if (event->type == CE_ADD_PARTICLESPAWNER) {
|
||||
|
||||
{
|
||||
switch (event->type) {
|
||||
case CE_DELETE_PARTICLESPAWNER: {
|
||||
MutexAutoLock lock(m_spawner_list_lock);
|
||||
if (m_particle_spawners.find(event->add_particlespawner.id) !=
|
||||
m_particle_spawners.end())
|
||||
{
|
||||
delete m_particle_spawners.find(event->add_particlespawner.id)->second;
|
||||
m_particle_spawners.erase(event->add_particlespawner.id);
|
||||
if (m_particle_spawners.find(event->delete_particlespawner.id) !=
|
||||
m_particle_spawners.end()) {
|
||||
delete m_particle_spawners.find(event->delete_particlespawner.id)->second;
|
||||
m_particle_spawners.erase(event->delete_particlespawner.id);
|
||||
}
|
||||
// no allocated memory in delete event
|
||||
break;
|
||||
}
|
||||
video::ITexture *texture =
|
||||
gamedef->tsrc()->getTextureForMesh(*(event->add_particlespawner.texture));
|
||||
case CE_ADD_PARTICLESPAWNER: {
|
||||
{
|
||||
MutexAutoLock lock(m_spawner_list_lock);
|
||||
if (m_particle_spawners.find(event->add_particlespawner.id) !=
|
||||
m_particle_spawners.end()) {
|
||||
delete m_particle_spawners.find(event->add_particlespawner.id)->second;
|
||||
m_particle_spawners.erase(event->add_particlespawner.id);
|
||||
}
|
||||
}
|
||||
|
||||
ParticleSpawner* toadd = new ParticleSpawner(gamedef, smgr, player,
|
||||
event->add_particlespawner.amount,
|
||||
event->add_particlespawner.spawntime,
|
||||
*event->add_particlespawner.minpos,
|
||||
*event->add_particlespawner.maxpos,
|
||||
*event->add_particlespawner.minvel,
|
||||
*event->add_particlespawner.maxvel,
|
||||
*event->add_particlespawner.minacc,
|
||||
*event->add_particlespawner.maxacc,
|
||||
event->add_particlespawner.minexptime,
|
||||
event->add_particlespawner.maxexptime,
|
||||
event->add_particlespawner.minsize,
|
||||
event->add_particlespawner.maxsize,
|
||||
event->add_particlespawner.collisiondetection,
|
||||
event->add_particlespawner.vertical,
|
||||
texture,
|
||||
event->add_particlespawner.id,
|
||||
this);
|
||||
video::ITexture *texture =
|
||||
gamedef->tsrc()->getTextureForMesh(*(event->add_particlespawner.texture));
|
||||
|
||||
/* delete allocated content of event */
|
||||
delete event->add_particlespawner.minpos;
|
||||
delete event->add_particlespawner.maxpos;
|
||||
delete event->add_particlespawner.minvel;
|
||||
delete event->add_particlespawner.maxvel;
|
||||
delete event->add_particlespawner.minacc;
|
||||
delete event->add_particlespawner.texture;
|
||||
delete event->add_particlespawner.maxacc;
|
||||
ParticleSpawner* toadd = new ParticleSpawner(gamedef, smgr, player,
|
||||
event->add_particlespawner.amount,
|
||||
event->add_particlespawner.spawntime,
|
||||
*event->add_particlespawner.minpos,
|
||||
*event->add_particlespawner.maxpos,
|
||||
*event->add_particlespawner.minvel,
|
||||
*event->add_particlespawner.maxvel,
|
||||
*event->add_particlespawner.minacc,
|
||||
*event->add_particlespawner.maxacc,
|
||||
event->add_particlespawner.minexptime,
|
||||
event->add_particlespawner.maxexptime,
|
||||
event->add_particlespawner.minsize,
|
||||
event->add_particlespawner.maxsize,
|
||||
event->add_particlespawner.collisiondetection,
|
||||
event->add_particlespawner.vertical,
|
||||
texture,
|
||||
event->add_particlespawner.id,
|
||||
this);
|
||||
|
||||
{
|
||||
MutexAutoLock lock(m_spawner_list_lock);
|
||||
m_particle_spawners.insert(
|
||||
std::pair<u32, ParticleSpawner*>(
|
||||
event->add_particlespawner.id,
|
||||
toadd));
|
||||
/* delete allocated content of event */
|
||||
delete event->add_particlespawner.minpos;
|
||||
delete event->add_particlespawner.maxpos;
|
||||
delete event->add_particlespawner.minvel;
|
||||
delete event->add_particlespawner.maxvel;
|
||||
delete event->add_particlespawner.minacc;
|
||||
delete event->add_particlespawner.texture;
|
||||
delete event->add_particlespawner.maxacc;
|
||||
|
||||
{
|
||||
MutexAutoLock lock(m_spawner_list_lock);
|
||||
m_particle_spawners.insert(
|
||||
std::pair<u32, ParticleSpawner*>(
|
||||
event->add_particlespawner.id,
|
||||
toadd));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CE_SPAWN_PARTICLE: {
|
||||
video::ITexture *texture =
|
||||
gamedef->tsrc()->getTextureForMesh(*(event->spawn_particle.texture));
|
||||
|
||||
return;
|
||||
}
|
||||
Particle* toadd = new Particle(gamedef, smgr, player, m_env,
|
||||
*event->spawn_particle.pos,
|
||||
*event->spawn_particle.vel,
|
||||
*event->spawn_particle.acc,
|
||||
event->spawn_particle.expirationtime,
|
||||
event->spawn_particle.size,
|
||||
event->spawn_particle.collisiondetection,
|
||||
event->spawn_particle.vertical,
|
||||
texture,
|
||||
v2f(0.0, 0.0),
|
||||
v2f(1.0, 1.0));
|
||||
|
||||
if (event->type == CE_SPAWN_PARTICLE) {
|
||||
video::ITexture *texture =
|
||||
gamedef->tsrc()->getTextureForMesh(*(event->spawn_particle.texture));
|
||||
addParticle(toadd);
|
||||
|
||||
Particle* toadd = new Particle(gamedef, smgr, player, m_env,
|
||||
*event->spawn_particle.pos,
|
||||
*event->spawn_particle.vel,
|
||||
*event->spawn_particle.acc,
|
||||
event->spawn_particle.expirationtime,
|
||||
event->spawn_particle.size,
|
||||
event->spawn_particle.collisiondetection,
|
||||
event->spawn_particle.vertical,
|
||||
texture,
|
||||
v2f(0.0, 0.0),
|
||||
v2f(1.0, 1.0));
|
||||
delete event->spawn_particle.pos;
|
||||
delete event->spawn_particle.vel;
|
||||
delete event->spawn_particle.acc;
|
||||
|
||||
addParticle(toadd);
|
||||
|
||||
delete event->spawn_particle.pos;
|
||||
delete event->spawn_particle.vel;
|
||||
delete event->spawn_particle.acc;
|
||||
|
||||
return;
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user