chiark / gitweb /
dice: Support occultation by label, for all 1-faced images
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 17 Apr 2022 12:51:38 +0000 (13:51 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 17 Apr 2022 15:12:05 +0000 (16:12 +0100)
Right now we mix dice of all ilks.  This is wrong.  Dice shouldn't mix
at all.  We're going to do that RSN.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/dice.rs
src/spec.rs

index 69ff21d9319ae36dc43577beba7c1d878b8daa7c..9101e520dc0a18a437b959d0a01d00e0071a834a 100644 (file)
@@ -181,8 +181,20 @@ impl PieceSpec for Spec {
 
     let occultable = match (img_occultable, &self.occult) {
       (None, None) => None,
-      (None, Some(_occ)) => {
-        throw!(SpecError::UnusedOccultLabel)
+      (None, Some(occ)) => {
+        let SpecLoaded { p: image, occultable: image_occ_reload } =
+          self.image.load_inert(ig, depth)?;
+
+        if image_occ_reload.is_some() {
+          throw!(internal_logic_error(
+            format!("reloading image {:?} occ varies", &self)
+          ));
+        }
+        if image.nfaces() != 1 {
+          throw!(SpecError::UnoccultableButRichImageForOccultation)
+        }
+        let occ_label = occ_label(occ);
+        Some((image.into(), "bad-ilk-mixing-todo".into(), occ_label))
       },
       (Some((image_occ_ilk, image_occ_image)), occ) => {
         let default_occ = default();
index 34aed86c489d2b41a4cdd0d3fa500cb742c7a788..d429c715fae9f8ff4d31a950eb7124441284bd04 100644 (file)
@@ -86,10 +86,12 @@ pub enum SpecError {
   #[error("piece alias loop")]               AliasLoop(String),
   #[error("invalid size scale")]             InvalidSizeScale,
   #[error("multiple faces required")]        MultipleFacesRequired,
-  #[error("occult label supplied but not occultable")] UnusedOccultLabel,
   #[error("far too many faces ({0})")]       FarTooManyFaces(usize),
   #[error("coordinate overflow")]
   CoordinateOverflow(#[from] CoordinateOverflow),
+  #[error("image for supposedly-occultable piece \
+           is not itself occultable but has multiple faces")]
+  UnoccultableButRichImageForOccultation,
   #[error("timeout too large ({got:?} > {max:?})")]
   TimeoutTooLarge {
     got: Duration,