mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Addressing code review.
This commit is contained in:
parent
20f57cf7f3
commit
9ba64ca57f
@ -1339,7 +1339,10 @@ impl Server {
|
||||
let chunk_tx = self.chunk_tx.clone();
|
||||
let world = self.world.clone();
|
||||
self.thread_pool.execute(move || {
|
||||
let _ = chunk_tx.send((key, world.generate_chunk(key, &cancel).map_err(|_| entity)));
|
||||
let payload = world
|
||||
.generate_chunk(key, || cancel.load(Ordering::Relaxed))
|
||||
.map_err(|_| entity);
|
||||
let _ = chunk_tx.send((key, payload));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -28,10 +28,7 @@ use common::{
|
||||
vol::{ReadVol, RectVolSize, Vox, WriteVol},
|
||||
};
|
||||
use rand::Rng;
|
||||
use std::{
|
||||
sync::atomic::{AtomicBool, Ordering},
|
||||
time::Duration,
|
||||
};
|
||||
use std::time::Duration;
|
||||
use vek::*;
|
||||
|
||||
#[derive(Debug)]
|
||||
@ -71,7 +68,7 @@ impl World {
|
||||
pub fn generate_chunk(
|
||||
&self,
|
||||
chunk_pos: Vec2<i32>,
|
||||
flag: &AtomicBool,
|
||||
mut should_continue: impl FnMut() -> bool,
|
||||
) -> Result<(TerrainChunk, ChunkSupplement), ()> {
|
||||
let air = Block::empty();
|
||||
let stone = Block::new(BlockKind::Dense, Rgb::new(200, 220, 255));
|
||||
@ -108,7 +105,7 @@ impl World {
|
||||
let mut chunk = TerrainChunk::new(base_z, stone, air, meta);
|
||||
for x in 0..TerrainChunkSize::RECT_SIZE.x as i32 {
|
||||
for y in 0..TerrainChunkSize::RECT_SIZE.y as i32 {
|
||||
if flag.load(Ordering::Relaxed) {
|
||||
if should_continue() {
|
||||
return Err(());
|
||||
};
|
||||
let wpos2d = Vec2::new(x, y)
|
||||
|
Loading…
Reference in New Issue
Block a user