From c8e02c6f86491ae99c2eb36f3d017b71312806fd Mon Sep 17 00:00:00 2001 From: Vijfhoek Date: Mon, 7 Jun 2021 02:26:28 +0200 Subject: [PATCH] Fix saving --- src/world/mod.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/world/mod.rs b/src/world/mod.rs index a555053..7f18948 100644 --- a/src/world/mod.rs +++ b/src/world/mod.rs @@ -123,15 +123,19 @@ impl Renderable for World { if let Some(chunk) = self.chunks.get(&position) { if let Err(err) = chunk.save(position, &self.chunk_database) { eprintln!("Failed to save chunk {:?}: {:?}", position, err); - } else if unload { + } else { + if unload { self.chunks.remove(&position); if DEBUG_IO { println!("Saved and unloaded chunk {:?}", position); } - } else if DEBUG_IO { + } else { + if DEBUG_IO { println!("Saved chunk {:?}", position); } + } + } } else { eprintln!("Tried to save unloaded chunk {:?}", position); } @@ -292,8 +296,7 @@ impl World { chunk.blocks[by][bz][bx] = block; } - self.chunk_save_queue - .push_back((chunk_position / CHUNK_ISIZE, false)); + self.enqueue_chunk_save(chunk_position, false); } fn calc_scale(vector: Vector3, scalar: f32) -> f32 {