From: Ian Jackson Date: Tue, 26 Jan 2021 23:20:29 +0000 (+0000) Subject: wdt: Actually read spec, and make it work X-Git-Tag: otter-0.4.0~671 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=94a3df6e0c6d9e6b662e046d0997a02be5d4c1b6;p=otter.git wdt: Actually read spec, and make it work Signed-off-by: Ian Jackson --- diff --git a/wdriver.rs b/wdriver.rs index 69a6615d..7eb761e7 100644 --- a/wdriver.rs +++ b/wdriver.rs @@ -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) diff --git a/wdriver/wdt-simple.rs b/wdriver/wdt-simple.rs index f0a73974..f2686378 100644 --- a/wdriver/wdt-simple.rs +++ b/wdriver/wdt-simple.rs @@ -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")?;