mirror of
https://github.com/Noratrieb/game-wip-dontplay.git
synced 2026-01-16 12:25:02 +01:00
Factor out single chunk saving code into a function
This commit is contained in:
parent
7c4af574cd
commit
80e10e4e91
1 changed files with 51 additions and 47 deletions
|
|
@ -91,6 +91,12 @@ impl World {
|
||||||
}
|
}
|
||||||
pub fn save_chunks(&self) {
|
pub fn save_chunks(&self) {
|
||||||
for (pos, chk) in self.chunks.iter() {
|
for (pos, chk) in self.chunks.iter() {
|
||||||
|
save_chunk(pos, chk);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn save_chunk(pos: &ChunkPos, chk: &Chunk) {
|
||||||
let reg_file_name = format_reg_file_name(pos.region());
|
let reg_file_name = format_reg_file_name(pos.region());
|
||||||
dbg!(®_file_name);
|
dbg!(®_file_name);
|
||||||
let reg_file_exists = Path::new(®_file_name).exists();
|
let reg_file_exists = Path::new(®_file_name).exists();
|
||||||
|
|
@ -139,8 +145,6 @@ impl World {
|
||||||
let result = f.write_all(&zstd::encode_all(®ion_tile_data[..], COMP_LEVEL).unwrap());
|
let result = f.write_all(&zstd::encode_all(®ion_tile_data[..], COMP_LEVEL).unwrap());
|
||||||
log::info!("{result:?}");
|
log::info!("{result:?}");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn loc_byte_idx_xy(x: u8, y: u8) -> usize {
|
fn loc_byte_idx_xy(x: u8, y: u8) -> usize {
|
||||||
loc_byte_idx(loc_idx(y, x))
|
loc_byte_idx(loc_idx(y, x))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue