players: default(),
log: default(),
gen: Generation(0),
- max_z: default(),
+ max_z: ZLevel::zero(),
occults: default(),
};
let mut updates = Vec::with_capacity(count_len);
let mut pos = pos.unwrap_or(DEFAULT_POS_START);
- let mut z = gs.max_z.clone_mut();
+ let mut z = gs.max_z.z.clone_mut();
for piece_i in count {
let ilks = &mut ig.ioccults.ilks;
let face = face.unwrap_or_default();
ilks.insert(ilkname, OccultIlkData { p_occ })
});
gpc.pos.clamped(gs.table_size).map_err(|_| SpecError::PosOffTable)?;
- if gpc.zlevel.z > gs.max_z { gs.max_z = gpc.zlevel.z.clone() }
+ if gpc.zlevel > gs.max_z { gs.max_z = gpc.zlevel.clone() }
let piece = gs.pieces.as_mut(modperm).insert(gpc);
let p = IPieceTraitObj::new(p);
ig.ipieces.as_mut(modperm).insert(piece, IPiece { p, occilk });
// ---------- general data types ----------
-#[derive(Debug,Clone,Serialize,Deserialize,Eq,PartialEq,Ord,PartialOrd)]
+#[derive(Debug,Clone,Eq,PartialEq,Ord,PartialOrd)]
+#[derive(Serialize,Deserialize)]
pub struct ZLevel {
pub z: ZCoord,
pub zg: Generation,
pub pieces: GPieces,
pub gen: Generation,
pub log: VecDeque<(Generation, Arc<CommittedLogEntry>)>,
- pub max_z: ZCoord,
+ pub max_z: ZLevel,
pub players: GPlayers,
pub occults: GameOccults,
}
pieces: default(),
gen: Generation(0),
log: default(),
- max_z: default(),
+ max_z: ZLevel::zero(),
players: default(),
occults: default(),
} }
}
+impl ZLevel {
+ pub fn zero() -> Self { ZLevel { z: default(), zg: Generation(0) } }
+}
+
// ---------- log expiry ==========
impl GameState {
#[throws(OnlineError)]
pub fn create_occultation(
gen: &mut UniqueGenGen,
- max_z: &mut ZCoord,
+ max_z: &mut ZLevel,
gplayers: &mut GPlayers,
gpieces: &mut GPieces,
goccults: &mut GameOccults,
} {
// We expect that ogpc.zlevel.z.increment() is shorter than
// the displ_z, but in case it isn't, we must look at both.
+ let max_z = &mut max_z.z;
(||{
max_z.update_max(&ogpc.zlevel.z.clone_mut().increment()?);
max_z.update_max(&displ_z.plus_offset(! 0)?);
-> SecondarySlotMap<PlayerId, U>
where
GUF: FnOnce(&mut GPiece, Generation, &IsResponseToClientOp),
- WMZ: FnMut(&mut ZCoord, &GPiece),
+ WMZ: FnMut(&mut ZLevel, &GPiece),
MUF: FnMut(&IOccults, &GameState, &GPiece, &IPiece,
PlayerId, &Option<PieceRenderInstructions>)
-> Result<Option<U>,IE>,
(
piece,by_client, gen_update,
- |max_z, gpc| max_z.update_max(&gpc.zlevel.z),
+ |max_z, gpc| max_z.update_max(&gpc.zlevel),
|ioccults,gs,gpc,ipc,player,pri| {
let ops = match ops {