mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-03-05 01:24:53 +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()?))
|
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
|
/// Processes a single region file
|
||||||
fn process_region(&self, path: &Path, coords: RegionCoords) -> Result<()> {
|
fn process_region(&self, path: &Path, coords: RegionCoords) -> Result<()> {
|
||||||
println!("Processing region r.{}.{}.mca", coords.0, coords.1);
|
println!("Processing region r.{}.{}.mca", coords.0, coords.1);
|
||||||
|
|
||||||
minedmap::io::region::from_file(path)?.foreach_chunk(
|
minedmap::io::region::from_file(path)?.foreach_chunk(
|
||||||
|chunk_coords, data: world::de::Chunk| {
|
|chunk_coords, data: world::de::Chunk| {
|
||||||
(|| -> Result<()> {
|
let _processed_chunk = self
|
||||||
let chunk = world::chunk::Chunk::new(&data)?;
|
.process_chunk(data)
|
||||||
|
.with_context(|| format!("Failed to process chunk {:?}", chunk_coords))?;
|
||||||
let _top_layer = world::layer::top_layer(&chunk, &self.block_types)?;
|
Ok(())
|
||||||
|
|
||||||
Ok(())
|
|
||||||
})()
|
|
||||||
.with_context(|| format!("Failed to process chunk {:?}", chunk_coords))
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue