aboutsummaryrefslogtreecommitdiff
path: root/src/network/clientpackethandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/clientpackethandler.cpp')
-rw-r--r--src/network/clientpackethandler.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/network/clientpackethandler.cpp b/src/network/clientpackethandler.cpp
index 3fadc3cb0..2d02d0755 100644
--- a/src/network/clientpackethandler.cpp
+++ b/src/network/clientpackethandler.cpp
@@ -977,7 +977,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
@@ -985,7 +985,7 @@ void Client::handleCommand_AddParticleSpawner(NetworkPacket* pkt)
std::string texture = pkt->readLongString();
- *pkt >> id;
+ *pkt >> server_id;
bool vertical = false;
bool collision_removal = false;
@@ -1007,6 +1007,9 @@ void Client::handleCommand_AddParticleSpawner(NetworkPacket* pkt)
object_collision = 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;
@@ -1027,7 +1030,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;
@@ -1037,12 +1040,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);
}