mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-24 17:37:22 +03:00
realizing an issue with old editor state
This commit is contained in:
parent
9c21dae3d9
commit
6f00507740
@ -73,6 +73,8 @@ impl ControlMap {
|
||||
}
|
||||
}
|
||||
|
||||
// General problem: TurnIDs change as code does. Serialized state is kinda tied to code version.
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct ModifiedTrafficSignal {
|
||||
pub cycles: Vec<CycleState>,
|
||||
|
@ -102,7 +102,7 @@ impl StopSign {
|
||||
map: &Map,
|
||||
control_map: &ControlMap,
|
||||
) -> bool {
|
||||
// TODO assert turn is in this intersection
|
||||
assert_eq!(map.get_t(turn).parent, self.id);
|
||||
|
||||
if self.accepted.contains_key(&car) {
|
||||
return true;
|
||||
@ -164,12 +164,14 @@ impl TrafficSignal {
|
||||
fn can_do_turn(
|
||||
&mut self,
|
||||
car: CarID,
|
||||
turn: TurnID,
|
||||
t: TurnID,
|
||||
time: Tick,
|
||||
map: &Map,
|
||||
control_map: &ControlMap,
|
||||
) -> bool {
|
||||
// TODO assert turn is in this intersection
|
||||
let turn = map.get_t(t);
|
||||
|
||||
assert_eq!(turn.parent, self.id);
|
||||
|
||||
if self.accepted.contains_key(&car) {
|
||||
return true;
|
||||
@ -178,15 +180,15 @@ impl TrafficSignal {
|
||||
let signal = &control_map.traffic_signals[&self.id];
|
||||
let (cycle, remaining_cycle_time) = signal.current_cycle_and_remaining_time(time.as_time());
|
||||
|
||||
if !cycle.contains(turn) {
|
||||
if !cycle.contains(t) {
|
||||
return false;
|
||||
}
|
||||
// How long will it take the car to cross the turn?
|
||||
let crossing_time = map.get_t(turn).length() / SPEED_LIMIT;
|
||||
let crossing_time = turn.length() / SPEED_LIMIT;
|
||||
// TODO account for TIMESTEP
|
||||
|
||||
if crossing_time < remaining_cycle_time {
|
||||
self.accepted.insert(car, turn);
|
||||
self.accepted.insert(car, t);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user