From b9ea714823443f6b40d1ce4a648440e55885a15e Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 31 Jan 2021 23:06:37 +0000 Subject: [PATCH] movement: Prevent players moving things that they haven't grasped Also, a todo. Signed-off-by: Ian Jackson squash! movement: Prevent players moving things that they haven't grasped --- daemon/api.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/daemon/api.rs b/daemon/api.rs index 1e96ba74..d863ba7f 100644 --- a/daemon/api.rs +++ b/daemon/api.rs @@ -322,6 +322,17 @@ api_route!{ api_move, "/_/api/m", struct ApiPieceMove(Pos); + #[throws(OnlineError)] + fn check_held(&self, pc: &PieceState, player: PlayerId) { + // This will ensure that occultations are (in general) properly + // updated, because the player will (have to) release the thing + // again + if pc.held != Some(player) { + throw!(OnlineError::PieceHeld) + } + // xxx prevent moving anything that is occulting + } + #[throws(ApiPieceOpError)] fn op(&self, a: ApiPieceOpArgs) -> PieceUpdate { let ApiPieceOpArgs { gs,piece, .. } = a; -- 2.30.2