perf(gameplay): batch entity updates into single packet

Aggregate per-entity update messages into S2CEntityUpdateBatch and
broadcast once per tick. Reuse serialized packets in several broadcast
loops to avoid repeated make_packet calls.
This commit is contained in:
2026-08-06 16:48:18 +08:00
parent 3534acd90f
commit c6a75e709e
8 changed files with 100 additions and 64 deletions

View File

@@ -87,7 +87,7 @@ void ClientEntityManager::receive_entity_destory(EntityID id) {
m_tasks.emplace(Command::DESTORY, id);
}
void ClientEntityManager::receive_entity_update(S2CEntityUpdate& msg) {
void ClientEntityManager::receive_entity_update(const S2CEntityUpdate& msg) {
UpdateInfo e;
e.id = msg.id();
e.pos = Tools::get_net_vec3(msg.pos());
@@ -96,6 +96,12 @@ void ClientEntityManager::receive_entity_update(S2CEntityUpdate& msg) {
m_tasks.emplace(Command::UPDATE, std::move(e));
}
void ClientEntityManager::receive_entity_update(S2CEntityUpdateBatch& msg) {
for (auto& u : msg.updates()) {
receive_entity_update(u);
}
}
void ClientEntityManager::destory(EntityID id) {
auto client = m_world.get_client();
Arena arena;