fix traffic signal diagram in sandbox mode after lots of time has passed :)

This commit is contained in:
Dustin Carlino 2019-08-06 11:59:58 -07:00
parent 1ff4933f6a
commit b5c48fca38

View File

@ -50,10 +50,11 @@ impl ControlTrafficSignal {
pub fn current_cycle_and_remaining_time(&self, time: Duration) -> (usize, &Cycle, Duration) {
let cycle_idx = (time / CYCLE_DURATION).floor() as usize;
let cycle = &self.cycles[cycle_idx % self.cycles.len()];
let normalized_cycle_idx = cycle_idx % self.cycles.len();
let cycle = &self.cycles[normalized_cycle_idx];
let next_cycle_time = CYCLE_DURATION * (cycle_idx + 1) as f64;
let remaining_cycle_time = next_cycle_time - time;
(cycle_idx, cycle, remaining_cycle_time)
(normalized_cycle_idx, cycle, remaining_cycle_time)
}
fn validate(&self, map: &Map) -> Result<(), Error> {