chiark / gitweb /
hidden: Make recaulculate_occultation take just plain vanilla
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 12 Feb 2021 01:17:11 +0000 (01:17 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 12 Feb 2021 01:38:24 +0000 (01:38 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/hidden.rs
src/imports.rs

index dfce8d161fe0610f5a7fb07dad81fe357bef8404..b40d3687be6baf2e2a1afb00796ffaa4523cebdd 100644 (file)
@@ -210,16 +210,14 @@ pub fn massage_prep_piecestate(
 // xxx this means this only happens on ungrab I think ?
 
 #[throws(InternalError)]
-pub fn recalculate_occultation<LF: FnOnce() -> Vec<LogEntry> + Sync>
-  (
-    gs: &mut GameState,
-    who_by: Html,
-    ipieces: &PiecesLoaded,
-    piece: PieceId,
-    vanilla_wrc: WhatResponseToClientOp,
-    vanilla_uo: PieceUpdateOp<(),()>,
-    vanilla_log: LF,
-  ) -> PieceUpdate
+pub fn recalculate_occultation(
+  gs: &mut GameState,
+  who_by: Html,
+  ipieces: &PiecesLoaded,
+  piece: PieceId,
+  vanilla: PUFOS,
+)
+  -> PieceUpdate
 {
   // fallible part
   let (update, occids): (_, OldNew<Option<OccId>>) = {
@@ -250,9 +248,7 @@ pub fn recalculate_occultation<LF: FnOnce() -> Vec<LogEntry> + Sync>
     ].into();
 
     let occids = occulteds.map(|h| h.as_ref().map(|occ| occ.occid));
-    if occids.old() == occids.new() {
-      return (vanilla_wrc, vanilla_uo, vanilla_log()).into()
-    }
+    if occids.old() == occids.new() { return vanilla.into(); }
 
   /*
     #[throws(IE)]
@@ -319,10 +315,10 @@ pub fn recalculate_occultation<LF: FnOnce() -> Vec<LogEntry> + Sync>
     };
 
     let most_obscure = most_obscure.unwrap_or(&OccK::Visible); // no players!
-    
+
     let log = match most_obscure {
       OccK::Visible => {
-        vanilla_log()
+        vanilla.2
       }
       OccK::Scrambled | OccK::Displaced{..} => {
         let face = ipc.nfaces() - 1;
index b2e852f9f03a3540d86e54e63f48ef0a49471b12..df0478188250109f9282f7c7944b77e450d02da2 100644 (file)
@@ -134,6 +134,7 @@ pub type POEPP = PieceOpErrorPartiallyProcessed;
 
 // updates.rs
 pub type PUE = PreparedUpdateEntry;
+pub type PUFOS = PieceUpdateFromOpSimple;
 pub type PUO<NS,ZL> = PieceUpdateOp<NS,ZL>;
 pub type PUOs = PieceUpdateOps;
 pub type WRC = WhatResponseToClientOp;