Fixing previous commit.

This commit is contained in:
Joshua Yanovski 2019-09-16 03:51:08 +02:00
parent b4ad76372b
commit 9a4e5e06f2

View File

@ -65,7 +65,8 @@ impl World {
BlockGen::new(self, ColumnGen::new(&self.sim))
}
pub fn generate_chunk(&self, chunk_pos: Vec2<i32>) -> (TerrainChunk, ChunkSupplement) {
pub fn generate_chunk(&self, chunk_pos: Vec2<i32>,
flag: &AtomicBool) -> Result<(TerrainChunk, ChunkSupplement), ()> {
let air = Block::empty();
let stone = Block::new(BlockKind::Dense, Rgb::new(200, 220, 255));
let water = Block::new(BlockKind::Water, Rgb::new(60, 90, 190));
@ -81,7 +82,7 @@ impl World {
{
Some((base_z, sim_chunk)) => (base_z as i32, sim_chunk),
None => {
return (
return Ok((
TerrainChunk::new(
CONFIG.sea_level as i32,
water,
@ -89,7 +90,7 @@ impl World {
TerrainChunkMeta::void(),
),
ChunkSupplement::default(),
)
))
}
};
@ -101,6 +102,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) { return Err(()) };
let wpos2d = Vec2::new(x, y)
+ Vec2::from(chunk_pos) * TerrainChunkSize::RECT_SIZE.map(|e| e as i32);
@ -151,7 +153,7 @@ impl World {
},
};
(chunk, supplement)
Ok((chunk, supplement))
}
}