1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-10-05 19:31:04 +00:00

Network: Batch individual particle packets (#16458)

also bumps proto ver
This commit is contained in:
Lars Müller 2025-09-22 18:46:34 +02:00 committed by GitHub
parent 4c29bf6923
commit 5f5ea13251
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 116 additions and 51 deletions

View file

@ -34,6 +34,7 @@
#include "skyparams.h"
#include "particles.h"
#include <memory>
#include <sstream>
const char *accessDeniedStrings[SERVER_ACCESSDENIED_MAX] = {
N_("Invalid password"),
@ -979,6 +980,29 @@ void Client::handleCommand_SpawnParticle(NetworkPacket* pkt)
m_client_event_queue.push(event);
}
void Client::handleCommand_SpawnParticleBatch(NetworkPacket *pkt)
{
std::stringstream particle_batch_data(std::ios::binary | std::ios::in | std::ios::out);
{
std::istringstream compressed(pkt->readLongString(), std::ios::binary);
decompressZstd(compressed, particle_batch_data);
}
while (particle_batch_data.peek() != EOF) {
auto p = std::make_unique<ParticleParameters>();
{
std::istringstream particle_data(deSerializeString32(particle_batch_data), std::ios::binary);
p->deSerialize(particle_data, m_proto_ver);
}
ClientEvent *event = new ClientEvent();
event->type = CE_SPAWN_PARTICLE;
event->spawn_particle = p.release();
m_client_event_queue.push(event);
}
}
void Client::handleCommand_AddParticleSpawner(NetworkPacket* pkt)
{
std::string datastring(pkt->getString(0), pkt->getSize());