From 0e01aaf9cd8b8bec7125c302252cf294f42a987f Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Fri, 20 Oct 2023 13:09:52 -0700 Subject: [PATCH] Filter out empty string CLSIDs. There's more detail in the comment, but this fixes an issue where some Mosquito loadouts could not be loaded. Might fix https://github.com/dcs-liberation/dcs_liberation/issues/3171. There aren't enough instructions in the bug for me to be sure, but it sounds like a similar problem, although I came across it with bombs rather than rockets. --- changelog.md | 1 + game/ato/loadouts.py | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index c7d962e7..c4d11d8f 100644 --- a/changelog.md +++ b/changelog.md @@ -29,6 +29,7 @@ Saves from 8.x are not compatible with 9.0.0. * **[Data]** Allow CH-47D, CH-53E and UH-60A to operate from carriers and LHAs. * **[Data]** Added the F-15E's LANTIRN to the list of known targeting pods. Player F-15E flight with TGPs will now be assigned laser codes. * **[Flight Planning]** Patrolling flight plans (CAS, CAP, refueling, etc) now handle TOT offsets. +* **[Loadouts]** Fixed error when loading certain DCS loadouts which contained an empty pylon (notably the Mosquito). * **[Mission Generation]** Restored previous AI behavior for anti-ship missions. A DCS update caused only a single aircraft in a flight to attack. The full flight will now attack like they used to. * **[Mission Generation]** Fix generation of OCA Runway missions to allow LGBs to be used. * **[Mission Generation]** Fixed AI flights flying far too slowly toward NAV points. diff --git a/game/ato/loadouts.py b/game/ato/loadouts.py index 48347acc..27094171 100644 --- a/game/ato/loadouts.py +++ b/game/ato/loadouts.py @@ -134,7 +134,17 @@ class Loadout: pylons = payload["pylons"] try: pylon_assignments = { - p["num"]: Weapon.with_clsid(p["CLSID"]) for p in pylons.values() + p["num"]: Weapon.with_clsid(p["CLSID"]) + for p in pylons.values() + # When unloading incompatible pylons (for example, some of the + # Mosquito's pylons cannot be loaded when other pylons are carrying + # rockets), DCS sometimes equips the empty string rather than + # unsetting the pylon. An unset pylon and the empty string appear to + # have identical behavior, and it's annoying to deal with weapons + # that pydcs doesn't know about, so just clear those pylons rather + # than explicitly handling "". + # https://github.com/dcs-liberation/dcs_liberation/issues/3171 + if p["CLSID"] != "" } except KeyError: logging.exception(