diff --git a/game/data/weapons.py b/game/data/weapons.py index a0fec4ca..38133fe0 100644 --- a/game/data/weapons.py +++ b/game/data/weapons.py @@ -59,6 +59,9 @@ class Weapon: @classmethod def from_clsid(cls, clsid: str) -> Optional[Weapon]: data = weapon_ids.get(clsid) + if clsid == "": + # Special case for a "weapon" that isn't exposed by pydcs. + return Weapon(clsid, "Clean", 0) if data is None: return None return cls.from_pydcs(data) @@ -70,7 +73,15 @@ class Pylon: allowed: Set[Weapon] def can_equip(self, weapon: Weapon) -> bool: - return weapon in self.allowed + # TODO: Fix pydcs to support the "weapon". + # is a special case because pydcs doesn't know about that "weapon", so + # it's not compatible with *any* pylon. Just trust the loadout and try to equip + # it. + # + # A similar hack exists in QPylonEditor to forcibly add "Clean" to the list of + # valid configurations for that pylon if a loadout has been seen with that + # configuration. + return weapon in self.allowed or weapon.cls_id == "" def equip(self, group: FlyingGroup, weapon: Weapon) -> None: if not self.can_equip(weapon): diff --git a/gen/aircraft.py b/gen/aircraft.py index b1d35486..63e9ca1d 100644 --- a/gen/aircraft.py +++ b/gen/aircraft.py @@ -1243,7 +1243,6 @@ class AircraftConflictGenerator: # Note that the only effect that the DCS task type has is in determining which # waypoint actions the group may perform. group.task = CAS.name - # But we still use the SEAD *loadout*. self._setup_group(group, package, flight, dynamic_runways) self.configure_behavior( group, diff --git a/qt_ui/windows/mission/flight/payload/QPylonEditor.py b/qt_ui/windows/mission/flight/payload/QPylonEditor.py index 9470e2e0..3cb22c19 100644 --- a/qt_ui/windows/mission/flight/payload/QPylonEditor.py +++ b/qt_ui/windows/mission/flight/payload/QPylonEditor.py @@ -16,6 +16,7 @@ class QPylonEditor(QComboBox): self.flight = flight self.pylon = pylon self.game = game + self.has_added_clean_item = False current = self.flight.loadout.pylons.get(self.pylon.number) @@ -45,9 +46,20 @@ class QPylonEditor(QComboBox): weapon = loadout.pylons.get(self.pylon.number) if weapon is None: return None - # TODO: Handle removed pylons better. + # TODO: Fix pydcs to support the "weapon". + # These are not exported in the pydcs weapon map, which causes the pydcs pylon + # exporter to fail to include them in the supported list. Since they aren't + # known to be compatible (and we can't show them as compatible for *every* + # pylon, because they aren't), we won't have populated a "Clean" weapon when + # creating the selection list, so it's not selectable. To work around this, add + # the item to the list the first time it's encountered for the pylon. + # + # A similar hack exists in Pylon to support forcibly equipping this even when + # it's not known to be compatible. if weapon.cls_id == "": - return None + if not self.has_added_clean_item: + self.addItem("Clean", weapon) + self.has_added_clean_item = True return weapon def matching_weapon_name(self, loadout: Loadout) -> str: @@ -55,7 +67,7 @@ class QPylonEditor(QComboBox): loadout = loadout.degrade_for_date(self.flight.unit_type, self.game.date) weapon = self.weapon_from_loadout(loadout) if weapon is None: - return "" + return "None" return weapon.name def set_from(self, loadout: Loadout) -> None: