chiark / gitweb /
hidden: Recalculate occultations every time on ungrab
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 15 Mar 2021 01:04:26 +0000 (01:04 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 15 Mar 2021 01:04:26 +0000 (01:04 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
apitest/at-otter.rs
daemon/api.rs
src/hidden.rs

index d17e9fe50ba6eb01c42348449ac65377b91fbe02..459eee0abf7d3d903146ac73264657c282197572 100644 (file)
@@ -532,7 +532,7 @@ impl Ctx {
     prepare_game(&self.su().ds, TABLE)?;
     let mut alice = self.connect_player(&self.alice)?;
     let mut bob = self.connect_player(&self.bob)?;
-    self.su_mut().mgmt_conn.fakerng_load(&[&"1"])?;
+    self.su_mut().mgmt_conn.fakerng_load(&[&"1",&"0"])?;
 
     let mut a_pieces = alice.pieces::<PIA>()?;
     let mut b_pieces = alice.pieces::<PIB>()?;
index 361a95d5e62c243ce8e927c3381c09523f190bc8..8733ea2d2fc2472fa18d3332d091fe220e979633 100644 (file)
@@ -333,6 +333,13 @@ api_route!{
                    update,
                    logents);
       
+    if let Some(occid) = gpc.occult.passive_occid() {
+      // xxx if piece is occulted, definitely repermute its occultation
+      // so that we don't leak which piece is which over repeated
+      // adjustment clicks
+      to_permute.mark_dirty(occid);
+    };
+
     let update=
       recalculate_occultation_piece(
         gs,
@@ -342,9 +349,6 @@ api_route!{
         piece,
         vanilla,
       ).map_err(|e| OnlineError::from(e))?;
-    // xxx if piece is occulted, definitely repermute its occultation
-    // so that we don't leak which piece is which over repeated
-    // adjustment clicks
 
     update
   }
index 035b5bca4fad7ec74ef1437c66c667f5c4c6ec40..0ba31ef9ccfdd6b16bd7dfa492d8c69248055a2f 100644 (file)
@@ -65,6 +65,7 @@ pub type OccultationKind = OccultationKindGeneral<(Area, ZCoord)>;
 
 impl PieceOccult {
   pub fn is_active(&self) -> bool { self.active.is_some() }
+  pub fn passive_occid(&self) -> Option<OccId> { Some(self.passive?.occid) }
 }
 
 impl Default for OccultationKind {