chiark / gitweb /
hidden: pass &mut Generation into occutation implementation
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 11 Mar 2021 19:18:23 +0000 (19:18 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 11 Mar 2021 19:18:23 +0000 (19:18 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/hand.rs
src/hidden.rs

index c3a26bc12144291a7bba2df70a4b9771b2e6ebac..5df47c925dc0a240481b0f7cd99cbe0638d6aa10 100644 (file)
@@ -141,6 +141,7 @@ impl PieceTrait for Hand {
                   opname: &str, wrc: WhatResponseToClientOp)
                   -> UpdateFromOpComplex {
     let ApiPieceOpArgs { gs,player,piece,ipieces,.. } = a;
+    let gen = &mut gs.gen;
     let gplayers = &mut gs.players;
     let gpieces = &mut gs.pieces;
 
@@ -194,7 +195,7 @@ impl PieceTrait for Hand {
         // actually do things:
         dbgc!("creating occ");
         let xupdates =
-          create_occultation(gplayers, gpieces, goccults, ipieces,
+          create_occultation(gen, gplayers, gpieces, goccults, ipieces,
                              region, piece, views)?;
 
         dbgc!("creating occ done", &new_owner, &xupdates);
index 0cf6df1d4128abf4b84c5a7d82042495a3e1ecb6..8eb6fd25f03f3f057c144278b4a945c198eda4ab 100644 (file)
@@ -809,7 +809,8 @@ pub fn recalculate_occultation_piece(
         log
       }
     ),
-    to_recompute.implement(&mut gs.players, &mut gs.pieces, &mut gs.occults,
+    to_recompute.implement(&mut gs.gen, &mut gs.players,
+                           &mut gs.pieces, &mut gs.occults,
                            ipieces),
   ))?
 }
@@ -853,6 +854,7 @@ mod recompute {
     }
     pub fn mark_dirty(&mut self, occid: OccId) { self.outdated.insert(occid); }
     pub fn implement(self,
+                     _gen: &mut Generation,
                      gplayers: &mut GPlayers,
                      gpieces: &mut GPieces,
                      goccults: &mut GameOccults,
@@ -907,6 +909,7 @@ impl OccultationViewDef for OwnerOccultationView {
 
 #[throws(OnlineError)]
 pub fn create_occultation(
+  gen: &mut Generation,
   gplayers: &mut GPlayers,
   gpieces: &mut GPieces,
   goccults: &mut GameOccults,
@@ -973,7 +976,7 @@ pub fn create_occultation(
       goccults.occults.remove(occid).expect("inserted this earlier");
       e
     }),
-    to_recompute.implement(gplayers, gpieces, goccults, ipieces),
+    to_recompute.implement(gen, gplayers, gpieces, goccults, ipieces),
   ))?;
 
   dbgc!(&updates);
@@ -982,6 +985,7 @@ pub fn create_occultation(
 
 #[throws(IE)]
 pub fn remove_occultation(
+  gen: &mut Generation,
   gplayers: &mut GPlayers,
   gpieces: &mut GPieces,
   goccults: &mut GameOccults,
@@ -1046,7 +1050,7 @@ pub fn remove_occultation(
       aggerr.record(internal_logic_error("removing occultation of non-piece"));
     }
   },
-    to_recompute.implement(gplayers, gpieces, goccults, ipieces),
+    to_recompute.implement(gen, gplayers, gpieces, goccults, ipieces),
   ));
 
   aggerr.ok()?;