From 6b3a77c9ec76a20e3409a9f2117f985225903937 Mon Sep 17 00:00:00 2001 From: Dustin Carlino Date: Mon, 4 Feb 2019 20:36:36 -0800 Subject: [PATCH] solve the problem with bikes entering too short --- sim/src/spawn.rs | 6 ++++++ sim/src/walking.rs | 3 +++ 2 files changed, 9 insertions(+) diff --git a/sim/src/spawn.rs b/sim/src/spawn.rs index 0aa9ebc059..d4b9b3a847 100644 --- a/sim/src/spawn.rs +++ b/sim/src/spawn.rs @@ -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) diff --git a/sim/src/walking.rs b/sim/src/walking.rs index c637acf203..4c863d98fc 100644 --- a/sim/src/walking.rs +++ b/sim/src/walking.rs @@ -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,