From 4591e9bcb5fe3e66d1cf11c11d70f3dbe599e57d Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Tue, 20 Jul 2021 20:58:41 +0100 Subject: [PATCH] create_occultation: Pass PUOs_Simple_Modify witness at all callers Signed-off-by: Ian Jackson --- src/deck.rs | 9 +++++---- src/hand.rs | 6 ++++-- src/hidden.rs | 3 +++ src/updates.rs | 8 ++++++++ 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/deck.rs b/src/deck.rs index 0e12afb5..95e077e1 100644 --- a/src/deck.rs +++ b/src/deck.rs @@ -219,13 +219,15 @@ impl PieceTrait for Deck { ); } + let puos = PUOs_Simple_Modify; + if let Some((region, views)) = region_views { dbgc!("creating occ"); xupdates.extend( create_occultation(&mut gen.unique_gen(), &mut gs.max_z, gplayers, gpieces, goccults, ipieces, ioccults, to_recalculate, rot_checked, - region, piece, views)? + region, piece, views, &puos)? ); dbgc!("creating occ done", &xupdates); } @@ -236,9 +238,8 @@ impl PieceTrait for Deck { (PieceUpdate { wrc, log, - ops: PUOs::Simple(PUO::Modify(())), - }, - xupdates.into_unprepared(None)) + ops: puos.into(), + }, xupdates.into_unprepared(None)) } fn occultation_notify_hook(&self, piece: PieceId) -> UnpreparedUpdates { diff --git a/src/hand.rs b/src/hand.rs index 307f0055..721a2c83 100644 --- a/src/hand.rs +++ b/src/hand.rs @@ -257,6 +257,8 @@ impl PieceTrait for Hand { dbgc!("ui op k entry", &opname, &xdata); + let puos = PUOs_Simple_Modify; + let (new_owner, xupdates, did) = match (opname, xdata.owner.is_some()) { @@ -293,7 +295,7 @@ impl PieceTrait for Hand { gplayers, gpieces, goccults, ipieces, ioccults, to_recalculate, rot_checked, - region, piece, views)?; + region, piece, views, &puos)?; xupdates } }; @@ -336,7 +338,7 @@ impl PieceTrait for Hand { (PieceUpdate { wrc, log, - ops: PUOs::Simple(PUO::Modify(())), + ops: puos.into(), }, xupdates.into_unprepared(None)) } diff --git a/src/hidden.rs b/src/hidden.rs index f291e938..a4f1b3c8 100644 --- a/src/hidden.rs +++ b/src/hidden.rs @@ -895,6 +895,9 @@ pub fn create_occultation( region: Region, occulter: PieceId, views: OccultationViews, + // Caller must promise not to fail if we succeed, so that this + // update actually happens! + _puos_will_return: &PUOs_Simple_Modify, ) -> Vec<(PieceId, PieceUpdateOps)> { { let ogpc = gpieces.get(occulter).ok_or_else( diff --git a/src/updates.rs b/src/updates.rs index 616ad8ef..69a3ff07 100644 --- a/src/updates.rs +++ b/src/updates.rs @@ -213,6 +213,14 @@ impl From for PieceUpdate { } } + +#[allow(non_camel_case_types)] +#[derive(Copy,Clone,Debug)] +pub struct PUOs_Simple_Modify; +impl From for PieceUpdateOps { + fn from(_: PUOs_Simple_Modify) -> Self { PUOs::Simple(PUO::Modify(())) } +} + // ---------- for traansmission ---------- #[derive(Debug,Serialize)] -- 2.30.2