chiark / gitweb /
specs: Parse the spec after accessing the game
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 18 May 2021 20:21:59 +0000 (21:21 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 18 May 2021 20:21:59 +0000 (21:21 +0100)
We're going to want to get at the game to get the spec from a bundle.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
daemon/cmdlistener.rs

index 5e47e87fa1c92a9b231a5a3dff4ea79400e38e78..452a7fbc4b40e01ce3797a5577f3bbeeac1dc525 100644 (file)
@@ -562,14 +562,14 @@ fn execute_game_insn<'cs, 'igr, 'ig: 'igr>(
     spec_toml: String,
   ) -> ExecuteGameInsnResults<'igr, 'ig>
   {
-    let spec: toml::Value = spec_toml.parse()
-      .map_err(|e: toml::de::Error| ME::TomlSyntaxError(e.to_string()))?;
-    let GameSpec {
-      pieces, table_size, table_colour, pcaliases,
-    } = toml_de::from_value(&spec)
-      .map_err(|e: toml_de::Error| ME::TomlStructureError(e.to_string()))?;
-
     reset_game(cs,ag,ig, Box::new(|_ig, insns|{
+      let spec: toml::Value = spec_toml.parse()
+        .map_err(|e: toml::de::Error| ME::TomlSyntaxError(e.to_string()))?;
+      let GameSpec {
+        pieces, table_size, table_colour, pcaliases,
+      } = toml_de::from_value(&spec)
+        .map_err(|e: toml_de::Error| ME::TomlStructureError(e.to_string()))?;
+
       // Define new stuff:
       for (alias, target) in pcaliases.into_iter() {
         insns.push(MGI::DefinePieceAlias{ alias, target });