core/tile_mipmapper: fix file meta version for mipmap tiles

The meta version should only change when the outputs must be regenerated
even if the inputs stay the same. This should never be the case for
mipmap tiles, so we separate the meta version from map/lightmap tiles.
This commit is contained in:
Matthias Schiffer 2024-01-08 02:35:05 +01:00
parent f79edb462c
commit 0988ebe095
Signed by: neocturne
GPG key ID: 16EF3F64CB201D9C
2 changed files with 16 additions and 10 deletions

View file

@ -70,12 +70,8 @@ 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, version);
let output_timestamp = fs::read_timestamp(&output_path, MIPMAP_FILE_META_VERSION);
let sources: Vec<_> = [(0, 0), (0, 1), (1, 0), (1, 1)]
.into_iter()
@ -149,11 +145,16 @@ impl<'a> TileMipmapper<'a> {
);
}
fs::create_with_timestamp(&output_path, version, input_timestamp, |file| {
image
.write_to(file, image::ImageFormat::Png)
.context("Failed to save image")
})?;
fs::create_with_timestamp(
&output_path,
MIPMAP_FILE_META_VERSION,
input_timestamp,
|file| {
image
.write_to(file, image::ImageFormat::Png)
.context("Failed to save image")
},
)?;
count_processed.send(()).unwrap();
Ok(())