From 3e4ff7a93db0fcdc20856186199f91663264afb0 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Tue, 12 Apr 2022 01:18:22 +0100 Subject: [PATCH] Extend load_inert to offer an occultable piece Now inert pieces can be occultable too. Currently this is meaningless since we only call load_inert when resolving the occultation for *another* piece, where we discard the occultation information. But that is going to change. Signed-off-by: Ian Jackson --- src/gamestate.rs | 2 +- src/pcaliases.rs | 2 +- src/shapelib.rs | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/gamestate.rs b/src/gamestate.rs index 1f2fbfec..ec7361df 100644 --- a/src/gamestate.rs +++ b/src/gamestate.rs @@ -277,7 +277,7 @@ pub trait PieceSpec: Debug + Sync + Send + 'static { -> Result; /// Used when a piece wants to use another for its occulted form fn load_inert(&self, _ig: &Instance, _:SpecDepth) - -> Result, SpecError> { + -> Result, SpecError> { throw!(SpE::ComplexPieceWhereInertRequired) } } diff --git a/src/pcaliases.rs b/src/pcaliases.rs index 25bf7b75..9d4f30ee 100644 --- a/src/pcaliases.rs +++ b/src/pcaliases.rs @@ -72,7 +72,7 @@ impl PieceSpec for Alias { } #[throws(SpecError)] fn load_inert(&self, ig: &Instance, depth: SpecDepth) - -> Box { + -> SpecLoaded { self.resolve(&ig.pcaliases)?.load_inert(ig, self.new_depth(depth)?)? } } diff --git a/src/shapelib.rs b/src/shapelib.rs index c50c53d5..a3b83dd2 100644 --- a/src/shapelib.rs +++ b/src/shapelib.rs @@ -562,7 +562,7 @@ impl Contents { Err(SpecError::AliasNotFound) => { }, Err(e) => throw!(e), Ok(p) => { - let p = p.into(); + let p = p.p.into(); back = Some(p); } } @@ -649,8 +649,9 @@ impl PieceSpec for ItemSpec { } #[throws(SpecError)] fn load_inert(&self, ig: &Instance, depth: SpecDepth) - -> Box { - self.find_load(ig,depth)?.0 as Box + -> SpecLoaded { + let (p, occultable) = self.find_load(ig,depth)?; + SpecLoaded { p: p as _, occultable } } } -- 2.30.2