savestate at the end of the step

This commit is contained in:
Dustin Carlino 2018-10-17 15:07:26 -07:00
parent 3968a78166
commit 452677672f

View File

@ -202,17 +202,18 @@ impl Sim {
self.intersection_state
.step(&mut events, self.time, map, control_map, &view);
// Savestate?
if let Some(t) = self.savestate_every {
if self.time.is_multiple_of(t) && self.time != Tick::zero() {
self.save();
}
}
// Do this at the end of the step, so that tick 0 actually occurs and things can happen
// then.
self.time = self.time.next();
// Savestate? Do this AFTER incrementing the timestep. Otherwise we could repeatedly load a
// savestate, run a step, and invalidly save over it.
if let Some(t) = self.savestate_every {
if self.time.is_multiple_of(t) {
self.save();
}
}
Ok(events)
}