From 75542c4e011c86fecd7411ff960f6d81c2a546a7 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 7 Apr 2021 19:17:49 +0100 Subject: [PATCH] Prevent use of organise function when rotated Add the proof token to the organise function, and check it in hand. This only currently makes any difference for player labels, because the other kinds of hand are unrotateable from load time. Because we don't update uos on rotation, the player can try to organise a rotated player label, but they will get an error. Signed-off-by: Ian Jackson --- src/hand.rs | 3 ++- src/organise.rs | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/hand.rs b/src/hand.rs index 2b10686a..14597a1a 100644 --- a/src/hand.rs +++ b/src/hand.rs @@ -223,10 +223,11 @@ impl PieceTrait for Hand { -> UpdateFromOpComplex { if let Some(r) = { let gpc = a.gs.pieces.byid_mut(a.piece)?; + let rot_checked = gpc.occulter_check_unrotated(vis)?; let rect = self.shape.outline.rect(gpc.pos) .map_err(|CoordinateOverflow| internal_error_bydebug(&(&gpc.pos, &self.shape)))?; - organise::ui_operation(&mut a, opname, wrc, &rect)? + organise::ui_operation(&mut a, rot_checked, opname, wrc, &rect)? } { return r; } diff --git a/src/organise.rs b/src/organise.rs index 60e3331e..fc89c246 100644 --- a/src/organise.rs +++ b/src/organise.rs @@ -230,8 +230,8 @@ fn try_layout(region: &Rect, #[throws(ApiPieceOpError)] -pub fn ui_operation(a: &mut ApiPieceOpArgs<'_>, opname: &str, - _wrc: WhatResponseToClientOp, region: &Rect) +pub fn ui_operation(a: &mut ApiPieceOpArgs<'_>, _: OcculterRotationChecked, + opname: &str, _wrc: WhatResponseToClientOp, region: &Rect) -> Option { let do_sort = match opname { "organise" => false, -- 2.30.2