mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-01 10:44:56 +03:00
fix traffic signal diagram in sandbox mode after lots of time has passed :)
This commit is contained in:
parent
1ff4933f6a
commit
b5c48fca38
@ -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> {
|
||||
|
Loading…
Reference in New Issue
Block a user