feat(gameplay): add packet to clear all chunks on server rebuild

Add new packet S2C_ClearAllChunks (ID 3005) to notify clients when the server rebuilds its world. Clients respond by clearing their chunk cache and requesting fresh chunks. Shift UPDATE_TIME packet ID to 3006 to accommodate.
This commit is contained in:
2026-06-27 11:20:51 +08:00
parent aace0b4888
commit 7b6c11e904
6 changed files with 53 additions and 4 deletions

View File

@@ -78,8 +78,8 @@ asio::awaitable<void> NetworkClient::read_loop() {
} break;
case to_num(PacketEnum::CHUNK_DATA_RSP): {
ChunkDataRsp rsp;
Logger::info("Client: Receive Chunk Data rsp, size {}mb",
body_data.size() / 1024.0f / 1024);
// Logger::info("Client: Receive Chunk Data rsp, size {}mb",
// body_data.size() / 1024.0f / 1024);
if (decode_packet(rsp, body_data, header)) {
m_world.receive_chunk(std::move(rsp));
}
@@ -109,6 +109,15 @@ asio::awaitable<void> NetworkClient::read_loop() {
m_world.receive_player_logout(*rsp);
}
} break;
case to_num(PacketEnum::S2C_CLEAR_ALL_CHUNKS): {
auto* rsp = Arena::Create<S2C_ClearAllChunks>(&arena);
if (decode_packet(*rsp, body_data, header)) {
if (rsp->clear()) {
Logger::info("Client Clear All Chunk");
m_world.rebuild_world();
}
}
} break;
}
}
} catch (const asio::system_error& e) {