chiark / gitweb /
recalculate_occultation: Refactor into ..._general etc.
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 16 Feb 2021 23:56:32 +0000 (23:56 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 16 Feb 2021 23:56:32 +0000 (23:56 +0000)
NFC

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
daemon/api.rs
src/hidden.rs

index cbb00df87f6fe419735b72e13c290e444977cab7..2b8545e9e176cdda8cfb3bb3d2f675c4e0a3fdde 100644 (file)
@@ -286,19 +286,12 @@ api_route!{
                    logents);
 
     let update=
-      recalculate_occultation(
+      recalculate_occultation_piece(
         gs,
         who_by,
         ipieces,
         piece,
         vanilla,
-        |who_by, old, new, show| vec![ LogEntry { html: Html(format!(
-          "{} moved {} from {} to {}",
-          &who_by.0,
-          if let Some(show) = show { &show.0 } else { "something" },
-          &old.0, &new.0,
-        ))}],
-        
       ).map_err(|e| OnlineError::from(e))?;
 
     update
index fb8dc598ddae8f5a063215f82011312db690a5bc..25246e005e8066475fa769a2f1d35c3dda417ae8 100644 (file)
@@ -210,7 +210,7 @@ pub fn massage_prep_piecestate(
 // xxx this means this only happens on ungrab I think ?
 
 #[throws(InternalError)]
-pub fn recalculate_occultation<
+fn recalculate_occultation_general<
   L: FnOnce(&Html, Html, Html, Option<&Html>) -> Vec<LogEntry>,
   >(
   gs: &mut GameState,
@@ -370,3 +370,28 @@ pub fn recalculate_occultation<
 
   update
 }
+
+#[throws(InternalError)]
+pub fn recalculate_occultation_piece(
+  gs: &mut GameState,
+  who_by: Html,
+  ipieces: &PiecesLoaded,
+  piece: PieceId,
+  vanilla: PUFOS,
+)
+  -> PieceUpdate
+{
+  recalculate_occultation_general(
+    gs,
+    who_by,
+    ipieces,
+    piece,
+    vanilla,
+    |who_by, old, new, show| vec![ LogEntry { html: Html(format!(
+      "{} moved {} from {} to {}",
+      &who_by.0,
+      if let Some(show) = show { &show.0 } else { "something" },
+      &old.0, &new.0,
+    ))}]
+  )?
+}