Compressing with lz4
This commit is contained in:
@@ -72,16 +72,17 @@ impl World {
|
||||
data_file.write_all(data_str.as_bytes()).expect("Failed to write");
|
||||
}
|
||||
|
||||
pub fn load(&mut self) {
|
||||
pub fn load(&mut self) -> bool {
|
||||
// Get directory
|
||||
let mut dir = dirs::data_local_dir().unwrap();
|
||||
dir.push("Voxelgame");
|
||||
if !dir.is_dir() {
|
||||
println!("Not exists: {:?}", dir);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Load all chunks
|
||||
let mut count = 0;
|
||||
for entry in fs::read_dir(dir).unwrap() {
|
||||
let path: PathBuf = entry.unwrap().path();
|
||||
if path.extension().unwrap().to_str() != Some("dat") {
|
||||
@@ -102,10 +103,11 @@ impl World {
|
||||
|
||||
println!("loaded {:?}", pos);
|
||||
self.chunks.insert(pos, chunk);
|
||||
count += 1;
|
||||
}
|
||||
|
||||
// Load metadata
|
||||
|
||||
return count > 0;
|
||||
}
|
||||
|
||||
pub fn gen_block(&mut self, block_wpos: &Point3<u32>) -> &WorldBlock {
|
||||
|
||||
Reference in New Issue
Block a user