chiark / gitweb /
hidden: abolish Passive.zg
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 13 Mar 2021 19:50:15 +0000 (19:50 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 13 Mar 2021 19:56:56 +0000 (19:56 +0000)
Look it up in the occ instead.  That saves keeping it up to date.

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

index 94dac5baccb5c18fe84db0fd613ef63b3d54ba8c..bdb8ce989c87770e44c7b8024131359c803ffde5 100644 (file)
@@ -28,7 +28,6 @@ pub struct PieceOccult {
 struct Passive {
   occid: OccId,
   notch: Notch,
-  zg: Generation,
 }
 
 #[derive(Clone,Debug,Serialize,Deserialize)]
@@ -239,6 +238,12 @@ mod vpid {
     zg: IndexVec<Notch, Generation>, // last time notch was (re)filled
   }
 
+  impl Occultation {
+    pub fn notch_zg(&self, notch: Notch) -> Option<Generation> {
+      self.notches.zg.get(notch).copied()
+    }
+  }
+
   impl Notches {
     pub fn iter<'i>(&'i self) -> impl Iterator<Item=PieceId> + 'i {
       self.table.iter()
@@ -513,8 +518,9 @@ fn inner(
 ) -> Option<PieceRenderInstructions>
 {
   let occk = if_chain! {
-    if let Some(Passive { occid, notch, zg }) = gpc.occult.passive;
+    if let Some(Passive { occid, notch }) = gpc.occult.passive;
     if let Some(occultation) = occults.occults.get(occid);
+    if let Some(zg) = occultation.notch_zg(notch);
     then {
       occultation.views.get_kind(player)
         .map_displaced(|(area, z)| {
@@ -641,7 +647,7 @@ fn recalculate_occultation_general<
 
     let occulteds = OldNewOcculteds {
       old:
-        gpc.occult.passive.map(|Passive { occid, notch, zg:_zg }| Ok::<_,IE>((
+        gpc.occult.passive.map(|Passive { occid, notch }| Ok::<_,IE>((
           Occulted {
             occid,
             occ: goccults.occults.get(occid).ok_or_else(
@@ -794,7 +800,7 @@ fn recalculate_occultation_general<
       let zg = gen.next();
       let notch = notches(goccults, occid)
         .insert(zg, piece);
-      Some(Passive { occid, notch, zg })
+      Some(Passive { occid, notch })
     } else {
       None
     };