prevent illegal trip from happening, fix bike_to_sidewalk

This commit is contained in:
Dustin Carlino 2019-02-27 08:57:58 -08:00
parent ba9a545dcf
commit 874b3be519
2 changed files with 17 additions and 3 deletions

View File

@ -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(_, _, _, _, _) => {}
};

View File

@ -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)