cancel turn requests when deleting a car forcibly

This commit is contained in:
Dustin Carlino 2019-09-08 15:21:15 -07:00
parent 105f526e9e
commit fb3e4e5177
2 changed files with 9 additions and 0 deletions

View File

@ -510,6 +510,9 @@ impl DrivingSimState {
let queue = self.queues.get_mut(&car.router.head()).unwrap();
queue.reserved_length += car.vehicle.length + FOLLOWING_DISTANCE;
}
if let Some(Traversable::Turn(t)) = car.router.maybe_next() {
intersections.cancel_request(AgentID::Car(c), t);
}
self.delete_car(&mut car, dists, idx, now, map, scheduler, intersections);
// delete_car cancels UpdateLaggyHead

View File

@ -88,6 +88,12 @@ impl IntersectionSimState {
}
}
// For deleting cars
pub fn cancel_request(&mut self, agent: AgentID, turn: TurnID) {
let state = self.state.get_mut(&turn.parent).unwrap();
state.waiting.remove(&Request { agent, turn });
}
pub fn space_freed(&mut self, now: Duration, i: IntersectionID, scheduler: &mut Scheduler) {
let state = self.state.get_mut(&i).unwrap();