pub struct Notches {
freelist: NotchPtr,
table: IndexVec<Notch, NotchRecord>,
+ zg: IndexVec<Notch, Generation>, // last time notch was (re)filled
}
impl Notches {
}
/// correctness: piece must not already be in this `Notches`
- pub fn insert(&mut self, piece: PieceId) -> Notch {
+ pub fn insert(&mut self, zg: Generation, piece: PieceId) -> Notch {
let new = NR::Piece(piece);
match self.freelist.take() {
None => {
- self.table.push(new)
+ let a = self.table.push(new);
+ let b = self.zg.push(zg);
+ assert_eq!(a,b);
+ a
},
Some(old_free_head) => {
self.freelist = self.table[old_free_head].unwrap_free();
self.table[old_free_head] = new;
+ self.zg[old_free_head] = zg;
old_free_head
},
}
let mut pieces = SecondarySlotMap::new();
for op in &self.todo { match op {
&Can::Insert(p) => {
- let notch = notches.insert(p);
+ let notch = notches.insert(Generation(0), p);
notches.check();
pieces.insert(p, notch);
},
occ: &mut Occultation,
gplayers: &mut GPlayers,
gpieces: &mut GPieces,
- ipieces: &IPieces,
- z_gen: Generation /* unique to this call */) {
+ ipieces: &IPieces) {
let new_notches = {
let mut ilks: HashMap<OccultIlkId, (
LF: FnOnce(Html, Html, Option<&Html>) -> LD, // log_callback
RF: FnOnce(PieceUpdateOps_PerPlayer, LD) -> RD, // ret_callback
>(
+ gen: &mut UniqueGenGen,
gplayers: &GPlayers,
gpieces: &mut GPieces,
goccults: &mut GameOccults,
};
let passive = if let Some(occid) = occulteds.new {
let notch = notches(goccults, occid)
- .insert(piece);
+ .insert(gen.next(), piece);
Some((occid, notch))
} else {
None
{
ToRecompute::with(|mut to_recompute| (
recalculate_occultation_general(
+ &mut gs.gen.unique_gen(),
&gs.players, &mut gs.pieces, &mut gs.occults, ipieces, &mut to_recompute,
piece, vanilla_log,
|log| (vanilla_wrc, vanilla_op, log).into(),
log
}
),
- to_recompute.implement(&mut gs.gen, &mut gs.players,
+ to_recompute.implement(&mut gs.players,
&mut gs.pieces, &mut gs.occults,
ipieces),
))?
#[throws(IE)]
fn recalculate_occultation_ofmany(
+ gen: &mut UniqueGenGen,
gplayers: &GPlayers,
gpieces: &mut GPieces,
goccults: &mut GameOccults,
updates: &mut Vec<(PieceId, PieceUpdateOps)>,
){
recalculate_occultation_general(
- gplayers, gpieces, goccults, ipieces, to_recompute,
+ gen, gplayers, gpieces, goccults, ipieces, to_recompute,
ppiece,
(), |_|(),
|_,_,_|(), |puo_pp, ()|{
}
pub fn mark_dirty(&mut self, occid: OccId) { self.outdated.insert(occid); }
pub fn implement(self,
- gen: &mut Generation,
gplayers: &mut GPlayers,
gpieces: &mut GPieces,
goccults: &mut GameOccults,
ipieces: &IPieces) -> Implemented {
- let mut gen = gen.unique_gen(); // xxx not used
-
for occid in self.outdated {
if let Some(occ) = goccults.occults.get_mut(occid) {
- vpid::permute(occid, occ, gplayers, gpieces, ipieces, gen.next());
+ vpid::permute(occid, occ, gplayers, gpieces, ipieces);
}
}
#[throws(OnlineError)]
pub fn create_occultation(
- gen: &mut Generation,
+ gen: &mut UniqueGenGen,
gplayers: &mut GPlayers,
gpieces: &mut GPieces,
goccults: &mut GameOccults,
ogpc.occult.active = Some(occid);
for &ppiece in &recalc {
- recalculate_occultation_ofmany(gplayers, gpieces, goccults, ipieces,
+ recalculate_occultation_ofmany(gen,
+ gplayers, gpieces, goccults, ipieces,
&mut to_recompute,
ppiece, &mut updates)?;
}
goccults.occults.remove(occid).expect("inserted this earlier");
e
}),
- to_recompute.implement(gen, gplayers, gpieces, goccults, ipieces),
+ to_recompute.implement(gplayers, gpieces, goccults, ipieces),
))?;
dbgc!(&updates);
#[throws(IE)]
pub fn remove_occultation(
- gen: &mut Generation,
+ gen: &mut UniqueGenGen,
gplayers: &mut GPlayers,
gpieces: &mut GPieces,
goccults: &mut GameOccults,
};
for &ppiece in pieces.iter() {
- recalculate_occultation_ofmany(gplayers, gpieces, goccults, ipieces,
+ recalculate_occultation_ofmany(gen,
+ gplayers, gpieces, goccults, ipieces,
&mut to_recompute,
ppiece, &mut updates)
.unwrap_or_else(|e| {
aggerr.record(internal_logic_error("removing occultation of non-piece"));
}
},
- to_recompute.implement(gen, gplayers, gpieces, goccults, ipieces),
+ to_recompute.implement(gplayers, gpieces, goccults, ipieces),
));
aggerr.ok()?;