mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Force dumping debug info on recreate.
We need a way to debug successful solvers that's still targeting to a specific flight. This will do for now.
This commit is contained in:
parent
d96f7a267c
commit
97ee6ba19f
@ -313,8 +313,8 @@ class Flight(SidcDescribable, RadioFrequencyContainer, TacanContainer):
|
|||||||
if pilot is not None:
|
if pilot is not None:
|
||||||
results.kill_pilot(self, pilot)
|
results.kill_pilot(self, pilot)
|
||||||
|
|
||||||
def recreate_flight_plan(self) -> None:
|
def recreate_flight_plan(self, dump_debug_info: bool = False) -> None:
|
||||||
self._flight_plan_builder.regenerate()
|
self._flight_plan_builder.regenerate(dump_debug_info)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def clone_flight(flight: Flight) -> Flight:
|
def clone_flight(flight: Flight) -> Flight:
|
||||||
|
|||||||
@ -32,9 +32,9 @@ class IBuilder(ABC, Generic[FlightPlanT, LayoutT]):
|
|||||||
assert self._flight_plan is not None
|
assert self._flight_plan is not None
|
||||||
return self._flight_plan
|
return self._flight_plan
|
||||||
|
|
||||||
def regenerate(self) -> None:
|
def regenerate(self, dump_debug_info: bool = False) -> None:
|
||||||
try:
|
try:
|
||||||
self._generate_package_waypoints_if_needed()
|
self._generate_package_waypoints_if_needed(dump_debug_info)
|
||||||
self._flight_plan = self.build()
|
self._flight_plan = self.build()
|
||||||
except NavMeshError as ex:
|
except NavMeshError as ex:
|
||||||
color = "blue" if self.flight.squadron.player else "red"
|
color = "blue" if self.flight.squadron.player else "red"
|
||||||
@ -43,14 +43,15 @@ class IBuilder(ABC, Generic[FlightPlanT, LayoutT]):
|
|||||||
f"{self.flight.departure} to {self.package.target}"
|
f"{self.flight.departure} to {self.package.target}"
|
||||||
) from ex
|
) from ex
|
||||||
|
|
||||||
def _generate_package_waypoints_if_needed(self) -> None:
|
def _generate_package_waypoints_if_needed(self, dump_debug_info: bool) -> None:
|
||||||
# Package waypoints are only valid for offensive missions. Skip this if the
|
# Package waypoints are only valid for offensive missions. Skip this if the
|
||||||
# target is friendly.
|
# target is friendly.
|
||||||
if self.package.waypoints is None and not self.package.target.is_friendly(
|
if self.package.target.is_friendly(self.is_player):
|
||||||
self.is_player
|
return
|
||||||
):
|
|
||||||
|
if self.package.waypoints is None or dump_debug_info:
|
||||||
self.package.waypoints = PackageWaypoints.create(
|
self.package.waypoints = PackageWaypoints.create(
|
||||||
self.package, self.coalition
|
self.package, self.coalition, dump_debug_info
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|||||||
@ -10,6 +10,7 @@ from game.ato.flightplans.waypointbuilder import WaypointBuilder
|
|||||||
from game.flightplan import JoinZoneGeometry
|
from game.flightplan import JoinZoneGeometry
|
||||||
from game.flightplan.ipsolver import IpSolver
|
from game.flightplan.ipsolver import IpSolver
|
||||||
from game.flightplan.refuelzonegeometry import RefuelZoneGeometry
|
from game.flightplan.refuelzonegeometry import RefuelZoneGeometry
|
||||||
|
from game.persistence.paths import liberation_user_dir
|
||||||
from game.utils import dcs_to_shapely_point
|
from game.utils import dcs_to_shapely_point
|
||||||
from game.utils import nautical_miles
|
from game.utils import nautical_miles
|
||||||
|
|
||||||
@ -27,16 +28,27 @@ class PackageWaypoints:
|
|||||||
refuel: Point
|
refuel: Point
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create(package: Package, coalition: Coalition) -> PackageWaypoints:
|
def create(
|
||||||
|
package: Package, coalition: Coalition, dump_debug_info: bool
|
||||||
|
) -> PackageWaypoints:
|
||||||
origin = package.departure_closest_to_target()
|
origin = package.departure_closest_to_target()
|
||||||
|
|
||||||
|
waypoint_debug_directory = liberation_user_dir() / "Debug/Waypoints"
|
||||||
|
|
||||||
# Start by picking the best IP for the attack.
|
# Start by picking the best IP for the attack.
|
||||||
ingress_point_shapely = IpSolver(
|
ip_solver = IpSolver(
|
||||||
dcs_to_shapely_point(origin.position),
|
dcs_to_shapely_point(origin.position),
|
||||||
dcs_to_shapely_point(package.target.position),
|
dcs_to_shapely_point(package.target.position),
|
||||||
coalition.doctrine,
|
coalition.doctrine,
|
||||||
coalition.opponent.threat_zone.all,
|
coalition.opponent.threat_zone.all,
|
||||||
).solve()
|
)
|
||||||
|
ip_solver.set_debug_properties(
|
||||||
|
waypoint_debug_directory / "IP", coalition.game.theater.terrain
|
||||||
|
)
|
||||||
|
ingress_point_shapely = ip_solver.solve()
|
||||||
|
if dump_debug_info:
|
||||||
|
ip_solver.dump_debug_info()
|
||||||
|
|
||||||
ingress_point = origin.position.new_in_same_map(
|
ingress_point = origin.position.new_in_same_map(
|
||||||
ingress_point_shapely.x, ingress_point_shapely.y
|
ingress_point_shapely.x, ingress_point_shapely.y
|
||||||
)
|
)
|
||||||
|
|||||||
@ -219,7 +219,7 @@ class QFlightWaypointTab(QFrame):
|
|||||||
if result == QMessageBox.Yes:
|
if result == QMessageBox.Yes:
|
||||||
self.flight.set_flight_type(task)
|
self.flight.set_flight_type(task)
|
||||||
try:
|
try:
|
||||||
self.flight.recreate_flight_plan()
|
self.flight.recreate_flight_plan(dump_debug_info=True)
|
||||||
except PlanningError as ex:
|
except PlanningError as ex:
|
||||||
self.flight.set_flight_type(original_task)
|
self.flight.set_flight_type(original_task)
|
||||||
logging.exception("Could not recreate flight")
|
logging.exception("Could not recreate flight")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user