mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-07-11 01:39:05 +02:00
world/layer: return None from top_layer() for empty chunks
Allow ignoring these chunks for the light map as well.
This commit is contained in:
parent
202364bfca
commit
4fd316f3fc
3 changed files with 24 additions and 5 deletions
12
src/main.rs
12
src/main.rs
|
@ -98,7 +98,10 @@ impl<'a> RegionProcessor<'a> {
|
|||
}
|
||||
|
||||
/// Processes a single chunk
|
||||
fn process_chunk(&self, data: world::de::Chunk) -> Result<Box<world::layer::BlockInfoArray>> {
|
||||
fn process_chunk(
|
||||
&self,
|
||||
data: world::de::Chunk,
|
||||
) -> Result<Option<Box<world::layer::BlockInfoArray>>> {
|
||||
let chunk = world::chunk::Chunk::new(&data, &self.block_types)?;
|
||||
world::layer::top_layer(&chunk)
|
||||
}
|
||||
|
@ -127,9 +130,12 @@ impl<'a> RegionProcessor<'a> {
|
|||
|
||||
minedmap::io::region::from_file(path)?.foreach_chunk(
|
||||
|chunk_coords, data: world::de::Chunk| {
|
||||
let processed_chunk = self
|
||||
let Some(processed_chunk) = self
|
||||
.process_chunk(data)
|
||||
.with_context(|| format!("Failed to process chunk {:?}", chunk_coords))?;
|
||||
.with_context(|| format!("Failed to process chunk {:?}", chunk_coords))?
|
||||
else {
|
||||
return Ok(());
|
||||
};
|
||||
processed_region[chunk_coords] = Some(processed_chunk);
|
||||
Ok(())
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue