From: Ian Jackson Date: Sat, 13 Mar 2021 19:50:15 +0000 (+0000) Subject: hidden: abolish Passive.zg X-Git-Tag: otter-0.4.0~102 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=67c306340cd559075710b0c1ea6af2b52af192a2;p=otter.git hidden: abolish Passive.zg Look it up in the occ instead. That saves keeping it up to date. Signed-off-by: Ian Jackson --- diff --git a/src/hidden.rs b/src/hidden.rs index 94dac5ba..bdb8ce98 100644 --- a/src/hidden.rs +++ b/src/hidden.rs @@ -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, // last time notch was (re)filled } + impl Occultation { + pub fn notch_zg(&self, notch: Notch) -> Option { + self.notches.zg.get(notch).copied() + } + } + impl Notches { pub fn iter<'i>(&'i self) -> impl Iterator + 'i { self.table.iter() @@ -513,8 +518,9 @@ fn inner( ) -> Option { 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 };