chiark / gitweb /
Extend load_inert to offer an occultable piece
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 12 Apr 2022 00:18:22 +0000 (01:18 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 12 Apr 2022 00:18:22 +0000 (01:18 +0100)
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 <ijackson@chiark.greenend.org.uk>
src/gamestate.rs
src/pcaliases.rs
src/shapelib.rs

index 1f2fbfec5b96eade1717f20bd6e797420ef3c083..ec7361df390fd7122bb133b653a39131b1cba7d3 100644 (file)
@@ -277,7 +277,7 @@ pub trait PieceSpec: Debug + Sync + Send + 'static {
           -> Result<PieceSpecLoaded, SpecError>;
   /// Used when a piece wants to use another for its occulted form
   fn load_inert(&self, _ig: &Instance, _:SpecDepth)
-                -> Result<Box<dyn InertPieceTrait>, SpecError> {
+                -> Result<SpecLoaded<dyn InertPieceTrait>, SpecError> {
     throw!(SpE::ComplexPieceWhereInertRequired)
   }
 }
index 25bf7b756d257c1da2f15175a32463b04fcd02dc..9d4f30eea5ee75ed92d5ba6d4c931360deec3584 100644 (file)
@@ -72,7 +72,7 @@ impl PieceSpec for Alias {
   }
   #[throws(SpecError)]
   fn load_inert(&self, ig: &Instance, depth: SpecDepth)
-                 -> Box<dyn InertPieceTrait> {
+                 -> SpecLoaded<dyn InertPieceTrait> {
     self.resolve(&ig.pcaliases)?.load_inert(ig, self.new_depth(depth)?)?
   }
 }
index c50c53d575c91aa8448ca7d83b86c10447419c54..a3b83dd2d153eb23bd8d586bbfb5971b2d3ef7c1 100644 (file)
@@ -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<dyn InertPieceTrait> {
-    self.find_load(ig,depth)?.0 as Box<dyn InertPieceTrait>
+                -> SpecLoaded<dyn InertPieceTrait> {
+    let (p, occultable) = self.find_load(ig,depth)?;
+    SpecLoaded { p: p as _, occultable }
   }
 }