From: Ian Jackson Date: Sun, 31 Jan 2021 23:06:37 +0000 (+0000) Subject: movement: Prevent players moving things that they haven't grasped X-Git-Tag: otter-0.4.0~571 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=b9ea714823443f6b40d1ce4a648440e55885a15e;p=otter.git 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 --- 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;