From: Ian Jackson Date: Mon, 18 Apr 2022 10:12:56 +0000 (+0100) Subject: Add special field to SpecLoaded X-Git-Tag: otter-1.1.0~485 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=03a7e153c8976ce74b32012a6de013f4029639f5;p=otter.git Add special field to SpecLoaded This is currently empty. Signed-off-by: Ian Jackson --- diff --git a/daemon/cmdlistener.rs b/daemon/cmdlistener.rs index 77468fbf..f826c6ae 100644 --- a/daemon/cmdlistener.rs +++ b/daemon/cmdlistener.rs @@ -1110,7 +1110,7 @@ fn execute_game_insn<'cs, 'igr, 'ig: 'igr>( last_released: default(), rotateable: true, }; - let SpecLoaded { p, occultable } = + let SpecLoaded { p, occultable, special } = info.load(piece_i as usize, &mut gpc, ig, SpecDepth::zero())?; if p.nfaces() <= face.into() { throw!(SpecError::FaceNotFound); @@ -1127,7 +1127,7 @@ fn execute_game_insn<'cs, 'igr, 'ig: 'igr>( ilks.load_lilk(lilk, data) }); ig.ipieces.as_mut(modperm).insert(piece, IPiece { - p, occilk, + p, occilk, special, }); updates.push((piece, PieceUpdateOp::Insert(()))); })(); // <- no ?, infallible (to avoid leaking ilk) diff --git a/src/clock.rs b/src/clock.rs index 2b1eb47f..16fbfbdc 100644 --- a/src/clock.rs +++ b/src/clock.rs @@ -417,6 +417,7 @@ impl PieceSpec for Spec { SpecLoaded { p: Box::new(clock), occultable: None, + special: default(), } } } diff --git a/src/currency.rs b/src/currency.rs index 04dc23a0..29e632bf 100644 --- a/src/currency.rs +++ b/src/currency.rs @@ -69,7 +69,8 @@ impl PieceSpec for Spec { itemname, qty, min_unit, }; - SpecLoaded { p: Box::new(bnote) as _, occultable: None } + SpecLoaded { p: Box::new(bnote) as _, occultable: None, + special: default() } } } diff --git a/src/deck.rs b/src/deck.rs index e31de48e..004bc881 100644 --- a/src/deck.rs +++ b/src/deck.rs @@ -71,6 +71,7 @@ impl PieceSpec for piece_specs::Deck { SpecLoaded { p, occultable: None, + special: default(), } } } diff --git a/src/dice.rs b/src/dice.rs index 6c72dcc5..1701b52c 100644 --- a/src/dice.rs +++ b/src/dice.rs @@ -224,6 +224,7 @@ impl PieceSpec for Spec { SpecLoaded { p: Box::new(die) as _, occultable, + special: default(), } } } diff --git a/src/gamestate.rs b/src/gamestate.rs index aa1a55a6..85b7e011 100644 --- a/src/gamestate.rs +++ b/src/gamestate.rs @@ -283,6 +283,7 @@ pub struct ApiPieceOpArgs<'a> { pub struct SpecLoaded { pub p: Box, pub occultable: PieceSpecLoadedOccultable, + pub special: PieceSpecialProperties, } #[derive(Debug)] pub struct SpecLoadedInert { @@ -293,6 +294,14 @@ pub struct SpecLoadedInert { pub type PieceSpecLoadedOccultable = Option<(LOccultIlk, Arc)>; +/// Special handling instructions for this piece +/// +/// These remain constant after the piece has been loaded, +/// so they are mostly "can/do we do this thing". +#[derive(Debug,Clone,Default,Serialize,Deserialize)] +pub struct PieceSpecialProperties { +} + #[typetag::serde(tag="type")] pub trait PieceSpec: Debug + Sync + Send + 'static { #[throws(SpecError)] diff --git a/src/global.rs b/src/global.rs index 18cccd6d..2a8a2ab7 100644 --- a/src/global.rs +++ b/src/global.rs @@ -80,6 +80,7 @@ pub struct IPlayer { // usual variable: ipl pub struct IPiece { pub p: IPieceTraitObj, pub occilk: Option, + #[serde(default)] pub special: PieceSpecialProperties, } deref_to_field!{IPiece, IPieceTraitObj, p} diff --git a/src/hand.rs b/src/hand.rs index 5ed96ae0..eb4461cb 100644 --- a/src/hand.rs +++ b/src/hand.rs @@ -111,6 +111,7 @@ impl piece_specs::OwnedCommon { SpecLoaded { p, occultable: None, + special: default(), } } } diff --git a/src/pieces.rs b/src/pieces.rs index b353037a..cf52fb5e 100644 --- a/src/pieces.rs +++ b/src/pieces.rs @@ -358,6 +358,7 @@ macro_rules! impl_PieceSpec_for_SimplePieceSpec { { $ty:ty } => { SpecLoaded { p: Box::new(self.load_raw()?.0), occultable: None, + special: default(), } } diff --git a/src/shapelib.rs b/src/shapelib.rs index 3eee455c..98df2054 100644 --- a/src/shapelib.rs +++ b/src/shapelib.rs @@ -493,6 +493,7 @@ impl From for SpecLoaded { SpecLoaded { p, occultable, + special: default(), } } }