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