From: Ian Jackson Date: Sun, 24 Apr 2022 23:41:55 +0000 (+0100) Subject: hidden: Refactor a bit in preparation for unnotched pieces fix X-Git-Tag: otter-1.1.0~445 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=40fdb9f13c21afb8711fbebb76f4195885f159b5;p=otter.git hidden: Refactor a bit in preparation for unnotched pieces fix In both of these places, we're going to want to do something if there is an occultation but notch is None. Signed-off-by: Ian Jackson --- diff --git a/src/hidden.rs b/src/hidden.rs index 26784e4e..e2b02ec1 100644 --- a/src/hidden.rs +++ b/src/hidden.rs @@ -154,11 +154,12 @@ impl PieceOccult { piece: PieceId) { if_chain! { if let Some(Passive { occid, permute_notch }) = self.passive; - if let Some(notch) = permute_notch; if let Some(occ) = goccults.occults.get_mut(occid); then { - occ.notches.remove(piece, notch) - .unwrap_or_else(|e| error!("removing occulted piece {:?}", e)); + if let Some(notch) = permute_notch { + occ.notches.remove(piece, notch) + .unwrap_or_else(|e| error!("removing occulted piece {:?}", e)); + } } } } @@ -707,11 +708,14 @@ fn recalculate_occultation_general< to_recalculate.mark_dirty(occid); goccults.occults.get_mut(occid).unwrap() }; - if let Some((occid, Some(old_notch))) = occulteds.old { - occultation(goccults, occid) - .notches - .remove(piece, old_notch) - .unwrap() + if let Some((occid, old_notch)) = occulteds.old { + let occ = occultation(goccults, occid); + if let Some(old_notch) = old_notch { + occ + .notches + .remove(piece, old_notch) + .unwrap(); + } }; let passive = if_chain!{ if let Some(occid) = occulteds.new;