Add some disabled validation that paths don't enter an access-restricted zone when they shouldn't.
I'm working on an overhaul to pathfinding and zones in another branch,
and need some more debugging tools. This one's ready to be checked in
now.
@@ -132,6 +132,9 @@ impl Path {
if false {
validate_restrictions(map, &steps);
}
+ if false {
+ validate_zones(map, &steps, &orig_req);
+ }
let mut path = Path {
steps: VecDeque::from(steps),
orig_req,
@@ -645,6 +648,33 @@ fn validate_restrictions(map: &Map, steps: &Vec<PathStep>) {
}
}
+fn validate_zones(map: &Map, steps: &Vec<PathStep>, req: &PathRequest) {
+ let z1 = map.get_parent(req.start.lane()).get_zone(map);
+ let z2 = map.get_parent(req.end.lane()).get_zone(map);
+
+ for step in steps {
+ if let PathStep::Turn(t) = step {
+ if map
+ .get_parent(t.src)
+ .access_restrictions
+ .allow_through_traffic
+ .contains(req.constraints)
+ && !map
+ .get_parent(t.dst)
+ .access_restrictions
+ .allow_through_traffic
+ .contains(req.constraints)
+ {
+ // Maybe it's fine
+ let into_zone = map.get_parent(t.dst).get_zone(map);
+ if into_zone != z1 && into_zone != z2 {
+ error!("{} causes illegal entrance into a zone at {}", req, t);
+ }
+ }
+ }
+ }
+}
+
/// Tuneable parameters for all types of routing.
// These will maybe become part of the PathRequest later, but that's an extremely invasive and
// space-expensive change right now.
