let mut ig = iad.gref.lock()?;
ig.save_game_later();
- ToRecalculate::with(|mut to_recalculate| {
+ let (ok, unprepared_outer) = ToRecalculate::with(|mut to_recalculate| {
let r = (||{
let g = &mut *ig;
&mut gs.pieces,
&mut gs.occults,
&g.ipieces))
- })?;
+ });
+
+ if let Some(unprepared) = unprepared_outer {
+ let mut prepub = PrepareUpdatesBuffer::new(&mut ig, None, None);
+ unprepared(&mut prepub);
+ prepub.finish();
+ }
+
+ ok?;
""
}
mut insns: Vec<MgmtGameInstruction>,
how: MgmtGameUpdateMode) -> MgmtResponse
{
- ToRecalculate::with(|mut to_permute| {
+ let (ok, uu) = ToRecalculate::with(|mut to_permute| {
let r = (||{
let mut uh = UpdateHandler::from_how(how);
&mut gs.occults,
&g.ipieces)
})
- })?
+ });
+
+ if let Some(uu) = uu {
+ let mut ig = igu.by_mut(Authorisation::authorise_any());
+ let mut prepub = PrepareUpdatesBuffer::new(&mut ig, None, None);
+ uu(&mut prepub);
+ prepub.finish();
+ }
+
+ ok?
}
#[derive(Debug,Default)]
pub struct ToRecalculate {
outdated: HashSet<OccId>,
}
- #[derive(Debug)]
- pub struct Implemented(());
+ #[must_use]
+ pub struct Implemented(UnpreparedUpdates);
+ impl Debug for Implemented {
+ #[throws(fmt::Error)]
+ fn fmt(&self, f: &mut Formatter) {
+ write!(f, "Implemented({})",
+ if self.0.is_some() { "Some(..)" } else { "None" })?;
+ }
+ }
impl ToRecalculate {
- pub fn with<R, F: FnOnce(Self) -> (R, Implemented)>(f: F) -> R {
+ pub fn with<R, F: FnOnce(Self) -> (R, Implemented)>
+ (f: F) -> (R, UnpreparedUpdates)
+ {
let to_recalculate = ToRecalculate { outdated: default() };
- let (r, Implemented(())) = f(to_recalculate);
- r
+ let (r, Implemented(uu)) = f(to_recalculate);
+ (r, uu)
}
pub fn mark_dirty(&mut self, occid: OccId) { self.outdated.insert(occid); }
pub fn implement(self,
consistency_check(gplayers, gpieces, goccults);
- Implemented(())
+ Implemented(None)
}
}
}