chiark / gitweb /
create_occultation: Pass PUOs_Simple_Modify witness at all callers
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 20 Jul 2021 19:58:41 +0000 (20:58 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 21 Jul 2021 19:40:37 +0000 (20:40 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/deck.rs
src/hand.rs
src/hidden.rs
src/updates.rs

index 0e12afb5a943ef3c43606bcad611554fd3bcab93..95e077e18c4e5cd3f7cd472dab964f972b25d202 100644 (file)
@@ -219,13 +219,15 @@ impl PieceTrait for Deck {
       );
     }
 
+    let puos = PUOs_Simple_Modify;
+
     if let Some((region, views)) = region_views {
       dbgc!("creating occ");
       xupdates.extend(
         create_occultation(&mut gen.unique_gen(), &mut gs.max_z,
                            gplayers, gpieces, goccults, ipieces, ioccults,
                            to_recalculate, rot_checked,
-                           region, piece, views)?
+                           region, piece, views, &puos)?
       );
       dbgc!("creating occ done", &xupdates);
     }
@@ -236,9 +238,8 @@ impl PieceTrait for Deck {
     
     (PieceUpdate {
       wrc, log,
-      ops: PUOs::Simple(PUO::Modify(())),
-    },
-     xupdates.into_unprepared(None))
+      ops: puos.into(),
+    }, xupdates.into_unprepared(None))
   }
 
   fn occultation_notify_hook(&self, piece: PieceId) -> UnpreparedUpdates {
index 307f0055e0a7937abc9c91f4ee2b615853e1ae00..721a2c83fdc4b3df5415661824c2a7a4e5ae4ffd 100644 (file)
@@ -257,6 +257,8 @@ impl PieceTrait for Hand {
 
     dbgc!("ui op k entry", &opname, &xdata);
 
+    let puos = PUOs_Simple_Modify;
+
     let (new_owner, xupdates, did) =
       match (opname, xdata.owner.is_some())
     {
@@ -293,7 +295,7 @@ impl PieceTrait for Hand {
                                  gplayers, gpieces, goccults,
                                  ipieces, ioccults,
                                  to_recalculate, rot_checked,
-                                 region, piece, views)?;
+                                 region, piece, views, &puos)?;
             xupdates
           }
         };
@@ -336,7 +338,7 @@ impl PieceTrait for Hand {
 
     (PieceUpdate {
       wrc, log,
-      ops: PUOs::Simple(PUO::Modify(())),
+      ops: puos.into(),
     }, xupdates.into_unprepared(None))
   }
 
index f291e938407c208f881da9946853a71f5eb76cb7..a4f1b3c8d01cde21fc53152898971aab9b2dd691 100644 (file)
@@ -895,6 +895,9 @@ pub fn create_occultation(
   region: Region,
   occulter: PieceId,
   views: OccultationViews,
+  // Caller must promise not to fail if we succeed, so that this
+  // update actually happens!
+  _puos_will_return: &PUOs_Simple_Modify,
 ) -> Vec<(PieceId, PieceUpdateOps)> {
   {
     let ogpc = gpieces.get(occulter).ok_or_else(
index 616ad8ef6863f0da67c06175ed1433bd2f4b9bbe..69a3ff07f3a8cd1e0e36e1d78f57087b2d0895bf 100644 (file)
@@ -213,6 +213,14 @@ impl From<PieceUpdateFromOpSimple> for PieceUpdate {
   }
 }
 
+
+#[allow(non_camel_case_types)]
+#[derive(Copy,Clone,Debug)]
+pub struct PUOs_Simple_Modify;
+impl From<PUOs_Simple_Modify> for PieceUpdateOps {
+  fn from(_: PUOs_Simple_Modify) -> Self { PUOs::Simple(PUO::Modify(())) }
+}
+
 // ---------- for traansmission ----------
 
 #[derive(Debug,Serialize)]