Clean up some of the trips state when abruptly deleting agents. #312

This commit is contained in:
Dustin Carlino 2020-10-21 12:32:14 -07:00
parent d98c5bc6bc
commit adcd0f65fe
2 changed files with 7 additions and 0 deletions

View File

@ -912,6 +912,7 @@ impl Sim {
Some(vehicle),
&mut ctx,
);
self.trips.trip_abruptly_cancelled(trip, AgentID::Car(car));
}
AgentID::Pedestrian(ped) => {
self.walking.delete_ped(ped, &mut ctx);
@ -922,6 +923,8 @@ impl Sim {
None,
&mut ctx,
);
self.trips
.trip_abruptly_cancelled(trip, AgentID::Pedestrian(ped));
}
AgentID::BusPassenger(_, _) => unreachable!(),
}

View File

@ -823,6 +823,10 @@ impl TripManager {
self.person_finished_trip(now, person, ctx);
}
pub fn trip_abruptly_cancelled(&mut self, trip: TripID, agent: AgentID) {
assert_eq!(self.active_trip_mode.remove(&agent), Some(trip));
}
pub fn active_agents(&self) -> Vec<AgentID> {
self.active_trip_mode.keys().cloned().collect()
}