summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs7
-rw-r--r--src/save.rs11
2 files changed, 10 insertions, 8 deletions
diff --git a/src/lib.rs b/src/lib.rs
index a77ff19..71c1cf6 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -56,11 +56,10 @@ where
}
#[cfg(not(target_arch = "wasm32"))]
-pub async fn run<'a, F, G, Fut>(title: &str, w: u32, h: u32, options: Options, gnew: F) -> Erm<()>
+pub fn run<'a, F, G>(title: &str, w: u32, h: u32, options: Options, gnew: F) -> Erm<()>
where
- Fut: std::future::Future<Output = G>,
G: state::Game + 'static,
- F: (Fn(&'a context::Context) -> Fut),
+ F: (Fn(&'a context::Context) -> G),
{
env_logger::Builder::new()
.filter(None, log::LevelFilter::Info)
@@ -121,7 +120,7 @@ where
glfw, window, gl,
w as f32, h as f32, resize,
)));
- let game = Box::leak(Box::new(gnew(ctx).await));
+ let game = Box::leak(Box::new(gnew(ctx)));
let st = Box::leak(Box::new(state::State::new(&ctx)));
unsafe {
diff --git a/src/save.rs b/src/save.rs
index 0f0d20b..3f244cc 100644
--- a/src/save.rs
+++ b/src/save.rs
@@ -26,8 +26,10 @@ pub fn save<W>(id: &str, data: &W) where W: serde::Serialize {
let pd = directories::ProjectDirs::from("", "milkfat", id).expect("failed to get save directory");
let _ = std::fs::create_dir_all(pd.data_dir());
let path = pd.data_dir().join("teleia.save");
- let file = std::fs::File::create(&path).expect("failed to open save file");
- serde_json::to_writer(file, data).expect("failed to write save file");
+ let mut file = std::fs::File::create(&path).expect("failed to open save file");
+ // serde_json::to_writer(file, data).expect("failed to write save file");
+ bincode::serde::encode_into_std_write(data, &mut file, bincode::config::standard())
+ .expect("failed to write save file");
}
#[cfg(not(target_arch = "wasm32"))]
@@ -35,6 +37,7 @@ pub fn load<W>(id: &str) -> Option<W> where W: serde::de::DeserializeOwned {
let pd = directories::ProjectDirs::from("", "milkfat", id).expect("failed to get save directory");
let _ = std::fs::create_dir_all(pd.data_dir());
let path = pd.data_dir().join("teleia.save");
- let file = std::fs::File::open(&path).ok()?;
- serde_json::from_reader(file).ok()
+ let mut file = std::fs::File::open(&path).ok()?;
+ // serde_json::from_reader(file).ok()
+ bincode::serde::decode_from_std_read(&mut file, bincode::config::standard()).ok()
}