summaryrefslogtreecommitdiff
path: root/src/savestate.rs
diff options
context:
space:
mode:
authortroido <troido@protonmail.com>2020-04-08 20:02:03 +0200
committertroido <troido@protonmail.com>2020-04-08 20:02:03 +0200
commita18bdf20159c50c570c398bf55c2da080f033908 (patch)
tree3a4b2d3a816877b335e88fd3f2b8fafb8594fe81 /src/savestate.rs
parent15da8ce3af4e943939d6976ccfe5c46785638c7e (diff)
load python room format
Diffstat (limited to 'src/savestate.rs')
-rw-r--r--src/savestate.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/savestate.rs b/src/savestate.rs
index c3b79cb..95f8d84 100644
--- a/src/savestate.rs
+++ b/src/savestate.rs
@@ -34,10 +34,11 @@ impl SaveState {
for v in val.get("changes").ok_or(perr!("save does not have changes"))?.as_array().ok_or(perr!("changes not an array"))? {
let pos = Pos::from_json(v.get(0).ok_or(perr!("change does not have index 0"))?).ok_or(perr!("change index 0 is not a pos"))?;
let mut templates = Vec::new();
- for t in v.get(1).ok_or(perr!("change does not have index 1"))?.as_array().ok_or(perr!("change index 1 not an array"))? {
+ let jsontemplates = v.get(1).ok_or(perr!("change does not have index 1"))?;
+ for t in jsontemplates.as_array().clone().unwrap_or(&vec![jsontemplates.clone()]) {
templates.push(Template::from_json(t)?);
}
- changes.insert(pos, templates);
+ changes.entry(pos).or_insert_with(Vec::new).append(&mut templates);
}
Ok(Self {changes})
}