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

@@ -392,6 +392,16 @@ void ServerWorld::rebuild_world() {
start_thread_pool();
start_gen_thread();
need_gen(std::nullopt);
Arena arena;
auto* rsp = Arena::Create<S2C_ClearAllChunks>(&arena);
rsp->set_clear(true);
{
std::lock_guard lock(m_player_mutex);
for (auto& [uuid, player] : m_players) {
player.get_session()->send(make_packet(*rsp));
}
}
m_is_rebuilding = false;
}