mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-01 02:33:54 +03:00
make sure we're not exceeding speed limit...
This commit is contained in:
parent
1845e5881b
commit
6e3f246877
@ -241,6 +241,11 @@ impl Car {
|
||||
self.speed = new_speed;
|
||||
|
||||
loop {
|
||||
let current_speed_limit = self.on.speed_limit(map);
|
||||
if self.speed > current_speed_limit {
|
||||
return Err(InvariantViolated(format!("{} is going {} on {:?}, which has a speed limit of {}", self.id, self.speed, self.on, current_speed_limit)));
|
||||
}
|
||||
|
||||
let leftover_dist = self.dist_along - self.on.length(map);
|
||||
// == 0.0 is important! If no floating point imprecision happens, cars will stop RIGHT
|
||||
// at the end of a lane, with exactly 0 leftover distance. We don't want to bump them
|
||||
|
Loading…
Reference in New Issue
Block a user