From: Ian Jackson Date: Thu, 25 Mar 2021 11:01:18 +0000 (+0000) Subject: occregion: Send to client (but this is wrong, it should be json string) X-Git-Tag: otter-0.5.0~427 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=137de7c954abab26c27d904651cebd0fe5cfb14d;p=otter.git occregion: Send to client (but this is wrong, it should be json string) Signed-off-by: Ian Jackson --- diff --git a/daemon/session.rs b/daemon/session.rs index ce68500e..0164b789 100644 --- a/daemon/session.rs +++ b/daemon/session.rs @@ -49,6 +49,7 @@ struct SessionPieceLoadJson<'r> { desc: Html, uos: &'r [UoDescription], moveable: PieceMoveable, + occregion: Option<&'r Region>, } #[derive(Serialize,Debug)] @@ -141,6 +142,7 @@ fn session_inner(form: Json, desc, moveable: gpc.moveable(), uos: &pri.ui_operations(&ig.gs, gpc, ipc)?, + occregion: gpc.occult.active_region(&ig.gs.occults)?, }; let for_piece = SessionPieceContext { diff --git a/src/hidden.rs b/src/hidden.rs index 5c41bbf6..cfa37763 100644 --- a/src/hidden.rs +++ b/src/hidden.rs @@ -106,6 +106,14 @@ impl PieceOccult { ) } + #[throws(IE)] + pub fn active_region<'r>(&'r self, goccults: &'r GameOccults) + -> Option<&'r Region> { + self.active_occ(goccults)?.map( + |occ| &occ.region + ) + } + #[throws(IE)] pub fn active_total_ppieces(&self, goccults: &GameOccults) -> Option { diff --git a/src/pcrender.rs b/src/pcrender.rs index 2e5b016e..232c39b5 100644 --- a/src/pcrender.rs +++ b/src/pcrender.rs @@ -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 diff --git a/src/updates.rs b/src/updates.rs index d9e8551e..ddeea607 100644 --- a/src/updates.rs +++ b/src/updates.rs @@ -107,6 +107,7 @@ pub struct PreparedPieceState { pub pinned: bool, pub moveable: PieceMoveable, pub uos: Vec, + pub occregion: Option>, } #[derive(Debug,Copy,Clone,Serialize,Deserialize,Eq)]