From ded39c285e7a66be42a969e749ad4f853c70b1a4 Mon Sep 17 00:00:00 2001 From: griffi-gh Date: Mon, 16 Jan 2023 19:58:08 +0100 Subject: [PATCH] owo --- src/game/world/thread.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/game/world/thread.rs b/src/game/world/thread.rs index 7cc4106..86b2c5c 100644 --- a/src/game/world/thread.rs +++ b/src/game/world/thread.rs @@ -4,7 +4,7 @@ use std::{ collections::HashMap, mem }; -use super::chunk::{ChunkData, Chunk}; +use super::chunk::{ChunkData, Chunk, DesiredState}; mod world_gen; mod mesh_gen; @@ -35,9 +35,15 @@ impl WorldThreading { log::warn!("load: discarded {}, reason: chunk no longer exists", position); return false } + if !matches!(chunks.get(position).unwrap().desired, DesiredState::Loaded | DesiredState::Rendered) { + log::warn!("load: discarded {}, reason: state undesired", position); + return false + } if !handle.as_ref().expect("Something went terribly wrong").is_finished() { + //task not finished yet, keep it and wait return true } + log::info!("load: done {}", position); let handle = mem::take(handle).unwrap(); let data = handle.join().unwrap(); chunks.get_mut(position).unwrap().block_data = Some(data);