Show the real front line bounds on the map.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/1067.
This commit is contained in:
Dan Albert 2023-08-10 20:45:28 -07:00 committed by Raffson
parent 03d8448def
commit 5ca344e87b
No known key found for this signature in database
GPG Key ID: B0402B2C9B764D99
4 changed files with 24 additions and 18 deletions

View File

@ -222,6 +222,7 @@ BAI/ANTISHIP/DEAD/STRIKE/BARCAP/CAS/OCA/AIR-ASSAULT (main) missions
* **[UI]** An error will be displayed when invalid fast-forward options are selected rather than beginning a never ending simulation.
* **[UI]** Added cheats for instantly repairing and destroying runways.
* **[UI]** Improved usability of the flight properties UI. It now shows human-readable names and uses more appropriate UI elements.
* **[UI]** The map now shows the real front line bounds.
## Fixes

View File

@ -11,8 +11,7 @@ from game.server.flights.models import FlightJs
from game.server.frontlines.models import FrontLineJs
from game.server.iadsnetwork.models import IadsConnectionJs
from game.server.leaflet import LeafletPoint
from game.server.mapzones.models import ThreatZonesJs
from game.server.mapzones.models import UnculledZoneJs
from game.server.mapzones.models import ThreatZonesJs, UnculledZoneJs
from game.server.navmesh.models import NavMeshJs
from game.server.supplyroutes.models import SupplyRouteJs
from game.server.tgos.models import TgoJs
@ -59,6 +58,7 @@ class GameUpdateEventsJs(BaseModel):
updated_unculled_zones = []
updated_iads = []
updated_supply_routes = []
updated_front_lines = []
if game is not None:
new_combats = [
FrozenCombatJs.for_combat(c, game.theater) for c in events.new_combats
@ -82,6 +82,10 @@ class GameUpdateEventsJs(BaseModel):
updated_supply_routes = SupplyRouteJs.all_in_game(game)
for route in updated_supply_routes:
route.points = []
updated_front_lines = [
FrontLineJs.for_front_line(game.theater, f)
for f in events.updated_front_lines
]
return GameUpdateEventsJs(
updated_flight_positions={
@ -103,9 +107,7 @@ class GameUpdateEventsJs(BaseModel):
deleted_flights=events.deleted_flights,
selected_flight=events.selected_flight,
deselected_flight=events.deselected_flight,
updated_front_lines=[
FrontLineJs.for_front_line(f) for f in events.updated_front_lines
],
updated_front_lines=updated_front_lines,
deleted_front_lines=events.deleted_front_lines,
updated_tgos=[TgoJs.for_tgo(tgo) for tgo in events.updated_tgos],
updated_control_points=[

View File

@ -5,12 +5,14 @@ from uuid import UUID
from pydantic import BaseModel
from game.missiongenerator.frontlineconflictdescription import (
FrontLineConflictDescription,
)
from game.server.leaflet import LeafletPoint
from game.utils import nautical_miles
if TYPE_CHECKING:
from game import Game
from game.theater import FrontLine
from game.theater import FrontLine, ConflictTheater
class FrontLineJs(BaseModel):
@ -21,17 +23,16 @@ class FrontLineJs(BaseModel):
title = "FrontLine"
@staticmethod
def for_front_line(front_line: FrontLine) -> FrontLineJs:
a = front_line.position.point_from_heading(
front_line.blue_forward_heading.right.degrees,
nautical_miles(2).meters,
def for_front_line(theater: ConflictTheater, front_line: FrontLine) -> FrontLineJs:
bounds = FrontLineConflictDescription.frontline_bounds(front_line, theater)
return FrontLineJs(
id=front_line.id,
extents=[bounds.left_position.latlng(), bounds.right_position.latlng()],
)
b = front_line.position.point_from_heading(
front_line.blue_forward_heading.left.degrees,
nautical_miles(2).meters,
)
return FrontLineJs(id=front_line.id, extents=[a.latlng(), b.latlng()])
@staticmethod
def all_in_game(game: Game) -> list[FrontLineJs]:
return [FrontLineJs.for_front_line(f) for f in game.theater.conflicts()]
return [
FrontLineJs.for_front_line(game.theater, f)
for f in game.theater.conflicts()
]

View File

@ -20,4 +20,6 @@ def list_front_lines(game: Game = Depends(GameContext.require)) -> list[FrontLin
def get_front_line(
front_line_id: UUID, game: Game = Depends(GameContext.require)
) -> FrontLineJs:
return FrontLineJs.for_front_line(game.db.front_lines.get(front_line_id))
return FrontLineJs.for_front_line(
game.theater, game.db.front_lines.get(front_line_id)
)