From efe284a6730b61403e5ea5512dc9a345e3ffba6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=A4rtens?= Date: Wed, 11 May 2022 15:44:48 +0200 Subject: [PATCH] make the client request a few more chunks to compensate for the delay in serialisation --- client/src/lib.rs | 9 ++++++++- server/src/sys/chunk_serialize.rs | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/client/src/lib.rs b/client/src/lib.rs index 7a1c311dfa..51d47faa2d 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -1662,6 +1662,7 @@ impl Client { self.state.remove_chunk(key); } + let mut current_tick_send_chunk_requests = 0; // Request chunks from the server. self.loaded_distance = ((view_distance * TerrainChunkSize::RECT_SIZE.x) as f32).powi(2); // +1 so we can find a chunk that's outside the vd for better fog @@ -1695,10 +1696,16 @@ impl Client { for key in keys.iter() { if self.state.terrain().get_key(*key).is_none() { if !skip_mode && !self.pending_chunks.contains_key(key) { - if self.pending_chunks.len() < 4 { + const TOTAL_PENDING_CHUNKS_LIMIT: usize = 12; + const CURRENT_TICK_PENDING_CHUNKS_LIMIT: usize = 2; + if self.pending_chunks.len() < TOTAL_PENDING_CHUNKS_LIMIT + && current_tick_send_chunk_requests + < CURRENT_TICK_PENDING_CHUNKS_LIMIT + { self.send_msg_err(ClientGeneral::TerrainChunkRequest { key: *key, })?; + current_tick_send_chunk_requests += 1; self.pending_chunks.insert(*key, Instant::now()); } else { skip_mode = true; diff --git a/server/src/sys/chunk_serialize.rs b/server/src/sys/chunk_serialize.rs index 6cb3bd35d1..724e757309 100644 --- a/server/src/sys/chunk_serialize.rs +++ b/server/src/sys/chunk_serialize.rs @@ -49,9 +49,9 @@ impl<'a> System<'a> for Sys { chunk_sender, ): Self::SystemData, ) { - // Only operate once per second + // Only operate twice per second //TODO: move out of this system and now even spawn this. - if tick.0.rem_euclid(30) != 0 { + if tick.0.rem_euclid(15) != 0 { return; }