chiark / gitweb /
occregion: Send to client (but this is wrong, it should be json string)
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 25 Mar 2021 11:01:18 +0000 (11:01 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 25 Mar 2021 11:02:58 +0000 (11:02 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
daemon/session.rs
src/hidden.rs
src/pcrender.rs
src/updates.rs

index ce68500e738d99eea58d3c0279ae2a5eceae4e86..0164b789fb636c64e55bd7f8ea137e18f80619b6 100644 (file)
@@ -49,6 +49,7 @@ struct SessionPieceLoadJson<'r> {
   desc: Html,
   uos: &'r [UoDescription],
   moveable: PieceMoveable,
+  occregion: Option<&'r Region<Coord>>,
 }
 
 #[derive(Serialize,Debug)]
@@ -141,6 +142,7 @@ fn session_inner(form: Json<SessionForm>,
         desc,
         moveable: gpc.moveable(),
         uos: &pri.ui_operations(&ig.gs, gpc, ipc)?,
+        occregion: gpc.occult.active_region(&ig.gs.occults)?,
       };
 
       let for_piece = SessionPieceContext {
index 5c41bbf6b85d40e990bc01c3c2ffbded5596a45c..cfa37763fbdbb0d071b02c784e66ceb84a4ca176 100644 (file)
@@ -106,6 +106,14 @@ impl PieceOccult {
     )
   }
 
+  #[throws(IE)]
+  pub fn active_region<'r>(&'r self, goccults: &'r GameOccults)
+                           -> Option<&'r Region<Coord>> {
+    self.active_occ(goccults)?.map(
+      |occ| &occ.region
+    )
+  }
+
   #[throws(IE)]
   pub fn active_total_ppieces(&self, goccults: &GameOccults)
                               -> Option<NotchNumber> {
index 2e5b016e9e663444b87d6bb96448526c72090909..232c39b5959b3887748427737bd3b2f817835211 100644 (file)
@@ -126,6 +126,7 @@ impl PieceRenderInstructions {
       pinned     : gpc.pinned,
       uos        : pri.ui_operations(gs, gpc, ipc)?,
       moveable   : gpc.moveable(),
+      occregion  : gpc.occult.active_region(&gs.occults)?.cloned(),
     };
     dbgc!(pri, ipc, gpc, r);
     r
index d9e8551e03324578fe4642e29c9db3135f0d4214..ddeea607a8f69070f4b37b456c8e6799f81136b3 100644 (file)
@@ -107,6 +107,7 @@ pub struct PreparedPieceState {
   pub pinned: bool,
   pub moveable: PieceMoveable,
   pub uos: Vec<UoDescription>,
+  pub occregion: Option<Region<Coord>>,
 }
 
 #[derive(Debug,Copy,Clone,Serialize,Deserialize,Eq)]