solve the problem with bikes entering too short

This commit is contained in:
Dustin Carlino 2019-02-04 20:36:36 -08:00
parent 17a0b57644
commit 6b3a77c9ec
2 changed files with 9 additions and 0 deletions

View File

@ -524,6 +524,7 @@ impl Spawner {
));
}
// This might fail!
pub fn start_trip_using_bike(
&mut self,
at: Tick,
@ -542,6 +543,11 @@ impl Spawner {
let b = map.get_b(start_bldg);
let pos = b.front_path.sidewalk;
if pos.dist_along() < MAX_BIKE_LENGTH {
let lane_len = map.get_l(pos.lane()).length();
if lane_len < MAX_BIKE_LENGTH {
// Just give up
return;
}
SidewalkSpot::bike_rack(Position::new(pos.lane(), MAX_BIKE_LENGTH), map)
} else {
SidewalkSpot::bike_rack(pos, map)

View File

@ -442,6 +442,9 @@ impl WalkingSimState {
}
Action::StartPreparingBike => {
let p = self.peds.get_mut(&id).unwrap();
// Since we enter this state when we're "close enough" to the goal, make sure
// we actually snap to this exact goal.
p.dist_along = p.goal.sidewalk_pos.dist_along();
p.moving = false;
p.bike_parking = Some(BikeParkingState {
is_parking: false,