diff options
author | red-001 <red-001@outlook.ie> | 2018-01-20 22:31:53 +0000 |
---|---|---|
committer | Loïc Blot <nerzhul@users.noreply.github.com> | 2018-01-20 23:31:53 +0100 |
commit | 5dab7426451842793b183fbd961ad2ae83c8acbd (patch) | |
tree | 7d9d643bd94f955c9745e073a55e75dac985fbb0 /src/network | |
parent | da80e8af8adee493e698227cfc201859a1515c81 (diff) | |
download | minetest-5dab7426451842793b183fbd961ad2ae83c8acbd.tar.gz minetest-5dab7426451842793b183fbd961ad2ae83c8acbd.tar.bz2 minetest-5dab7426451842793b183fbd961ad2ae83c8acbd.zip |
[CSM] Add functions to create particles and particlespawners. (#6072)
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/clientpackethandler.cpp | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/network/clientpackethandler.cpp b/src/network/clientpackethandler.cpp index bd0cd6a08..db3655875 100644 --- a/src/network/clientpackethandler.cpp +++ b/src/network/clientpackethandler.cpp @@ -956,7 +956,7 @@ void Client::handleCommand_AddParticleSpawner(NetworkPacket* pkt) float minsize; float maxsize; bool collisiondetection; - u32 id; + u32 server_id; *pkt >> amount >> spawntime >> minpos >> maxpos >> minvel >> maxvel >> minacc >> maxacc >> minexptime >> maxexptime >> minsize @@ -964,7 +964,7 @@ void Client::handleCommand_AddParticleSpawner(NetworkPacket* pkt) std::string texture = pkt->readLongString(); - *pkt >> id; + *pkt >> server_id; bool vertical = false; bool collision_removal = false; @@ -984,6 +984,9 @@ void Client::handleCommand_AddParticleSpawner(NetworkPacket* pkt) glow = readU8(is); } catch (...) {} + u32 client_id = m_particle_manager.getSpawnerId(); + m_particles_server_to_client[server_id] = client_id; + ClientEvent *event = new ClientEvent(); event->type = CE_ADD_PARTICLESPAWNER; event->add_particlespawner.amount = amount; @@ -1003,7 +1006,7 @@ void Client::handleCommand_AddParticleSpawner(NetworkPacket* pkt) event->add_particlespawner.attached_id = attached_id; event->add_particlespawner.vertical = vertical; event->add_particlespawner.texture = new std::string(texture); - event->add_particlespawner.id = id; + event->add_particlespawner.id = client_id; event->add_particlespawner.animation = animation; event->add_particlespawner.glow = glow; @@ -1013,12 +1016,19 @@ void Client::handleCommand_AddParticleSpawner(NetworkPacket* pkt) void Client::handleCommand_DeleteParticleSpawner(NetworkPacket* pkt) { - u32 id; - *pkt >> id; + u32 server_id; + *pkt >> server_id; + + u32 client_id; + auto i = m_particles_server_to_client.find(server_id); + if (i != m_particles_server_to_client.end()) + client_id = i->second; + else + return; ClientEvent *event = new ClientEvent(); event->type = CE_DELETE_PARTICLESPAWNER; - event->delete_particlespawner.id = id; + event->delete_particlespawner.id = client_id; m_client_event_queue.push(event); } |