From ecd117afeadb2c7ee07dd924f0560f4de8cc7e9a Mon Sep 17 00:00:00 2001 From: Max Bradbury Date: Thu, 8 Jul 2021 11:06:07 +0100 Subject: [PATCH] 7.5 update --- Cargo.toml | 4 ++-- src/lib.rs | 17 ++++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 00f24a9..43c3f91 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "mixsy" description = "combine Bitsy games" -version = "0.72.0" +version = "0.75.0" authors = ["Max Bradbury "] edition = "2018" license = "MIT" @@ -13,6 +13,6 @@ repository = "https://tinybird.dev/max/mixsy" crate-type = ["cdylib"] [dependencies] -"bitsy-parser" = "^0.72.0" +"bitsy-parser" = "^0.75.0" "lazy_static" = "^1.4.0" "wasm-bindgen" = "^0.2.64" diff --git a/src/lib.rs b/src/lib.rs index cc19e52..f2fae5e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -16,10 +16,11 @@ lazy_static! { #[wasm_bindgen] pub fn load_main(game_data: String) -> String { - let game = Game::from(game_data); + let result = Game::from(game_data); - if game.is_ok() { - STATE.lock().unwrap().main = Some(game.unwrap()); + if result.is_ok() { + let (game, _errors) = result.unwrap(); + STATE.lock().unwrap().main = Some(game); "OK!" } else { "Could not parse game data" @@ -28,10 +29,11 @@ pub fn load_main(game_data: String) -> String { #[wasm_bindgen] pub fn load_additional(game_data: String) -> String { - let game = Game::from(game_data); + let result = Game::from(game_data); - if game.is_ok() { - STATE.lock().unwrap().additional = Some(game.unwrap()); + if result.is_ok() { + let (game, _errors) = result.unwrap(); + STATE.lock().unwrap().additional = Some(game); "OK!" } else { "Could not parse game data" @@ -47,7 +49,8 @@ pub fn merge() -> String { } let mut main = state.main.clone().unwrap(); - let additional = state.additional.clone().unwrap(); + let additional = state.additional.as_ref().unwrap(); + main.merge(additional); main.dedupe_tiles(); main.to_string()