diff --git a/game/data/radar_db.py b/game/data/radar_db.py new file mode 100644 index 00000000..a8bec9b4 --- /dev/null +++ b/game/data/radar_db.py @@ -0,0 +1,72 @@ +from dcs.ships import ( + Battlecruiser_1144_2_Pyotr_Velikiy, + Cruiser_1164_Moskva, + CVN_70_Carl_Vinson, + CVN_71_Theodore_Roosevelt, + CVN_72_Abraham_Lincoln, + CVN_73_George_Washington, + CVN_74_John_C__Stennis, + CV_1143_5_Admiral_Kuznetsov, + CV_1143_5_Admiral_Kuznetsov_2017, + Frigate_11540_Neustrashimy, + Corvette_1124_4_Grisha, + Frigate_1135M_Rezky, + Corvette_1241_1_Molniya, + LHA_1_Tarawa, + FFG_Oliver_Hazzard_Perry, + CG_Ticonderoga, + Type_052B_Destroyer, + Type_052C_Destroyer, + Type_054A_Frigate, + DDG_Arleigh_Burke_IIa, +) +from dcs.vehicles import AirDefence + +UNITS_WITH_RADAR = [ + # Radars + AirDefence.SAM_SA_15_Tor_Gauntlet, + AirDefence.SAM_SA_11_Buk_Gadfly_C2, + AirDefence.SAM_Patriot_CR__AMG_AN_MRC_137, + AirDefence.SAM_Patriot_ECS, + AirDefence.SPAAA_Gepard, + AirDefence.SPAAA_Vulcan_M163, + AirDefence.SPAAA_ZSU_23_4_Shilka_Gun_Dish, + AirDefence.EWR_1L13, + AirDefence.SAM_SA_6_Kub_Straight_Flush_STR, + AirDefence.SAM_SA_10_S_300_Grumble_Flap_Lid_TR, + AirDefence.SAM_SA_10_S_300_Grumble_Clam_Shell_SR, + AirDefence.EWR_55G6, + AirDefence.SAM_SA_10_S_300_Grumble_Big_Bird_SR, + AirDefence.SAM_SA_11_Buk_Gadfly_Snow_Drift_SR, + AirDefence.MCC_SR_Sborka_Dog_Ear_SR, + AirDefence.SAM_Hawk_TR__AN_MPQ_46, + AirDefence.SAM_Hawk_SR__AN_MPQ_50, + AirDefence.SAM_Patriot_STR, + AirDefence.SAM_Hawk_CWAR_AN_MPQ_55, + AirDefence.SAM_P19_Flat_Face_SR__SA_2_3, + AirDefence.SAM_Roland_EWR, + AirDefence.SAM_SA_3_S_125_Low_Blow_TR, + AirDefence.SAM_SA_2_S_75_Fan_Song_TR, + AirDefence.HQ_7_Self_Propelled_STR, + # Ships + CVN_70_Carl_Vinson, + FFG_Oliver_Hazzard_Perry, + CG_Ticonderoga, + Corvette_1124_4_Grisha, + CV_1143_5_Admiral_Kuznetsov, + Corvette_1241_1_Molniya, + Cruiser_1164_Moskva, + Frigate_11540_Neustrashimy, + Battlecruiser_1144_2_Pyotr_Velikiy, + Frigate_1135M_Rezky, + CV_1143_5_Admiral_Kuznetsov_2017, + CVN_74_John_C__Stennis, + CVN_71_Theodore_Roosevelt, + CVN_72_Abraham_Lincoln, + CVN_73_George_Washington, + DDG_Arleigh_Burke_IIa, + LHA_1_Tarawa, + Type_052B_Destroyer, + Type_054A_Frigate, + Type_052C_Destroyer, +] diff --git a/game/theater/theatergroundobject.py b/game/theater/theatergroundobject.py index 29a7355b..7675b256 100644 --- a/game/theater/theatergroundobject.py +++ b/game/theater/theatergroundobject.py @@ -10,6 +10,7 @@ from dcs.unit import Unit from dcs.unitgroup import Group from .. import db +from ..data.radar_db import UNITS_WITH_RADAR from ..utils import Distance, meters if TYPE_CHECKING: @@ -140,15 +141,7 @@ class TheaterGroundObject(MissionTarget): """Returns True if the ground object contains a unit with radar.""" for group in self.groups: for unit in group.units: - unit_type = db.unit_type_from_name(unit.type) - if unit_type is None: - logging.error(f"Unknown unit type {unit.type}") - continue - - # Some units in pydcs have detection_range/threat_range defined, but - # explicitly set to None. Others do not define it at all. - unit_range = getattr(unit_type, "detection_range", None) - if unit_range is not None: + if db.unit_type_from_name(unit.type) in UNITS_WITH_RADAR: return True return False @@ -163,8 +156,8 @@ class TheaterGroundObject(MissionTarget): logging.error(f"Unknown unit type {u.type}") continue - # Some units in pydcs have detection_range/threat_range defined, but - # explicitly set to None. Others do not define it at all. + # Some units in pydcs have detection_range/threat_range defined, + # but explicitly set to None. unit_range = getattr(unit, range_type, None) if unit_range is not None: max_range = max(max_range, meters(unit_range)) diff --git a/qt_ui/widgets/combos/QSEADTargetSelectionComboBox.py b/qt_ui/widgets/combos/QSEADTargetSelectionComboBox.py index 1353bf1c..3cd46bf9 100644 --- a/qt_ui/widgets/combos/QSEADTargetSelectionComboBox.py +++ b/qt_ui/widgets/combos/QSEADTargetSelectionComboBox.py @@ -1,6 +1,7 @@ from PySide2.QtGui import QStandardItem, QStandardItemModel from game import Game +from game.data.radar_db import UNITS_WITH_RADAR from gen import db from qt_ui.widgets.combos.QFilteredComboBox import QFilteredComboBox @@ -44,18 +45,21 @@ class QSEADTargetSelectionComboBox(QFilteredComboBox): for g in cp.ground_objects: radars = [] - max_detection_range = 0 + detection_range = 0 threat_range = 0 if g.dcs_identifier == "AA": for group in g.groups: for u in group.units: utype = db.unit_type_from_name(u.type) - detection_range = getattr(utype, "detection_range", 0) - if detection_range > 1000: - max_detection_range = max( - detection_range, max_detection_range - ) - radars.append(u) + + if utype in UNITS_WITH_RADAR: + if ( + hasattr(utype, "detection_range") + and utype.detection_range > 1000 + ): + if utype.detection_range > detection_range: + detection_range = utype.detection_range + radars.append(u) if hasattr(utype, "threat_range"): if utype.threat_range > threat_range: @@ -77,7 +81,7 @@ class QSEADTargetSelectionComboBox(QFilteredComboBox): tgt_info.radars = radars tgt_info.location = g tgt_info.threat_range = threat_range - tgt_info.detection_range = max_detection_range + tgt_info.detection_range = detection_range i = add_model_item(i, model, tgt_info) self.setModel(model)