chiark / gitweb /
wdt: Actually read spec, and make it work
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 26 Jan 2021 23:20:29 +0000 (23:20 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 26 Jan 2021 23:28:12 +0000 (23:28 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
wdriver.rs
wdriver/wdt-simple.rs

index 69a6615dc58e4353ba87ad5359e8ec81abe9679e..7eb761e701e1a7205d664316c12dd78a121ae044 100644 (file)
@@ -48,6 +48,7 @@ pub use otter::gamestate::{self, Generation};
 pub use otter::global::InstanceName;
 pub use otter::mgmtchannel::MgmtChannel;
 pub use otter::spec::{Coord, Pos, PosC};
+pub use otter::toml_de;
 pub use otter::ui::{AbbrevPresentationLayout, PresentationLayout};
 
 pub type T4d = t4::WebDriver;
@@ -649,7 +650,8 @@ impl DirSubst {
     let path = self.game_spec_path()?;
     (||{
       let data = fs::read(&path).context("read")?;
-      let data = toml::de::from_slice(&data).context("parse")?;
+      let data = std::str::from_utf8(&data).context("convert from UTF-8")?;
+      let data = toml_de::from_str(&data).context("parse")?;
       Ok::<_,AE>(data)
     })()
       .context(path)
index f0a73974873ee3958e05a83b2b0e2c0f69cf6fbf..f2686378a2a0098563e9b4deb1051991ed6e81f5 100644 (file)
@@ -8,6 +8,7 @@ struct Ctx {
   su: Setup,
   alice: Window,
   bob: Window,
+  spec: otter::spec::GameSpec,
 }
 
 impl Ctx {
@@ -127,9 +128,10 @@ fn main(){
     let (mut su, inst) = setup(module_path!()).always_context("setup")?;
     let [alice, bob] : [Window; 2] =
       su.setup_static_users(&inst)?.try_into().unwrap();
+    let spec = su.ds.game_spec_data()?;
     debug!("ok {:?} {:?}", alice, bob);
 
-    let mut c = Ctx { su, alice, bob };
+    let mut c = Ctx { su, alice, bob, spec };
 
     c.drag().always_context("drag")?;
     let pc = c.rotate().always_context("rotate")?;