From 84c4b992e0779440d27a38b8b3791fcb5a4e9c2d Mon Sep 17 00:00:00 2001 From: Raffson Date: Sat, 9 Nov 2024 14:49:38 +0100 Subject: [PATCH] Improve AGL to AMSL transition for naval waypoints Some maps have inaccurate bounds for sea-zones, thus waypoints that end up being too close to the shore may keep using AGL which could still lead to trouble. Adding a condition to check whether a point is "not on land" will likely fix this issue for maps that have gaps between sea-zones and inclusion-zones around the shoreline... --- .../aircraft/waypoints/pydcswaypointbuilder.py | 8 +++++--- game/theater/conflicttheater.py | 9 +++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/game/missiongenerator/aircraft/waypoints/pydcswaypointbuilder.py b/game/missiongenerator/aircraft/waypoints/pydcswaypointbuilder.py index 045cf049..9ba90ad1 100644 --- a/game/missiongenerator/aircraft/waypoints/pydcswaypointbuilder.py +++ b/game/missiongenerator/aircraft/waypoints/pydcswaypointbuilder.py @@ -85,9 +85,11 @@ class PydcsWaypointBuilder: return waypoint def switch_to_baro_if_in_sea(self, waypoint: MovingPoint) -> None: - if ( - waypoint.alt_type == "RADIO" - and self.flight.coalition.game.theater.is_in_sea(waypoint.position) + if waypoint.alt_type == "RADIO" and ( + self.flight.coalition.game.theater.is_in_sea(waypoint.position) + or not self.flight.coalition.game.theater.is_on_land( + waypoint.position, ignore_exclusion=True + ) ): waypoint.alt_type = "BARO" diff --git a/game/theater/conflicttheater.py b/game/theater/conflicttheater.py index 875a2659..98ed275c 100644 --- a/game/theater/conflicttheater.py +++ b/game/theater/conflicttheater.py @@ -75,7 +75,7 @@ class ConflictTheater: return False - def is_on_land(self, point: Point) -> bool: + def is_on_land(self, point: Point, ignore_exclusion: bool = False) -> bool: if not self.landmap: return True @@ -86,9 +86,10 @@ class ConflictTheater: if not is_point_included: return False - for exclusion_zone in self.landmap.exclusion_zones.geoms: - if poly_contains(point.x, point.y, exclusion_zone): - return False + if not ignore_exclusion: + for exclusion_zone in self.landmap.exclusion_zones.geoms: + if poly_contains(point.x, point.y, exclusion_zone): + return False return True