From: Ian Jackson Date: Thu, 11 Mar 2021 11:36:31 +0000 (+0000) Subject: hidden: New occultable arrangeents X-Git-Tag: otter-0.4.0~184 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=004e2693299352e504a95f6bc412d30155c07f3b;p=otter.git hidden: New occultable arrangeents Honour occilk, not occultable. Abolish the latter. Signed-off-by: Ian Jackson --- diff --git a/src/gamestate.rs b/src/gamestate.rs index 7ae73ac7..4d56fcfe 100644 --- a/src/gamestate.rs +++ b/src/gamestate.rs @@ -155,8 +155,6 @@ pub trait PieceTrait: OutlineTrait + Send + Debug + 'static { fn describe_html(&self, gpc: &GPiece) -> Result; - fn occultable(&self) -> Option<&dyn OccultedPieceTrait> { None } - fn delete_hook(&self, _p: &GPiece, _gs: &mut GameState) -> ExecuteGameChangeUpdates { ExecuteGameChangeUpdates{ pcs: vec![], log: vec![], raw: None } @@ -381,17 +379,22 @@ impl PieceRenderInstructions { } #[throws(IE)] - fn instead<'p>(&self, _ioccults: &'p IOccults, p: &'p IPiece) + fn instead<'p>(&self, ioccults: &'p IOccults, p: &'p IPiece) -> Option<&'p dyn OccultedPieceTrait> { match self.occulted { PriOcculted::Visible => None, PriOcculted::Occulted | PriOcculted::Displaced(_) => { - Some( - p.p.occultable() + Some({ + let occilk = p.occilk.as_ref() .ok_or_else(|| internal_logic_error(format!( "occulted non-occultable {:?}", p)))? - ) + .borrow(); + let occ_data = ioccults.ilks.get(occilk) + .ok_or_else(|| internal_logic_error(format!( + "occulted ilk vanished {:?} {:?}", p, occilk)))?; + occ_data.p_occ.as_ref() + }) }, } } diff --git a/src/hidden.rs b/src/hidden.rs index 48a12f59..c89f26d5 100644 --- a/src/hidden.rs +++ b/src/hidden.rs @@ -623,7 +623,7 @@ fn recalculate_occultation_general< // prevent occulting pieces being occulted // (also prevents reflexive occultation) return None - } else if ipc.p.occultable().is_none() { + } else if ipc.occilk.is_none() { // if we cannot make it look identical to the others, we // cannot occult it beause we can't hide its identity return None