diff options
author | Loïc Blot <nerzhul@users.noreply.github.com> | 2019-03-01 20:16:11 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-01 20:16:11 +0100 |
commit | 170dd409cbf1856600ee5089a95c096dd668b75e (patch) | |
tree | dd18026fbfe1e9c76f9081864174266109809996 /src/client/particles.h | |
parent | 111f1dc9c5f336f5b4f12c15940dc4cc2cbe7f82 (diff) | |
download | dragonfireclient-170dd409cbf1856600ee5089a95c096dd668b75e.tar.xz |
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.h')
-rw-r--r-- | src/client/particles.h | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/src/client/particles.h b/src/client/particles.h index 3392e7e95..353743372 100644 --- a/src/client/particles.h +++ b/src/client/particles.h @@ -132,7 +132,6 @@ public: u16 attached_id, bool vertical, video::ITexture *texture, - u32 id, const struct TileAnimationParams &anim, u8 glow, ParticleManager* p_manager); @@ -196,12 +195,16 @@ public: void addNodeParticle(IGameDef *gamedef, LocalPlayer *player, v3s16 pos, const MapNode &n, const ContentFeatures &f); - u32 getSpawnerId() const + /** + * This function is only used by client particle spawners + * + * We don't need to check the particle spawner list because client ID will n + * ever overlap (u64) + * @return new id + */ + u64 generateSpawnerId() { - for (u32 id = 0;; ++id) { // look for unused particlespawner id - if (m_particle_spawners.find(id) == m_particle_spawners.end()) - return id; - } + return m_next_particle_spawner_id++; } protected: @@ -209,13 +212,16 @@ protected: private: - void stepParticles (float dtime); - void stepSpawners (float dtime); + void stepParticles(float dtime); + void stepSpawners(float dtime); - void clearAll (); + void clearAll(); std::vector<Particle*> m_particles; - std::map<u32, ParticleSpawner*> m_particle_spawners; + std::unordered_map<u64, ParticleSpawner*> m_particle_spawners; + // Start the particle spawner ids generated from here after u32_max. lower values are + // for server sent spawners. + u64 m_next_particle_spawner_id = U32_MAX + 1; ClientEnvironment* m_env; std::mutex m_particle_list_lock; |