enum ApiPieceOpError {
ReportViaResponse(#[from] OnlineError),
ReportViaUpdate(#[from] PieceOpError),
+ PartiallyProcessed(PieceOpError, Vec<LogEntry>),
}
display_as_debug!(ApiPieceOpError);
Err(ReportViaUpdate(poe)) => {
PrepareUpdatesBuffer::piece_report_error(
&mut ig, poe,
- piece, player, client, &lens
+ piece, vec![], client, &lens
+ )?;
+ },
+ Err(PartiallyProcessed(poe, logents)) => {
+ PrepareUpdatesBuffer::piece_report_error(
+ &mut ig, poe,
+ piece, logents, client, &lens
)?;
},
Err(ReportViaResponse(err)) => {
-> (PieceUpdateOp<()>, Vec<LogEntry>) {
let pc = gs.pieces.byid_mut(piece).unwrap();
let (pos, clamped) = self.0.clamped(gs.table_size);
+ let logents = vec![];
pc.pos = pos;
if clamped {
- Err(ApiPieceOpError::ReportViaUpdate(PieceOpError::PosOffTable))?;
+ throw!(ApiPieceOpError::PartiallyProcessed(
+ PieceOpError::PosOffTable,
+ logents,
+ ));
}
let update = PieceUpdateOp::Move(self.0);
- (update, vec![])
+ (update, logents)
}
}
Self::new(ig, None, Some(1))
}
pub fn piece_report_error(ig: &mut Instance,
- error: PieceOpError,
- piece: PieceId, player: PlayerId, client: ClientId,
+ error: PieceOpError, piece: PieceId,
+ logents: Vec<LogEntry>, client: ClientId,
lens: &dyn Lens) -> Result<(),OE> {
let mut buf = PrepareUpdatesBuffer::new_for_error(ig);
let update = buf.piece_update_fallible(
},
_ => panic!(),
};
- let update = PreparedUpdate { gen: buf.gen, us : vec![ update ] };
- assert!(buf.us.is_empty());
- mem::drop(buf);
- let pl_updates = ig.updates.get_mut(player).ok_or(OE::NoPlayer)?;
- pl_updates.push(Arc::new(update));
+ buf.us.push(update);
+ buf.log_updates(logents);
Ok(())
}