From: Ian Jackson Date: Sun, 24 Apr 2022 23:50:13 +0000 (+0100) Subject: hidden: Introduce Occultation::pieces X-Git-Tag: otter-1.1.0~447 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=a2b1de3e5fdda046d7d304ec3a35c06a05979377;p=otter.git hidden: Introduce Occultation::pieces This is going to want to return un-notched pieces too. Fix both sites where we iterate over the notches. Signed-off-by: Ian Jackson --- diff --git a/src/hidden.rs b/src/hidden.rs index a8926434..967d5aa3 100644 --- a/src/hidden.rs +++ b/src/hidden.rs @@ -243,6 +243,10 @@ impl Occultation { pub fn in_region(&self, pos: Pos) -> bool { self.region.contains(pos) } + + pub fn pieces(&self) -> impl Iterator + '_ { + self.notches.iter() + } } impl GameOccults { @@ -1057,7 +1061,8 @@ pub fn remove_occultation( // relevant pieces. Only then can we get rid of the occultation. occ.region = Region::empty(); - let pieces: Vec<_> = occ.notches.iter().collect(); + let pieces: Vec<_> = occ.pieces().collect(); + for &ppiece in pieces.iter() { recalculate_occultation_ofmany(gen, gplayers, gpieces, goccults, @@ -1076,7 +1081,7 @@ pub fn remove_occultation( let occ = goccults.occults.remove(occid).ok_or_else( || internal_logic_error("occultation vanished in recalc!"))?; - unbreak_pieces.extend(occ.notches.iter()); + unbreak_pieces.extend(occ.pieces()); Ok::<_,IE>(()) })() {