mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-08-09 02:07:04 +08:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user