From 7c1cb104b13a1d0f32661a408c151a1398d3db50 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 27 Feb 2021 11:24:24 +0000 Subject: [PATCH] Pass ipieces to ui_operation Signed-off-by: Ian Jackson --- daemon/api.rs | 6 +++--- src/gamestate.rs | 3 ++- src/hand.rs | 5 +++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/daemon/api.rs b/daemon/api.rs index cc5550f6..afa9a30d 100644 --- a/daemon/api.rs +++ b/daemon/api.rs @@ -37,10 +37,10 @@ struct ApiPiece { struct ApiPieceOpArgs<'a> { gs: &'a mut GameState, + ipieces: &'a PiecesLoaded, player: PlayerId, piece: PieceId, p: &'a dyn Piece, - ipieces: &'a PiecesLoaded, } trait ApiPieceOp: Debug { @@ -409,7 +409,7 @@ api_route!{ } #[throws(ApiPieceOpError)] fn op(&self, a: ApiPieceOpArgs) -> PieceUpdate { - let ApiPieceOpArgs { gs,player,piece,p, .. } = a; + let ApiPieceOpArgs { gs,player,piece,p,ipieces, .. } = a; '_normal_global_ops__not_loop: loop { let pc = gs.pieces.byid_mut(piece)?; let gpl = gs.players.byid_mut(player)?; @@ -439,7 +439,7 @@ api_route!{ }; } - p.ui_operation(gs, player, piece, &self.opname, self.wrc)? + p.ui_operation(gs, ipieces, player, piece, &self.opname, self.wrc)? } } diff --git a/src/gamestate.rs b/src/gamestate.rs index d1645fcb..4cf6340b 100644 --- a/src/gamestate.rs +++ b/src/gamestate.rs @@ -148,7 +148,8 @@ pub trait Piece: Outline + Send + Debug { _gpc: &PieceState) { } fn ui_operation(&self, - _gs: &mut GameState, _player: PlayerId, _piece: PieceId, + _gs: &mut GameState, _ipieces: &PiecesLoaded, + _player: PlayerId, _piece: PieceId, _opname: &str, _wrc: WhatResponseToClientOp) -> PieceUpdateResult { throw!(OE::BadOperation) diff --git a/src/hand.rs b/src/hand.rs index bb75214c..a7e7e08d 100644 --- a/src/hand.rs +++ b/src/hand.rs @@ -127,8 +127,9 @@ impl Piece for Hand { }) } - fn ui_operation(&self, gs: &mut GameState, player: PlayerId, - piece: PieceId, opname: &str, wrc: WhatResponseToClientOp) + fn ui_operation(&self, gs: &mut GameState, _ipieces: &PiecesLoaded, + player: PlayerId, piece: PieceId, + opname: &str, wrc: WhatResponseToClientOp) -> PieceUpdateResult { let gplayers = &mut gs.players; let gpc = gs.pieces.byid_mut(piece)?; -- 2.30.2