Fix bug introduced in Don't
cache intersection_type in DrawIntersection; it changes when converting
stop signs<->traffic signals<->closed for construction.
@@ -15,7 +15,6 @@ use std::cell::RefCell;
pub struct DrawIntersection {
pub id: IntersectionID,
- intersection_type: IntersectionType,
zorder: isize,
draw_default: RefCell<Option<Drawable>>,
@@ -26,7 +25,6 @@ impl DrawIntersection {
pub fn new(i: &Intersection, map: &Map) -> DrawIntersection {
DrawIntersection {
id: i.id,
- intersection_type: i.intersection_type,
zorder: i.get_zorder(map),
draw_default: RefCell::new(None),
draw_traffic_signal: RefCell::new(None),
@@ -139,17 +137,16 @@ impl Renderable for DrawIntersection {
}
g.redraw(draw.as_ref().unwrap());
- if self.intersection_type == IntersectionType::TrafficSignal
- && !opts.suppress_traffic_signal_details.contains(&self.id)
- {
- let signal = app.primary.map.get_traffic_signal(self.id);
+ if let Some(signal) = app.primary.map.maybe_get_traffic_signal(self.id) {
+ if !opts.suppress_traffic_signal_details.contains(&self.id) {
let mut maybe_redraw = self.draw_traffic_signal.borrow_mut();
let recalc = maybe_redraw
.as_ref()
.map(|(t, _)| *t != app.primary.sim.time())
.unwrap_or(true);
if recalc {
- let (idx, remaining) = app.primary.sim.current_phase_and_remaining_time(self.id);
+ let (idx, remaining) =
+ app.primary.sim.current_phase_and_remaining_time(self.id);
let mut batch = GeomBatch::new();
draw_signal_phase(
g.prerender,
@@ -174,6 +171,7 @@ impl Renderable for DrawIntersection {
g.redraw(batch);
}
}
+ }
fn get_outline(&self, map: &Map) -> Polygon {
let poly = &map.get_i(self.id).polygon;
