mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-20 11:35:21 +02:00
Network: Batch individual particle packets (#16458)
also bumps proto ver
This commit is contained in:
@@ -111,6 +111,7 @@ const ToClientCommandHandler toClientCommandTable[TOCLIENT_NUM_MSG_TYPES] =
|
||||
{ "TOCLIENT_FORMSPEC_PREPEND", TOCLIENT_STATE_CONNECTED, &Client::handleCommand_FormspecPrepend }, // 0x61,
|
||||
{ "TOCLIENT_MINIMAP_MODES", TOCLIENT_STATE_CONNECTED, &Client::handleCommand_MinimapModes }, // 0x62,
|
||||
{ "TOCLIENT_SET_LIGHTING", TOCLIENT_STATE_CONNECTED, &Client::handleCommand_SetLighting }, // 0x63,
|
||||
{ "TOCLIENT_SPAWN_PARTICLE_BATCH", TOCLIENT_STATE_CONNECTED, &Client::handleCommand_SpawnParticleBatch }, // 0x64,
|
||||
};
|
||||
|
||||
const static ServerCommandFactory null_command_factory = { nullptr, 0, false };
|
||||
|
@@ -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());
|
||||
|
@@ -68,10 +68,13 @@
|
||||
PROTOCOL VERSION 49
|
||||
Support of showing a player inventory using 'core.show_formspec'
|
||||
[scheduled bump for 5.13.0]
|
||||
PROTOCOL VERSION 50
|
||||
Support for TOCLIENT_SPAWN_PARTICLE_BATCH
|
||||
[scheduled bump for 5.14.0]
|
||||
*/
|
||||
|
||||
// Note: Also update core.protocol_versions in builtin when bumping
|
||||
const u16 LATEST_PROTOCOL_VERSION = 49;
|
||||
const u16 LATEST_PROTOCOL_VERSION = 50;
|
||||
|
||||
// See also formspec [Version History] in doc/lua_api.md
|
||||
const u16 FORMSPEC_API_VERSION = 10;
|
||||
|
@@ -288,6 +288,8 @@ enum ToClientCommand : u16
|
||||
|
||||
TOCLIENT_SPAWN_PARTICLE = 0x46,
|
||||
/*
|
||||
ParticleParameters params:
|
||||
|
||||
using range<T> = RangedParameter<T> {
|
||||
T min, max
|
||||
f32 bias
|
||||
@@ -692,7 +694,14 @@ enum ToClientCommand : u16
|
||||
f32 center_weight_power
|
||||
*/
|
||||
|
||||
TOCLIENT_NUM_MSG_TYPES = 0x64,
|
||||
TOCLIENT_SPAWN_PARTICLE_BATCH = 0x64,
|
||||
/*
|
||||
std::string data, zstd-compressed, for each particle:
|
||||
u32 len
|
||||
u8[len] serialized ParticleParameters
|
||||
*/
|
||||
|
||||
TOCLIENT_NUM_MSG_TYPES = 0x65,
|
||||
};
|
||||
|
||||
enum ToServerCommand : u16
|
||||
|
@@ -212,4 +212,5 @@ const ClientCommandFactory clientCommandFactoryTable[TOCLIENT_NUM_MSG_TYPES] =
|
||||
{ "TOCLIENT_FORMSPEC_PREPEND", 0, true }, // 0x61
|
||||
{ "TOCLIENT_MINIMAP_MODES", 0, true }, // 0x62
|
||||
{ "TOCLIENT_SET_LIGHTING", 0, true }, // 0x63
|
||||
{ "TOCLIENT_SPAWN_PARTICLE_BATCH", 0, true }, // 0x64
|
||||
};
|
||||
|
Reference in New Issue
Block a user