Unfilter the custom waypoint targets.

There doesn't appear to be any reason for us to be poking at
implementation details here aside from changing the name from "unit" to
"building" for that case. Just iterate over the known strike targets.

Making this change uncovered some latent type errors.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2564.

(cherry picked from commit 5e7e5e2636)
This commit is contained in:
Dan Albert
2022-11-25 14:04:42 -08:00
parent b57e30a13c
commit 5f74fd81eb
3 changed files with 24 additions and 67 deletions

View File

@@ -7,7 +7,6 @@ from game.missiongenerator.frontlineconflictdescription import (
FrontLineConflictDescription,
)
from game.theater.controlpoint import ControlPointType
from game.theater.theatergroundobject import BuildingGroundObject, IadsGroundObject
from game.utils import Distance
from qt_ui.widgets.combos.QFilteredComboBox import QFilteredComboBox
@@ -81,66 +80,25 @@ class QPredefinedWaypointSelectionComboBox(QFilteredComboBox):
wpt.description = "Frontline"
i = add_model_item(i, model, wpt.pretty_name, wpt)
if self.include_targets:
for cp in self.game.theater.controlpoints:
if (self.include_enemy and not cp.captured) or (
self.include_friendly and cp.captured
):
for ground_object in cp.ground_objects:
if not ground_object.is_dead and isinstance(
ground_object, BuildingGroundObject
):
wpt = FlightWaypoint(
ground_object.waypoint_name,
FlightWaypointType.CUSTOM,
ground_object.position,
Distance.from_meters(0),
)
wpt.alt_type = "RADIO"
wpt.pretty_name = wpt.name
wpt.obj_name = ground_object.obj_name
wpt.targets.append(ground_object)
if cp.captured:
wpt.description = "Friendly Building"
else:
wpt.description = "Enemy Building"
i = add_model_item(i, model, wpt.pretty_name, wpt)
if self.include_units:
for cp in self.game.theater.controlpoints:
if (self.include_enemy and not cp.captured) or (
self.include_friendly and cp.captured
):
for ground_object in cp.ground_objects:
if not ground_object.is_dead and (
isinstance(ground_object, IadsGroundObject)
):
for g in ground_object.groups:
for j, u in enumerate(g.units):
wptname = (
"["
+ str(ground_object.obj_name)
+ "] : "
+ u.name
+ " #"
+ str(j)
)
wpt = FlightWaypoint(
wptname,
FlightWaypointType.CUSTOM,
u.position,
Distance.from_meters(0),
)
wpt.alt_type = "RADIO"
wpt.pretty_name = wptname
wpt.targets.append(u)
wpt.obj_name = ground_object.obj_name
wpt.waypoint_type = FlightWaypointType.CUSTOM
if cp.captured:
wpt.description = "Friendly unit: " + u.name
else:
wpt.description = "Enemy unit: " + u.name
i = add_model_item(i, model, wpt.pretty_name, wpt)
for tgo in self.game.theater.ground_objects:
for target_idx, target in enumerate(tgo.strike_targets):
wptname = f"[{tgo.obj_name}] : {target.name} #{target_idx}"
wpt = FlightWaypoint(
wptname,
FlightWaypointType.CUSTOM,
target.position,
Distance.from_meters(0),
)
wpt.alt_type = "RADIO"
wpt.pretty_name = wptname
wpt.targets.append(target)
wpt.obj_name = tgo.obj_name
wpt.waypoint_type = FlightWaypointType.CUSTOM
if tgo.is_friendly(to_player=True):
wpt.description = f"Friendly unit: {target.name}"
else:
wpt.description = f"Enemy unit: {target.name}"
i = add_model_item(i, model, wpt.pretty_name, wpt)
if self.include_airbases:
for cp in self.game.theater.controlpoints: