PartialPlayerData,
#[error("Coordinate overflow")]
CoordinateOverflow(#[from] CoordinateOverflow),
+ #[error("Z Coordinate overflow (game is too crufty?)")]
+ ZCoordinateOverflow(#[from] zcoord::Overflow),
#[error("Multiple errors occurred where only one could be reported")]
Aggregated,
}
// actually do things:
dbgc!("creating occ");
let xupdates =
- create_occultation(&mut gen.unique_gen(),
+ create_occultation(&mut gen.unique_gen(), &mut gs.max_z,
gplayers, gpieces, goccults, ipieces, ioccults,
to_permute,
region, piece, views)?;
#[throws(OnlineError)]
pub fn create_occultation(
gen: &mut UniqueGenGen,
+ max_z: &mut ZCoord,
gplayers: &mut GPlayers,
gpieces: &mut GPieces,
goccults: &mut GameOccults,
if ogpc.occult.active.is_some() {
throw!(internal_logic_error("re-occulting!"))
}
+
+ if let Some(displ_z) = {
+ views.views
+ .iter().map(|ov| &ov.occult)
+ .chain(iter::once(&views.defview))
+ .filter_map(|ok| { use OccKG::*; match ok {
+ Visible | Scrambled | Invisible => None,
+ Displaced((_area, ref z)) => Some(z)
+ }})
+ .max()
+ } {
+ // We expect that ogpc.zlevel.z.increment() is shorter than
+ // the displ_z, but in case it isn't, we must look at both.
+ (||{
+ max_z.update_max(&ogpc.zlevel.z.clone_mut().increment()?);
+ max_z.update_max(&displ_z.plus_offset(! 0)?);
+ Ok::<_,IE>(())
+ })()?;
+ }
}
for occ in goccults.occults.values() {
None => {
let a = self.table.push(new);
let b = self.zg.push(zg);
- // xxx maybe update z_max in gs
+ // gs.max_z was updated when we created the occultation
assert_eq!(a,b);
a
},