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

View File

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