mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-24 01:15:12 +03:00
Don't filter deadends
(You told me about nowhere, sounds like someplace I'd like to go)
This commit is contained in:
parent
c978affdd5
commit
966dd7955d
@ -52,7 +52,7 @@ impl FreehandFilters {
|
||||
}
|
||||
let road = app.map.get_r(*r);
|
||||
// Don't show error messages
|
||||
if road.oneway_for_driving().is_some() {
|
||||
if road.oneway_for_driving().is_some() || road.is_deadend(&app.map) {
|
||||
continue;
|
||||
}
|
||||
if let Some((pt, _)) = road.center_pts.intersection(&path) {
|
||||
|
@ -98,6 +98,9 @@ pub fn handle_world_outcome(
|
||||
if road.oneway_for_driving().is_some() {
|
||||
return EditOutcome::error(ctx, "A one-way street can't have a filter");
|
||||
}
|
||||
if road.is_deadend(&app.map) {
|
||||
return EditOutcome::error(ctx, "You can't filter a dead-end");
|
||||
}
|
||||
|
||||
app.session.modal_filters.before_edit();
|
||||
if app.session.modal_filters.roads.remove(&r).is_none() {
|
||||
|
@ -51,6 +51,9 @@ pub fn handle_world_outcome(
|
||||
if app.session.modal_filters.roads.contains_key(&r) {
|
||||
return EditOutcome::error(ctx, "A one-way street can't have a filter");
|
||||
}
|
||||
if app.map.get_r(r).is_deadend(&app.map) {
|
||||
return EditOutcome::error(ctx, "A dead-end street can't be one-way");
|
||||
}
|
||||
|
||||
let leftmost_dir = if app.map.get_config().driving_side == DrivingSide::Right {
|
||||
Direction::Back
|
||||
|
@ -615,6 +615,11 @@ impl Road {
|
||||
pub fn oneway_for_driving(&self) -> Option<Direction> {
|
||||
LaneSpec::oneway_for_driving(&self.lane_specs())
|
||||
}
|
||||
|
||||
/// Does either end of this road lead nowhere?
|
||||
pub fn is_deadend(&self, map: &Map) -> bool {
|
||||
map.get_i(self.src_i).is_deadend() || map.get_i(self.dst_i).is_deadend()
|
||||
}
|
||||
}
|
||||
|
||||
// TODO All of this is kind of deprecated? Some callers seem to really need to still handle lanes
|
||||
|
Loading…
Reference in New Issue
Block a user