mirror of
https://github.com/minetest/minetest.git
synced 2025-07-05 01:10:22 +02:00
Fix sound and particlespawner id generation (#14059)
* Fix server sound ids being reused to early * Fix particlespawner id generation It always returned 0. Also, now the ids always grow, to make a conflict with ids in lua unlikely.
This commit is contained in:
@ -1638,11 +1638,11 @@ u32 ServerEnvironment::addParticleSpawner(float exptime)
|
||||
float time = exptime > 0.f ? exptime : PARTICLE_SPAWNER_NO_EXPIRY;
|
||||
|
||||
u32 free_id = m_particle_spawners_id_last_used;
|
||||
while (free_id == 0 || m_particle_spawners.find(free_id) != m_particle_spawners.end()) {
|
||||
do {
|
||||
free_id++;
|
||||
if (free_id == m_particle_spawners_id_last_used)
|
||||
return 0; // full
|
||||
free_id++;
|
||||
}
|
||||
} while (free_id == 0 || m_particle_spawners.find(free_id) != m_particle_spawners.end());
|
||||
|
||||
m_particle_spawners_id_last_used = free_id;
|
||||
m_particle_spawners[free_id] = time;
|
||||
|
Reference in New Issue
Block a user