mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Don't allow carrier's path over land in UI
This commit is contained in:
parent
cf38113cde
commit
592b1a7833
@ -89,6 +89,15 @@ def set_destination(
|
||||
detail=f"Cannot move {cp} more than "
|
||||
f"{cp.max_move_distance.nautical_miles}nm.",
|
||||
)
|
||||
if (
|
||||
cp.is_fleet
|
||||
and game.theater.landmap
|
||||
and game.theater.landmap.land_inbetween(cp.position, point)
|
||||
):
|
||||
raise HTTPException(
|
||||
status.HTTP_400_BAD_REQUEST,
|
||||
detail=f"Cannot move {cp} over land.",
|
||||
)
|
||||
cp.target_position = point
|
||||
from .. import EventStream
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@ from dcs.drawing.polygon import FreeFormPolygon
|
||||
from dcs.mapping import Point
|
||||
from dcs.mission import Mission
|
||||
from dcs.terrain.terrain import Terrain
|
||||
from shapely import geometry
|
||||
from shapely import geometry, LineString
|
||||
from shapely.geometry import MultiPolygon, Polygon
|
||||
|
||||
|
||||
@ -32,6 +32,10 @@ class Landmap:
|
||||
def inclusion_zone_only(self) -> MultiPolygon:
|
||||
return self.inclusion_zones - self.exclusion_zones - self.sea_zones
|
||||
|
||||
def land_inbetween(self, a: Point, b: Point) -> bool:
|
||||
line = LineString([[a.x, a.y], [b.x, b.y]])
|
||||
return self.inclusion_zones.intersects(line)
|
||||
|
||||
|
||||
def load_landmap(filename: Path) -> Optional[Landmap]:
|
||||
try:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user