mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-24 01:15:12 +03:00
Fix a crash in the trip info panel. If you happen to open a trip of a
car waiting to spawn, its total path distance is briefly 0. Also silence the lane-changing info for the moment, until work resumes there.
This commit is contained in:
parent
160d65ca28
commit
bf316fa99c
@ -143,7 +143,7 @@ pub fn ongoing(
|
||||
details,
|
||||
phases,
|
||||
&app.primary.map,
|
||||
Some(props.dist_crossed / props.total_dist),
|
||||
Some(props.dist_crossed.safe_percent(props.total_dist)),
|
||||
));
|
||||
Widget::col(col)
|
||||
}
|
||||
|
@ -102,6 +102,15 @@ impl Distance {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Calculates a percentage, usually in [0.0, 1.0], of self / other. If the denominator is
|
||||
/// zero, returns 0%.
|
||||
pub fn safe_percent(self, other: Distance) -> f64 {
|
||||
if other == Distance::ZERO {
|
||||
return 0.0;
|
||||
}
|
||||
self / other
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for Distance {
|
||||
|
@ -1123,12 +1123,14 @@ impl DrivingSimState {
|
||||
)
|
||||
{
|
||||
// TODO Can downgrade this to an alert or debug once active work has settled down
|
||||
info!(
|
||||
"{} is starting to change lanes from {} to {}",
|
||||
car.vehicle.id,
|
||||
car.router.head(),
|
||||
target_lane
|
||||
);
|
||||
if false {
|
||||
info!(
|
||||
"{} is starting to change lanes from {} to {}",
|
||||
car.vehicle.id,
|
||||
car.router.head(),
|
||||
target_lane
|
||||
);
|
||||
}
|
||||
|
||||
// Exit the old queue (leaving a dynamic blockage in place)
|
||||
self.queues
|
||||
|
Loading…
Reference in New Issue
Block a user