diff --git a/src/core/common.rs b/src/core/common.rs index 471bef3..39c8e54 100644 --- a/src/core/common.rs +++ b/src/core/common.rs @@ -11,10 +11,16 @@ use serde::{Deserialize, Serialize}; use crate::{io::fs::FileMetaVersion, resource::Biome, types::*, world::layer}; -/// MinedMap data version number -/// /// Increase to force regeneration of all output files -pub const FILE_META_VERSION: FileMetaVersion = FileMetaVersion(0); + +/// MinedMap processed region data version number +pub const REGION_FILE_META_VERSION: FileMetaVersion = FileMetaVersion(0); + +/// MinedMap map tile data version number +pub const MAP_FILE_META_VERSION: FileMetaVersion = FileMetaVersion(0); + +/// MinedMap lightmap data version number +pub const LIGHTMAP_FILE_META_VERSION: FileMetaVersion = FileMetaVersion(0); /// Coordinate pair of a generated tile /// diff --git a/src/core/region_processor.rs b/src/core/region_processor.rs index 6442da0..830b0f2 100644 --- a/src/core/region_processor.rs +++ b/src/core/region_processor.rs @@ -126,7 +126,7 @@ impl<'a> RegionProcessor<'a> { processed_region: &ProcessedRegion, timestamp: SystemTime, ) -> Result<()> { - storage::write(path, processed_region, FILE_META_VERSION, timestamp) + storage::write(path, processed_region, REGION_FILE_META_VERSION, timestamp) } /// Saves a lightmap tile @@ -137,7 +137,7 @@ impl<'a> RegionProcessor<'a> { lightmap: &image::GrayAlphaImage, timestamp: SystemTime, ) -> Result<()> { - fs::create_with_timestamp(path, FILE_META_VERSION, timestamp, |file| { + fs::create_with_timestamp(path, LIGHTMAP_FILE_META_VERSION, timestamp, |file| { lightmap .write_to(file, image::ImageFormat::Png) .context("Failed to save image") @@ -156,9 +156,9 @@ impl<'a> RegionProcessor<'a> { let input_timestamp = fs::modified_timestamp(&input_path)?; let output_path = self.config.processed_path(coords); - let output_timestamp = fs::read_timestamp(&output_path, FILE_META_VERSION); + let output_timestamp = fs::read_timestamp(&output_path, REGION_FILE_META_VERSION); let lightmap_path = self.config.tile_path(TileKind::Lightmap, 0, coords); - let lightmap_timestamp = fs::read_timestamp(&lightmap_path, FILE_META_VERSION); + let lightmap_timestamp = fs::read_timestamp(&lightmap_path, LIGHTMAP_FILE_META_VERSION); if Some(input_timestamp) <= output_timestamp && Some(input_timestamp) <= lightmap_timestamp { diff --git a/src/core/tile_mipmapper.rs b/src/core/tile_mipmapper.rs index cc1a8d4..355bd23 100644 --- a/src/core/tile_mipmapper.rs +++ b/src/core/tile_mipmapper.rs @@ -70,8 +70,12 @@ impl<'a> TileMipmapper<'a> { /// Tile width/height const N: u32 = (BLOCKS_PER_CHUNK * CHUNKS_PER_REGION) as u32; + let version = match kind { + TileKind::Map => REGION_FILE_META_VERSION, + TileKind::Lightmap => LIGHTMAP_FILE_META_VERSION, + }; let output_path = self.config.tile_path(kind, level, coords); - let output_timestamp = fs::read_timestamp(&output_path, FILE_META_VERSION); + let output_timestamp = fs::read_timestamp(&output_path, version); let sources: Vec<_> = [(0, 0), (0, 1), (1, 0), (1, 1)] .into_iter() @@ -145,7 +149,7 @@ impl<'a> TileMipmapper<'a> { ); } - fs::create_with_timestamp(&output_path, FILE_META_VERSION, input_timestamp, |file| { + fs::create_with_timestamp(&output_path, version, input_timestamp, |file| { image .write_to(file, image::ImageFormat::Png) .context("Failed to save image") diff --git a/src/core/tile_renderer.rs b/src/core/tile_renderer.rs index 219e7c8..34f0310 100644 --- a/src/core/tile_renderer.rs +++ b/src/core/tile_renderer.rs @@ -270,7 +270,7 @@ impl<'a> TileRenderer<'a> { let (processed_paths, processed_timestamp) = self.processed_sources(coords)?; let output_path = self.config.tile_path(TileKind::Map, 0, coords); - let output_timestamp = fs::read_timestamp(&output_path, FILE_META_VERSION); + let output_timestamp = fs::read_timestamp(&output_path, MAP_FILE_META_VERSION); if Some(processed_timestamp) <= output_timestamp { debug!( @@ -300,7 +300,7 @@ impl<'a> TileRenderer<'a> { fs::create_with_timestamp( &output_path, - FILE_META_VERSION, + MAP_FILE_META_VERSION, processed_timestamp, |file| { image