Run terrain persistence before /reload_chunks

This commit is contained in:
Maxicarlos08 2023-10-16 18:39:41 +02:00
parent 3605e49a00
commit 0da10c1dfc
No known key found for this signature in database
2 changed files with 10 additions and 2 deletions

View File

@ -3489,6 +3489,12 @@ fn handle_reload_chunks(
_args: Vec<String>,
_action: &ServerChatCommand,
) -> CmdResult<()> {
#[cfg(feature = "persistent_world")]
server
.state
.ecs()
.write_resource::<crate::terrain_persistence::TerrainPersistence>()
.unload_all();
server.state.clear_terrain();
Ok(())

View File

@ -380,12 +380,14 @@ impl<'a> System<'a> for Sys {
chunk_generator.cancel_if_pending(key);
// If you want to trigger any behaivour on unload, do it in `Server::tick` by
// reading `TerrainChanges::removed_chunks` since chunks can also be removed
// using eg. /reload_chunks
// TODO: code duplication for chunk insertion between here and state.rs
terrain.remove(key).map(|chunk| {
terrain_changes.removed_chunks.insert(key);
chunk
// The rtsim hook to unload the chunks is later called in
// the main server tick function
})
})
.collect::<Vec<_>>();