mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-03-04 17:23:33 +01:00
core/region_processor: make regular processing errors non-fatal again
Never fail because of invalid save files.
This commit is contained in:
parent
09374d755e
commit
fd48f94f16
1 changed files with 40 additions and 24 deletions
|
@ -5,7 +5,7 @@ use std::{ffi::OsStr, path::Path, time::SystemTime};
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use indexmap::IndexSet;
|
use indexmap::IndexSet;
|
||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
use tracing::{debug, info};
|
use tracing::{debug, info, warn};
|
||||||
|
|
||||||
use super::common::*;
|
use super::common::*;
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -168,31 +168,47 @@ impl<'a> RegionProcessor<'a> {
|
||||||
|
|
||||||
debug!("Processing region r.{}.{}.mca", coords.x, coords.z);
|
debug!("Processing region r.{}.{}.mca", coords.x, coords.z);
|
||||||
|
|
||||||
crate::nbt::region::from_file(input_path)?.foreach_chunk(
|
if let Err(err) = (|| -> Result<()> {
|
||||||
|chunk_coords, data: world::de::Chunk| {
|
crate::nbt::region::from_file(input_path)?.foreach_chunk(
|
||||||
let Some(layer::LayerData {
|
|chunk_coords, data: world::de::Chunk| {
|
||||||
blocks,
|
let Some(layer::LayerData {
|
||||||
biomes,
|
blocks,
|
||||||
block_light,
|
biomes,
|
||||||
depths,
|
block_light,
|
||||||
}) = self
|
depths,
|
||||||
.process_chunk(&mut processed_region.biome_list, data)
|
}) = self
|
||||||
.with_context(|| format!("Failed to process chunk {:?}", chunk_coords))?
|
.process_chunk(&mut processed_region.biome_list, data)
|
||||||
else {
|
.with_context(|| format!("Failed to process chunk {:?}", chunk_coords))?
|
||||||
return Ok(());
|
else {
|
||||||
};
|
return Ok(());
|
||||||
processed_region.chunks[chunk_coords] = Some(Box::new(ProcessedChunk {
|
};
|
||||||
blocks,
|
processed_region.chunks[chunk_coords] = Some(Box::new(ProcessedChunk {
|
||||||
biomes,
|
blocks,
|
||||||
depths,
|
biomes,
|
||||||
}));
|
depths,
|
||||||
|
}));
|
||||||
|
|
||||||
let chunk_lightmap = Self::render_chunk_lightmap(block_light);
|
let chunk_lightmap = Self::render_chunk_lightmap(block_light);
|
||||||
overlay_chunk(&mut lightmap, &chunk_lightmap, chunk_coords);
|
overlay_chunk(&mut lightmap, &chunk_lightmap, chunk_coords);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
},
|
},
|
||||||
)?;
|
)
|
||||||
|
})() {
|
||||||
|
if output_timestamp.is_some() && lightmap_timestamp.is_some() {
|
||||||
|
warn!(
|
||||||
|
"Failed to process region {:?}, using old data: {:?}",
|
||||||
|
coords, err
|
||||||
|
);
|
||||||
|
return Ok(RegionProcessorStatus::ErrorOk);
|
||||||
|
} else {
|
||||||
|
warn!(
|
||||||
|
"Failed to process region {:?}, no old data available: {:?}",
|
||||||
|
coords, err
|
||||||
|
);
|
||||||
|
return Ok(RegionProcessorStatus::ErrorMissing);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if Some(input_timestamp) > output_timestamp {
|
if Some(input_timestamp) > output_timestamp {
|
||||||
Self::save_region(&output_path, &processed_region, input_timestamp)?;
|
Self::save_region(&output_path, &processed_region, input_timestamp)?;
|
||||||
|
|
Loading…
Add table
Reference in a new issue