From: Ian Jackson Date: Sun, 14 Mar 2021 22:23:22 +0000 (+0000) Subject: cmdlistener: Plumb a ToPermute through to execute_game_insn X-Git-Tag: otter-0.4.0~47 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=16a21754c61e19be6d3a238a32aac958497802fe;p=otter.git cmdlistener: Plumb a ToPermute through to execute_game_insn Signed-off-by: Ian Jackson --- diff --git a/daemon/cmdlistener.rs b/daemon/cmdlistener.rs index 09fe887f..d2176a02 100644 --- a/daemon/cmdlistener.rs +++ b/daemon/cmdlistener.rs @@ -239,7 +239,9 @@ fn execute_game_insn<'cs, 'igr, 'ig: 'igr>( ag: &'_ mut AccountsGuard, ig: &'igr mut Unauthorised, InstanceName>, update: MgmtGameInstruction, - who: &Html) + who: &Html, + _to_permute: &mut ToPermute, +) -> Result ,ME> { type U = ExecuteGameChangeUpdates; @@ -754,6 +756,9 @@ fn execute_for_game<'cs, 'igr, 'ig: 'igr>( mut insns: Vec, how: MgmtGameUpdateMode) -> MgmtResponse { + ToPermute::with(|mut to_permute| { + let r = (||{ + let mut uh = UpdateHandler::from_how(how); let mut responses = Vec::with_capacity(insns.len()); let mut auth = None; @@ -773,7 +778,8 @@ fn execute_for_game<'cs, 'igr, 'ig: 'igr>( }; let res = (||{ for insn in insns.drain(0..) { - let (updates, resp, ig) = execute_game_insn(cs, ag, igu, insn, &who)?; + let (updates, resp, ig) = execute_game_insn(cs, ag, igu, insn, &who, + &mut to_permute)?; uh.accumulate(ig, updates)?; responses.push(resp); auth = Some(Authorisation::authorised(&*ig.name)); @@ -784,10 +790,22 @@ fn execute_for_game<'cs, 'igr, 'ig: 'igr>( if let Some(auth) = auth { igu.by_mut(auth).save_game_now()?; } - MgmtResponse::AlterGame { + Ok::<_,ME>(MgmtResponse::AlterGame { responses, error: res.unwrap_or_else(Some), - } + }) + + })(); + (r, { + let ig = igu.by_mut(Authorisation::authorise_any()); + let g = &mut **ig; + let gs = &mut g.gs; + to_permute.implement(&mut gs.players, + &mut gs.pieces, + &mut gs.occults, + &g.ipieces) + }) + })? } #[derive(Debug,Default)]