aboutsummaryrefslogtreecommitdiff
path: root/src/client/particles.cpp
diff options
context:
space:
mode:
authorLoïc Blot <nerzhul@users.noreply.github.com>2019-03-01 20:16:11 +0100
committerGitHub <noreply@github.com>2019-03-01 20:16:11 +0100
commit170dd409cbf1856600ee5089a95c096dd668b75e (patch)
treedd18026fbfe1e9c76f9081864174266109809996 /src/client/particles.cpp
parent111f1dc9c5f336f5b4f12c15940dc4cc2cbe7f82 (diff)
downloadhax-minetest-server-170dd409cbf1856600ee5089a95c096dd668b75e.tar.gz
hax-minetest-server-170dd409cbf1856600ee5089a95c096dd668b75e.zip
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
Diffstat (limited to 'src/client/particles.cpp')
-rw-r--r--src/client/particles.cpp37
1 files changed, 9 insertions, 28 deletions
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<u32, ParticleSpawner*>::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<Particle*>::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<u32, ParticleSpawner*>::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<u32, ParticleSpawner*>(
- event->add_particlespawner.id,
- toadd));
+ m_particle_spawners[event->add_particlespawner.id] = toadd;
}
break;
}