mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Make hacky hash for gen opts
This commit is contained in:
parent
1a21dfbc5b
commit
ddf2c43c18
@ -369,6 +369,7 @@ impl FileOpts {
|
||||
match self {
|
||||
Self::Save { .. } => {
|
||||
use std::time::SystemTime;
|
||||
|
||||
Some(format!(
|
||||
"map_{}.bin",
|
||||
SystemTime::now()
|
||||
@ -377,7 +378,20 @@ impl FileOpts {
|
||||
.unwrap_or(0)
|
||||
))
|
||||
},
|
||||
Self::CacheLoad(name, opts) => Some(format!("map_{}{:?}.bin", name, opts)),
|
||||
Self::CacheLoad(name, opts) => {
|
||||
use std::{
|
||||
collections::hash_map::DefaultHasher,
|
||||
hash::{Hash, Hasher},
|
||||
};
|
||||
|
||||
// We convert opts to string, as opts isn't hasheable because
|
||||
// of scale which is f64
|
||||
let opts = format!("{opts:?}");
|
||||
let mut hashed_opts = DefaultHasher::new();
|
||||
opts.hash(&mut hashed_opts);
|
||||
|
||||
Some(format!("map_{}{:x}.bin", name, hashed_opts.finish()))
|
||||
},
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user