chiark / gitweb /
hidden: Introduce Occultation::pieces
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 24 Apr 2022 23:50:13 +0000 (00:50 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 25 Apr 2022 00:27:40 +0000 (01:27 +0100)
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 <ijackson@chiark.greenend.org.uk>
src/hidden.rs

index a89264348c651d161600b1221e7e91fae465ee86..967d5aa35c11f99e598ab214a4dcd4875b0e7e4d 100644 (file)
@@ -243,6 +243,10 @@ impl Occultation {
   pub fn in_region(&self, pos: Pos) -> bool {
     self.region.contains(pos)
   }
+
+  pub fn pieces(&self) -> impl Iterator<Item=PieceId> + '_ {
+    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>(())
   })() {