From 6b272d7bd630fe35ae7048d4b82a56616c9b2ffa Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 3 Apr 2021 17:58:19 +0100 Subject: [PATCH] updates: Replace *_nc functions, pass IsResponseToClientOp around Signed-off-by: Ian Jackson --- daemon/cmdlistener.rs | 2 +- src/deck.rs | 2 +- src/hand.rs | 2 +- src/organise.rs | 2 +- src/updates.rs | 11 +++++++---- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/daemon/cmdlistener.rs b/daemon/cmdlistener.rs index 1b59a26b..14aecf75 100644 --- a/daemon/cmdlistener.rs +++ b/daemon/cmdlistener.rs @@ -667,7 +667,7 @@ fn execute_game_insn<'cs, 'igr, 'ig: 'igr>( if xupdates.len() != 0 { Some( Box::new(move |prepub: &mut PrepareUpdatesBuffer| - prepub.piece_updates_nc(xupdates)) + prepub.piece_updates(xupdates, &None)) as SomeUnpreparedUpdates ) } else { None }, diff --git a/src/deck.rs b/src/deck.rs index ec0da91a..2e70570c 100644 --- a/src/deck.rs +++ b/src/deck.rs @@ -230,7 +230,7 @@ impl PieceTrait for Deck { wrc, log, ops: PUOs::Simple(PUO::Modify(())), }, - xupdates.into_unprepared_nc()) + xupdates.into_unprepared(None)) } fn occultation_notify_hook(&self, piece: PieceId) -> UnpreparedUpdates { diff --git a/src/hand.rs b/src/hand.rs index 7aff7793..08804fcf 100644 --- a/src/hand.rs +++ b/src/hand.rs @@ -321,6 +321,6 @@ impl PieceTrait for Hand { (PieceUpdate { wrc, log, ops: PUOs::Simple(PUO::Modify(())), - }, xupdates.into_unprepared_nc()) + }, xupdates.into_unprepared(None)) } } diff --git a/src/organise.rs b/src/organise.rs index 26134285..9914f5a3 100644 --- a/src/organise.rs +++ b/src/organise.rs @@ -299,6 +299,6 @@ pub fn ui_operation(a: &mut ApiPieceOpArgs<'_>, opname: &str, wrc: WRC::Predictable, log, ops: PUOs::PerPlayer(default()), - }, updates.into_unprepared_nc())) + }, updates.into_unprepared(None))) })() // <- no ?, shows it's infallible } diff --git a/src/updates.rs b/src/updates.rs index ac7abedd..f36d942b 100644 --- a/src/updates.rs +++ b/src/updates.rs @@ -789,9 +789,11 @@ impl<'r> PrepareUpdatesBuffer<'r> { self.us.push(PUE::Image(PreparedUpdateEntry_Image { ims })) } - pub fn piece_updates_nc(&mut self, updates: Vec<(PieceId, PieceUpdateOps)>) { + pub fn piece_updates(&mut self, + updates: Vec<(PieceId, PieceUpdateOps)>, + by_client: &IsResponseToClientOp) { for (piece, ops) in updates { - self.piece_update(piece,&None, ops); + self.piece_update(piece, by_client, ops); } } @@ -975,10 +977,11 @@ impl PreparedUpdate { #[ext(pub)] impl Vec<(PieceId, PieceUpdateOps)> { - fn into_unprepared_nc(self) -> UnpreparedUpdates { + fn into_unprepared(self, by_client: IsResponseToClientOp) + -> UnpreparedUpdates { Some(Box::new( move |buf: &mut PrepareUpdatesBuffer| { - buf.piece_updates_nc(self) + buf.piece_updates(self, &by_client) })) } } -- 2.30.2