diff --git a/client/src/lib.rs b/client/src/lib.rs index 64cf3059ef..84d4c29151 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -194,9 +194,9 @@ impl Client { { let chunk_pos = self.state.terrain().pos_key(pos.0.map(|e| e as i32)); - for i in chunk_pos.x - 3..chunk_pos.x + 3 { - for j in chunk_pos.y - 3..chunk_pos.y + 3 { - for k in 0..1 { + for i in chunk_pos.x - 1..chunk_pos.x + 1 { + for j in chunk_pos.y - 1..chunk_pos.y + 1 { + for k in 0..2 { let key = Vec3::new(i, j, k); if self.state.terrain().get_key(key).is_none() && !self.pending_chunks.contains(&key) diff --git a/common/src/net/post2.rs b/common/src/net/post2.rs index bb79ab3531..0f198ba7c6 100644 --- a/common/src/net/post2.rs +++ b/common/src/net/post2.rs @@ -73,6 +73,7 @@ impl PostOffice { match self.listener.accept() { Ok((stream, sock)) => new.push(PostBox::from_stream(stream).unwrap()), Err(e) if e.kind() == io::ErrorKind::WouldBlock => break, + Err(e) if e.kind() == io::ErrorKind::Interrupted => {}, Err(e) => { self.error = Some(e.into()); break; @@ -179,7 +180,7 @@ impl PostBox { } // Try getting messages from the send channel - for _ in 0..100 { + for _ in 0..1000 { match send_rx.try_recv() { Ok(send_msg) => { // Serialize message @@ -209,7 +210,7 @@ impl PostBox { } // Try sending bytes through the TCP stream - for _ in 0..100 { + for _ in 0..1000 { //println!("HERE! Outgoing len: {}", outgoing_chunks.len()); match outgoing_chunks.pop_front() { Some(chunk) => match stream.write_all(&chunk) { @@ -230,12 +231,13 @@ impl PostBox { } // Try receiving bytes from the TCP stream - for _ in 0..100 { + for _ in 0..1000 { let mut buf = [0; 1024]; match stream.read(&mut buf) { Ok(n) => incoming_buf.extend_from_slice(&buf[0..n]), Err(e) if e.kind() == io::ErrorKind::WouldBlock => break, + Err(e) if e.kind() == io::ErrorKind::Interrupted => {}, // Worker error Err(e) => { recv_tx.send(Err(e.into())).unwrap(); @@ -245,7 +247,7 @@ impl PostBox { } // Try turning bytes into messages - for _ in 0..100 { + for _ in 0..1000 { match incoming_buf.get(0..8) { Some(len_bytes) => { let len = usize::from_le_bytes(<[u8; 8]>::try_from(len_bytes).unwrap()); // Can't fail @@ -254,13 +256,14 @@ impl PostBox { recv_tx.send(Err(Error::InvalidMessage)).unwrap(); break 'work; } else if incoming_buf.len() >= len + 8 { - let deserialize_result = bincode::deserialize(&incoming_buf[8..len + 8]); - - if let Err(e) = &deserialize_result { - println!("DESERIALIZE ERROR: {:?}", e); + match bincode::deserialize(&incoming_buf[8..len + 8]) { + Ok(msg) => recv_tx.send(Ok(msg)).unwrap(), + Err(err) => { + println!("Invalid message: {:?}", err); + recv_tx.send(Err(err.into())).unwrap() + }, } - recv_tx.send(deserialize_result.map_err(|e| e.into())); incoming_buf = incoming_buf.split_off(len + 8); } else { break; diff --git a/world/src/lib.rs b/world/src/lib.rs index 3a42b2e22b..f8d4857c13 100644 --- a/world/src/lib.rs +++ b/world/src/lib.rs @@ -40,10 +40,15 @@ impl World { let wpos = lpos + chunk_pos * chunk.get_size().map(|e| e as i32); let wposf = wpos.map(|e| e as f64); - let freq = 1.0 / 64.0; - let ampl = 12.0; - let offs = 16.0; - let height = perlin_nz.get(Vec2::from(wposf * freq).into_array()) * ampl + offs; + let freq = 1.0 / 128.0; + let ampl = 32.0; + let small_freq = 1.0 / 16.0; + let small_ampl = 8.0; + let offs = 32.0; + let height = + perlin_nz.get(Vec2::from(wposf * freq).into_array()) * ampl + + perlin_nz.get(Vec2::from(wposf * small_freq).into_array()) * small_ampl + + offs; chunk.set(lpos, if wposf.z < height { if wposf.z < height - 1.0 {