mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-03-04 17:23:33 +01:00
core/common: separate FileMetaVersion for different outputs
This commit is contained in:
parent
4574c06f5d
commit
fa15a4e6e5
4 changed files with 21 additions and 11 deletions
|
@ -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
|
||||
///
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue