chiark / gitweb /
hidden: New occultable arrangeents
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 11 Mar 2021 11:36:31 +0000 (11:36 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 11 Mar 2021 12:29:33 +0000 (12:29 +0000)
Honour occilk, not occultable.  Abolish the latter.

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

index 7ae73ac779b7967a86df0cb858ec226ab42ca648..4d56fcfe5644195a3961a56807715dbb8f8ed1e7 100644 (file)
@@ -155,8 +155,6 @@ pub trait PieceTrait: OutlineTrait + Send + Debug + 'static {
 
   fn describe_html(&self, gpc: &GPiece) -> Result<Html,IE>;
 
-  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()
+        })
       },
     }
   }
index 48a12f592f850fd525a7cd072554f3e8ee2f7ad3..c89f26d57de5e78353666fab0ae859b883722766 100644 (file)
@@ -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