From 170dd409cbf1856600ee5089a95c096dd668b75e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Blot?= Date: Fri, 1 Mar 2019 20:16:11 +0100 Subject: Fix particle spawners not visible since CSM spawner implementation (#8289) * Drop the ID mapper, use a big u64 instead. This will permit to resync server ids properly with the manager code * Modernize some code parts (std::unordered_map, auto) * generate id on client part on U32_MAX + 1 ids, lower are for server ids --- src/client/particles.cpp | 37 +++++++++---------------------------- 1 file changed, 9 insertions(+), 28 deletions(-) (limited to 'src/client/particles.cpp') diff --git a/src/client/particles.cpp b/src/client/particles.cpp index 25cfa081e..ebd52f0f0 100644 --- a/src/client/particles.cpp +++ b/src/client/particles.cpp @@ -261,7 +261,6 @@ ParticleSpawner::ParticleSpawner( u16 attached_id, bool vertical, video::ITexture *texture, - u32 id, const struct TileAnimationParams &anim, u8 glow, ParticleManager *p_manager @@ -423,17 +422,11 @@ void ParticleManager::step(float dtime) void ParticleManager::stepSpawners (float dtime) { MutexAutoLock lock(m_spawner_list_lock); - for (std::map::iterator i = - m_particle_spawners.begin(); - i != m_particle_spawners.end();) - { - if (i->second->get_expired()) - { + for (auto i = m_particle_spawners.begin(); i != m_particle_spawners.end();) { + if (i->second->get_expired()) { delete i->second; m_particle_spawners.erase(i++); - } - else - { + } else { i->second->step(dtime, m_env); ++i; } @@ -443,17 +436,12 @@ void ParticleManager::stepSpawners (float dtime) void ParticleManager::stepParticles (float dtime) { MutexAutoLock lock(m_particle_list_lock); - for(std::vector::iterator i = m_particles.begin(); - i != m_particles.end();) - { - if ((*i)->get_expired()) - { + for (auto i = m_particles.begin(); i != m_particles.end();) { + if ((*i)->get_expired()) { (*i)->remove(); delete *i; i = m_particles.erase(i); - } - else - { + } else { (*i)->step(dtime); ++i; } @@ -464,10 +452,7 @@ void ParticleManager::clearAll () { MutexAutoLock lock(m_spawner_list_lock); MutexAutoLock lock2(m_particle_list_lock); - for(std::map::iterator i = - m_particle_spawners.begin(); - i != m_particle_spawners.end();) - { + for (auto i = m_particle_spawners.begin(); i != m_particle_spawners.end();) { delete i->second; m_particle_spawners.erase(i++); } @@ -509,7 +494,7 @@ void ParticleManager::handleParticleEvent(ClientEvent *event, Client *client, video::ITexture *texture = client->tsrc()->getTextureForMesh(*(event->add_particlespawner.texture)); - ParticleSpawner *toadd = new ParticleSpawner(client, player, + auto toadd = new ParticleSpawner(client, player, event->add_particlespawner.amount, event->add_particlespawner.spawntime, *event->add_particlespawner.minpos, @@ -528,7 +513,6 @@ void ParticleManager::handleParticleEvent(ClientEvent *event, Client *client, event->add_particlespawner.attached_id, event->add_particlespawner.vertical, texture, - event->add_particlespawner.id, event->add_particlespawner.animation, event->add_particlespawner.glow, this); @@ -544,10 +528,7 @@ void ParticleManager::handleParticleEvent(ClientEvent *event, Client *client, { MutexAutoLock lock(m_spawner_list_lock); - m_particle_spawners.insert( - std::pair( - event->add_particlespawner.id, - toadd)); + m_particle_spawners[event->add_particlespawner.id] = toadd; } break; } -- cgit v1.2.3