#[serde(transparent)]
pub struct IPieces(ActualIPieces);
pub type ActualIPieces = SecondarySlotMap<PieceId, IPiece>;
+
+/// Proof token that it is OK to modify the array
+///
+/// This exists to prevent bugs where we forget to save aux
#[derive(Copy,Clone,Debug)]
pub struct ModifyingPieces(());
}
}
+impl ModifyingPieces {
+ pub fn allow_without_necessarily_saving() -> ModifyingPieces {
+ ModifyingPieces(())
+ }
+}
+
// ---------- Main API for instance lifecycle ----------
impl InstanceRef {
ModifyingPieces(())
}
+ pub fn modify_pieces_not_necessarily_saving_aux(&mut self)
+ -> ModifyingPieces {
+ self.save_game_later();
+ ModifyingPieces(())
+ }
+
fn token_register<Id:AccessId>(
&mut self,
token: RawToken,