From 93ccf96848cd59e2edaccc81596de74f5de8fd8c Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Fri, 20 May 2022 19:04:33 +0100 Subject: [PATCH] fastsplit: Properly occult the left-behind piece When we split, occult the new piece, if appropriate. Signed-off-by: Ian Jackson --- src/fastsplit.rs | 23 +++++++++++++++++++++++ src/hidden.rs | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/fastsplit.rs b/src/fastsplit.rs index 5b492696..84d49386 100644 --- a/src/fastsplit.rs +++ b/src/fastsplit.rs @@ -152,6 +152,28 @@ impl InstanceGuard<'_> { let npiece = ig.gs.pieces.as_mut(modperm).insert(ngpc); ig.ipieces.as_mut(modperm).insert(npiece, nipc); + // "Recalculate" the occultation of the piece we're leaving behind. + let ((), r_unprepared) = ToRecalculate::with(|mut to_permute| { + let () = recalculate_occultation_general( + &mut ig.gs.gen.unique_gen(), + &mut ig.gs.players, &mut ig.gs.pieces, + &mut ig.gs.occults, &ig.ipieces, &ig.ioccults, + &mut to_permute, npiece, + // We are treat this as a new piece, but it's not, semantically. + // We don't log anything, since that new piece is not really + // supposed to be interesting and the piece implwementation + // is supposed to have logged whatever is needed. + || (), + (), + |_old,_new,_desc| (), + |_puopp, ()| (), + ).unwrap_or_else(|e| { + // not good + error!("failed to recalculate after piece split! {:?}", &e); + }); + ((), to_permute.implement(ig)) + }); + let n_unprepared = vec![( npiece, PUOs::Simple(PUO::Insert(())), @@ -159,6 +181,7 @@ impl InstanceGuard<'_> { let unprepared = chain!( n_unprepared, + r_unprepared, t_unprepared, ).collect(); diff --git a/src/hidden.rs b/src/hidden.rs index 3d18d23f..084e5dff 100644 --- a/src/hidden.rs +++ b/src/hidden.rs @@ -510,7 +510,7 @@ pub fn vpiece_decode( } #[throws(InternalError)] -fn recalculate_occultation_general< +pub fn recalculate_occultation_general< RD: Debug, // return data LD: Debug, // log data VF: FnOnce() -> RD, // ret_vanilla -- 2.30.2