From: Ian Jackson Date: Sun, 17 Apr 2022 12:51:38 +0000 (+0100) Subject: dice: Support occultation by label, for all 1-faced images X-Git-Tag: otter-1.1.0~515 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=e21b7d53a442c941e6350f36d95a402f6227c23b;p=otter.git dice: Support occultation by label, for all 1-faced images 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 --- diff --git a/src/dice.rs b/src/dice.rs index 69ff21d9..9101e520 100644 --- a/src/dice.rs +++ b/src/dice.rs @@ -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(); diff --git a/src/spec.rs b/src/spec.rs index 34aed86c..d429c715 100644 --- a/src/spec.rs +++ b/src/spec.rs @@ -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,