diff --git a/src/viewport.cpp b/src/viewport.cpp --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -1356,9 +1356,6 @@ static void ViewportAddKdtreeSigns(DrawP bool show_signs = HasBit(_display_opt, DO_SHOW_SIGNS) && !IsInvisibilitySet(TO_SIGNS); bool show_competitors = HasBit(_display_opt, DO_SHOW_COMPETITOR_SIGNS); - const BaseStation *st; - const Sign *si; - /* Collect all the items first and draw afterwards, to ensure layering */ std::vector stations; std::vector towns; @@ -1366,34 +1363,36 @@ static void ViewportAddKdtreeSigns(DrawP _viewport_sign_kdtree.FindContained(search_rect.left, search_rect.top, search_rect.right, search_rect.bottom, [&](const ViewportSignKdtreeItem & item) { switch (item.type) { - case ViewportSignKdtreeItem::VKI_STATION: + case ViewportSignKdtreeItem::VKI_STATION: { if (!show_stations) break; - st = BaseStation::Get(item.id.station); + const BaseStation *st = BaseStation::Get(item.id.station); /* Don't draw if station is owned by another company and competitor station names are hidden. Stations owned by none are never ignored. */ if (!show_competitors && _local_company != st->owner && st->owner != OWNER_NONE) break; stations.push_back(st); break; - - case ViewportSignKdtreeItem::VKI_WAYPOINT: + } + + case ViewportSignKdtreeItem::VKI_WAYPOINT: { if (!show_waypoints) break; - st = BaseStation::Get(item.id.station); + const BaseStation *st = BaseStation::Get(item.id.station); /* Don't draw if station is owned by another company and competitor station names are hidden. Stations owned by none are never ignored. */ if (!show_competitors && _local_company != st->owner && st->owner != OWNER_NONE) break; stations.push_back(st); break; + } case ViewportSignKdtreeItem::VKI_TOWN: if (!show_towns) break; towns.push_back(Town::Get(item.id.town)); break; - case ViewportSignKdtreeItem::VKI_SIGN: + case ViewportSignKdtreeItem::VKI_SIGN: { if (!show_signs) break; - si = Sign::Get(item.id.sign); + const Sign *si = Sign::Get(item.id.sign); /* Don't draw if sign is owned by another company and competitor signs should be hidden. * Note: It is intentional that also signs owned by OWNER_NONE are hidden. Bankrupt @@ -1402,6 +1401,7 @@ static void ViewportAddKdtreeSigns(DrawP signs.push_back(si); break; + } default: NOT_REACHED();