fix traffic signal editing, broken by the EditCmd refactor

This commit is contained in:
Dustin Carlino 2020-02-19 09:55:50 -08:00
parent a65ea991e5
commit 044eef2b43
2 changed files with 29 additions and 18 deletions

View File

@ -1072,7 +1072,11 @@ impl EditCmd {
recalculate_turns(dst_i, map, effects, timer);
true
}
EditCmd::ChangeIntersection { i, ref new, .. } => {
EditCmd::ChangeIntersection {
i,
ref new,
ref old,
} => {
if map.get_i_edit(*i) == new.clone() {
return false;
}
@ -1093,7 +1097,10 @@ impl EditCmd {
map.intersections[i.0].intersection_type = IntersectionType::Construction;
}
}
recalculate_turns(*i, map, effects, timer);
if old == &EditIntersection::Closed || new == &EditIntersection::Closed {
recalculate_turns(*i, map, effects, timer);
}
true
}
}

View File

@ -254,22 +254,26 @@ fn make_input_graph(
&route.stops[0],
)))
{
let driving_cost = bus_graph
.pathfind(
&PathRequest {
start: map.get_bs(*stop1).driving_pos,
end: map.get_bs(*stop2).driving_pos,
constraints: PathConstraints::Bus,
},
map,
)
.unwrap()
.1;
input_graph.add_edge(
nodes.get(Node::RideBus(*stop1)),
nodes.get(Node::RideBus(*stop2)),
driving_cost,
);
if let Some((_, driving_cost)) = bus_graph.pathfind(
&PathRequest {
start: map.get_bs(*stop1).driving_pos,
end: map.get_bs(*stop2).driving_pos,
constraints: PathConstraints::Bus,
},
map,
) {
input_graph.add_edge(
nodes.get(Node::RideBus(*stop1)),
nodes.get(Node::RideBus(*stop2)),
driving_cost,
);
} else {
panic!(
"No bus route from {} to {} now! Prevent this edit",
map.get_bs(*stop1).driving_pos,
map.get_bs(*stop2).driving_pos
);
}
}
}
}