From c4d08fa7b79a1ad51d980ab592f3fae50b5b68c7 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Thu, 12 Nov 2020 23:52:24 -0800 Subject: [PATCH] Fix handling of non-AA units in AA groups. Some units in pydcs have detection_range and threat_range defined, but explicitly set to None. --- qt_ui/widgets/map/QLiberationMap.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/qt_ui/widgets/map/QLiberationMap.py b/qt_ui/widgets/map/QLiberationMap.py index 5834ba6f..a24b609b 100644 --- a/qt_ui/widgets/map/QLiberationMap.py +++ b/qt_ui/widgets/map/QLiberationMap.py @@ -176,10 +176,17 @@ class QLiberationMap(QGraphicsView): if unit is None: logging.error(f"Unknown unit type {u.type}") continue - detection_range = max(detection_range, - getattr(unit, "detection_range")) - threat_range = max(threat_range, - getattr(unit, "threat_range")) + + # Some units in pydcs have detection_range and threat_range + # defined, but explicitly set to None. + unit_detection_range = getattr(unit, "detection_range", None) + if unit_detection_range is not None: + detection_range = max(detection_range, unit_detection_range) + + unit_threat_range = getattr(unit, "threat_range", None) + if unit_threat_range is not None: + threat_range = max(threat_range, unit_threat_range) + return detection_range, threat_range def reload_scene(self):