chiark / gitweb /
api: Allow setz to strictly lower an occulter
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 5 Jul 2021 22:09:42 +0000 (23:09 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 6 Jul 2021 00:24:04 +0000 (01:24 +0100)
This will be useful for various things, including in particular
recovering from things stuck under occulters, and making the UI "b"
work properly.

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

index 6b62f955e29d2b98c26164a4e516b4f37beb2227..db4636a20cd0ac64ca3153130269ed753cd86fe2 100644 (file)
@@ -450,7 +450,9 @@ api_route!{
   fn op(&self, a: ApiPieceOpArgs) -> PieceUpdate {
     let ApiPieceOpArgs { gs,piece, .. } = a;
     let gpc = gs.pieces.byid_mut(piece).unwrap();
-    if gpc.occult.is_active() { throw!(OE::Occultation) }
+    if gpc.occult.is_active() {
+      if self.z >= gpc.zlevel.z { throw!(OE::Occultation) }
+    }
     gpc.zlevel = ZLevel { z: self.z.clone(), zg: gs.gen };
     let update = PieceUpdateOp::SetZLevel(());
     (WhatResponseToClientOp::Predictable,