mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-03-04 17:23:33 +01:00
main: factor out process_chunk() method
This commit is contained in:
parent
d77dcce778
commit
18cecb947e
1 changed files with 10 additions and 8 deletions
18
src/main.rs
18
src/main.rs
|
@ -43,20 +43,22 @@ impl RegionProcessor {
|
|||
Some((x.parse().ok()?, z.parse().ok()?))
|
||||
}
|
||||
|
||||
/// Processes a single chunk
|
||||
fn process_chunk(&self, data: world::de::Chunk) -> Result<Box<world::layer::BlockInfoArray>> {
|
||||
let chunk = world::chunk::Chunk::new(&data)?;
|
||||
world::layer::top_layer(&chunk, &self.block_types)
|
||||
}
|
||||
|
||||
/// Processes a single region file
|
||||
fn process_region(&self, path: &Path, coords: RegionCoords) -> Result<()> {
|
||||
println!("Processing region r.{}.{}.mca", coords.0, coords.1);
|
||||
|
||||
minedmap::io::region::from_file(path)?.foreach_chunk(
|
||||
|chunk_coords, data: world::de::Chunk| {
|
||||
(|| -> Result<()> {
|
||||
let chunk = world::chunk::Chunk::new(&data)?;
|
||||
|
||||
let _top_layer = world::layer::top_layer(&chunk, &self.block_types)?;
|
||||
|
||||
Ok(())
|
||||
})()
|
||||
.with_context(|| format!("Failed to process chunk {:?}", chunk_coords))
|
||||
let _processed_chunk = self
|
||||
.process_chunk(data)
|
||||
.with_context(|| format!("Failed to process chunk {:?}", chunk_coords))?;
|
||||
Ok(())
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue