mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-24 09:24:26 +03:00
prevent illegal trip from happening, fix bike_to_sidewalk
This commit is contained in:
parent
ba9a545dcf
commit
874b3be519
@ -83,13 +83,27 @@ impl TripSpawner {
|
||||
self.parked_cars_claimed.insert(car_id);
|
||||
}
|
||||
TripSpec::JustWalking(_, _) => {}
|
||||
TripSpec::UsingBike(start, _, _) => {
|
||||
TripSpec::UsingBike(start, _, goal) => {
|
||||
if SidewalkSpot::bike_rack(start.sidewalk_pos.lane(), map).is_none() {
|
||||
panic!(
|
||||
"Can't start biking from {}; no biking or driving lane nearby?",
|
||||
start.sidewalk_pos.lane()
|
||||
);
|
||||
}
|
||||
if let DrivingGoal::ParkNear(_) = goal {
|
||||
let last_lane = goal.goal_pos(map).lane();
|
||||
// If bike_to_sidewalk works, then SidewalkSpot::bike_rack should too.
|
||||
if map
|
||||
.get_parent(last_lane)
|
||||
.bike_to_sidewalk(last_lane)
|
||||
.is_none()
|
||||
{
|
||||
panic!(
|
||||
"Can't fulfill {:?} for a bike trip; no sidewalk near {}",
|
||||
goal, last_lane
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
TripSpec::UsingTransit(_, _, _, _, _) => {}
|
||||
};
|
||||
|
@ -161,12 +161,12 @@ impl Road {
|
||||
// TODO Crossing bus lanes means higher layers of sim should know to block these off
|
||||
let (fwds, idx) = self.dir_and_offset(bike);
|
||||
if fwds {
|
||||
self.children_forwards[0..idx]
|
||||
self.children_forwards[idx..]
|
||||
.iter()
|
||||
.find(|(_, lt)| *lt == LaneType::Sidewalk)
|
||||
.map(|(id, _)| *id)
|
||||
} else {
|
||||
self.children_backwards[0..idx]
|
||||
self.children_backwards[idx..]
|
||||
.iter()
|
||||
.find(|(_, lt)| *lt == LaneType::Sidewalk)
|
||||
.map(|(id, _)| *id)
|
||||
|
Loading…
Reference in New Issue
Block a user