chiark / gitweb /
hidden: Pos: handle in prep_piecestate
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 12 Mar 2021 00:52:37 +0000 (00:52 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 12 Mar 2021 01:20:49 +0000 (01:20 +0000)
There are still a few places we don't do this right.

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

index fc69153bd5271196e555a3d5a70a60440ce76540..75f5576209f47a0737522dd43f15ab3da4168e2c 100644 (file)
@@ -303,13 +303,18 @@ impl GPiece {
   #[throws(IE)]
   pub fn prep_piecestate(&self, ioccults: &IOccults,
                          ipc: &IPiece, pri: &PieceRenderInstructions)
-                     -> PreparedPieceState {
+                         -> PreparedPieceState {
+    use PriOcculted as PO;
+    let (pos, zlevel) = match &pri.occulted {
+      PO::Visible | PO::Occulted => (self.pos, self.zlevel.clone()),
+      PO::Displaced(pos, zlevel) => (*pos, zlevel.clone()),
+    };
     PreparedPieceState {
-      pos        : self.pos,
+      pos        : pos,
       held       : self.held,
       svg        : pri.make_defs(ioccults, self, ipc)?,
-      z          : self.zlevel.z.clone(),
-      zg         : self.zlevel.zg,
+      z          : zlevel.z,
+      zg         : zlevel.zg,
       angle      : pri.angle(self).to_compass(),
       pinned     : self.pinned,
       uos        : pri.ui_operations(self, ipc.p.borrow())?,
index 39f33e213724e1b067dd4456b968246fa565036e..af56dee6ba342ba809c8e0381a79117a198d36f5 100644 (file)
@@ -567,13 +567,6 @@ pub fn vpiece_decode(
   piece
 }
 
-pub fn massage_prep_piecestate(
-  _pri: &PieceRenderInstructions, // xxx
-  _ns: &mut PreparedPieceState, // xxx
-) {
-  // xxx hidden position involves adjusting pos and z and ??? here
-}
-
 // xxx prevent addpiece and removepiece in places that would be occulted
 // xxx this means this only happens on ungrab I think ?
 // xxx prevent occultation scrambling of grasped things
index cfda540b5f696b96a0b15896d7d32229dd06eba2..ca7f9eceaf762d5eee81f7fb1a9e4bae1377dd80 100644 (file)
@@ -507,8 +507,7 @@ impl<'r> PrepareUpdatesBuffer<'r> {
 
     let op = op.try_map(
       |()|{
-        let mut ns = pc.prep_piecestate(ioccults, ipc, pri)?;
-        massage_prep_piecestate(pri, &mut ns);
+        let ns = pc.prep_piecestate(ioccults, ipc, pri)?;
         <Result<_,InternalError>>::Ok(ns)
       },
       |()|{