diff --git a/game/data/radar_db.py b/game/data/radar_db.py deleted file mode 100644 index a8bec9b4..00000000 --- a/game/data/radar_db.py +++ /dev/null @@ -1,72 +0,0 @@ -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 7675b256..29a7355b 100644 --- a/game/theater/theatergroundobject.py +++ b/game/theater/theatergroundobject.py @@ -10,7 +10,6 @@ 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: @@ -141,7 +140,15 @@ class TheaterGroundObject(MissionTarget): """Returns True if the ground object contains a unit with radar.""" for group in self.groups: for unit in group.units: - if db.unit_type_from_name(unit.type) in UNITS_WITH_RADAR: + 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: return True return False @@ -156,8 +163,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. + # 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, 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 3cd46bf9..1353bf1c 100644 --- a/qt_ui/widgets/combos/QSEADTargetSelectionComboBox.py +++ b/qt_ui/widgets/combos/QSEADTargetSelectionComboBox.py @@ -1,7 +1,6 @@ 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 @@ -45,21 +44,18 @@ class QSEADTargetSelectionComboBox(QFilteredComboBox): for g in cp.ground_objects: radars = [] - detection_range = 0 + max_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) - - 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) + detection_range = getattr(utype, "detection_range", 0) + if detection_range > 1000: + max_detection_range = max( + detection_range, max_detection_range + ) + radars.append(u) if hasattr(utype, "threat_range"): if utype.threat_range > threat_range: @@ -81,7 +77,7 @@ class QSEADTargetSelectionComboBox(QFilteredComboBox): tgt_info.radars = radars tgt_info.location = g tgt_info.threat_range = threat_range - tgt_info.detection_range = detection_range + tgt_info.detection_range = max_detection_range i = add_model_item(i, model, tgt_info) self.setModel(model)