mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-27 00:12:55 +03:00
fix an awesome parking contention bug
This commit is contained in:
parent
72c391fe15
commit
0543cb015e
@ -171,12 +171,9 @@ impl Router {
|
||||
) {
|
||||
*spot = Some((new_spot, new_pos.dist_along()));
|
||||
} else {
|
||||
if let Some((new_path_steps, new_spot, new_pos)) = path_to_free_parking_spot(
|
||||
self.path.current_step().as_lane(),
|
||||
vehicle,
|
||||
map,
|
||||
parking,
|
||||
) {
|
||||
if let Some((new_path_steps, new_spot, new_pos)) =
|
||||
path_to_free_parking_spot(current_lane, vehicle, map, parking)
|
||||
{
|
||||
*spot = Some((new_spot, new_pos.dist_along()));
|
||||
for step in new_path_steps {
|
||||
self.path.add(step, map);
|
||||
@ -238,6 +235,9 @@ fn path_to_free_parking_spot(
|
||||
|
||||
while !queue.is_empty() {
|
||||
let current = queue.pop_front().unwrap();
|
||||
// If the current lane has a spot open, we wouldn't be asking. This can happen if a spot
|
||||
// opens up on the 'start' lane, but behind the car.
|
||||
if current != start {
|
||||
if let Some((spot, pos)) =
|
||||
parking.get_first_free_spot(Position::new(current, Distance::ZERO), vehicle, map)
|
||||
{
|
||||
@ -256,6 +256,7 @@ fn path_to_free_parking_spot(
|
||||
current = turn.src;
|
||||
}
|
||||
}
|
||||
}
|
||||
for turn in map.get_legal_turns(current, vec![LaneType::Driving]) {
|
||||
if !backrefs.contains_key(&turn.id.dst) {
|
||||
backrefs.insert(turn.id.dst, turn.id);
|
||||
|
Loading…
Reference in New Issue
Block a user