chiark / gitweb /
Prevent use of organise function when rotated
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 7 Apr 2021 18:17:49 +0000 (19:17 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 7 Apr 2021 18:38:48 +0000 (19:38 +0100)
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 <ijackson@chiark.greenend.org.uk>
src/hand.rs
src/organise.rs

index 2b10686afa6d8057b4c9ad04689da179c830dec9..14597a1aaa2538afeaf1cca9cd44e9e5761f319b 100644 (file)
@@ -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;
     }
index 60e3331e959c763a3e78d848102d30d58977097c..fc89c24648552e98cb579448798b71fb139b32a9 100644 (file)
@@ -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<UpdateFromOpComplex> {
   let do_sort = match opname {
     "organise" => false,