mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-23 22:42:32 +03:00
Fix a treachurous bug that was crashing the simulation, first uncovered
by chance in #870. A vehicle exits a driveway and blocks a lane on its way out. When we try to clear the static blockage, the queue calculation recurses to resolve distances on the queue where that vehicle is entering. But since we temporarily don't have the car in the list of cars (for the borrow checker), it was crashing. One of those "2 hours to figure out, 30 seconds to fix" bugs.
This commit is contained in:
parent
b867859dde
commit
9b4abae174
@ -25,7 +25,7 @@ pub fn prebake_all() {
|
||||
|
||||
let mut summaries = Vec::new();
|
||||
for name in vec![
|
||||
//MapName::seattle("arboretum"),
|
||||
MapName::seattle("arboretum"),
|
||||
MapName::seattle("montlake"),
|
||||
//MapName::seattle("lakeslice"),
|
||||
//MapName::seattle("phinney"),
|
||||
|
@ -5200,6 +5200,11 @@
|
||||
"uncompressed_size_bytes": 49839934,
|
||||
"compressed_size_bytes": 19580571
|
||||
},
|
||||
"data/system/us/seattle/prebaked_results/arboretum/weekday.bin": {
|
||||
"checksum": "e2569e2629949dad887eb75f7184c910",
|
||||
"uncompressed_size_bytes": 16719161,
|
||||
"compressed_size_bytes": 6419906
|
||||
},
|
||||
"data/system/us/seattle/prebaked_results/montlake/car vs bike contention.bin": {
|
||||
"checksum": "ce3dcac62c670a2260cd9258fd1d29b7",
|
||||
"uncompressed_size_bytes": 4288,
|
||||
|
@ -428,13 +428,23 @@ impl DrivingSimState {
|
||||
for lane in blocked_starts {
|
||||
// Calculate the exact positions along this blocked queue (which is ***NOT***
|
||||
// the same queue that the unparking car is in!). Use that to update the
|
||||
// follower. Note that it's fine that the current car isn't currently in
|
||||
// self.cars; the static blockage doesn't need it.
|
||||
// follower.
|
||||
//
|
||||
// It SHOULD be fine that the current car isn't currently in self.cars; the
|
||||
// static blockage doesn't need it. But calculating positions on one queue may
|
||||
// recurse to the queue where the current car is. So temporarily make the car
|
||||
// visible in this query.
|
||||
self.cars.insert(car.vehicle.id, car.clone());
|
||||
|
||||
let dists = self.queues[&Traversable::Lane(*lane)].get_car_positions(
|
||||
now,
|
||||
&self.cars,
|
||||
&self.queues,
|
||||
);
|
||||
|
||||
// Undo the above hack.
|
||||
self.cars.remove(&car.vehicle.id);
|
||||
|
||||
let idx = dists.iter().position(|entry| matches!(entry.member, Queued::StaticBlockage { cause, ..} if cause == car.vehicle.id)).unwrap();
|
||||
self.update_follower(idx, &dists, now, ctx);
|
||||
|
||||
|
@ -1,4 +1,11 @@
|
||||
[
|
||||
{
|
||||
"map": "arboretum (in seattle (us))",
|
||||
"scenario": "weekday",
|
||||
"finished_trips": 76640,
|
||||
"cancelled_trips": 0,
|
||||
"total_trip_duration_seconds": 43692260.45700034
|
||||
},
|
||||
{
|
||||
"map": "montlake (in seattle (us))",
|
||||
"scenario": "weekday",
|
||||
|
Loading…
Reference in New Issue
Block a user