diff --git a/changelog.md b/changelog.md index 63025dfd..69d006d6 100644 --- a/changelog.md +++ b/changelog.md @@ -34,6 +34,7 @@ Saves from 5.x are not compatible with 6.0. * **[Mission Generation]** Fixed an issue where SEAD/DEAD/BAI flights fired all missiles / bombs against a single unit in a group instead of targeting the whole group. * **[Mission Generation]** Fixed adding additional mission types for a squadron causing error messages when the mission type is not supported by the aircraft type by default * **[Mission Generation]** AAA ground units now spawn correctly at the frontline +* **[Modding]** Loadouts with invalid weapons (typically new DCS weapons not yet available in Liberation) will be ignored rather than causing an error. * **[UI]** Fixed and issue where the liberation main exe was still running after application close. * **[UI]** Disable player slots for non-flyable aircraft. diff --git a/game/ato/loadouts.py b/game/ato/loadouts.py index 442be6b6..c08d16cc 100644 --- a/game/ato/loadouts.py +++ b/game/ato/loadouts.py @@ -1,6 +1,7 @@ from __future__ import annotations import datetime +import logging from collections.abc import Iterable from typing import Iterator, Mapping, Optional, TYPE_CHECKING, Type @@ -122,9 +123,19 @@ class Loadout: for payload in payloads.values(): name = payload["name"] pylons = payload["pylons"] + try: + pylon_assignments = { + p["num"]: Weapon.with_clsid(p["CLSID"]) for p in pylons.values() + } + except KeyError: + logging.exception( + "Ignoring %s loadout with invalid weapons: %s", aircraft.name, name + ) + continue + yield Loadout( name, - {p["num"]: Weapon.with_clsid(p["CLSID"]) for p in pylons.values()}, + pylon_assignments, date=None, ) @@ -189,11 +200,16 @@ class Loadout: dcs_unit_type.load_payloads() payload = dcs_unit_type.loadout_by_name(name) if payload is not None: - return Loadout( - name, - {i: Weapon.with_clsid(d["clsid"]) for i, d in payload}, - date=None, - ) + try: + pylons = {i: Weapon.with_clsid(d["clsid"]) for i, d in payload} + except KeyError: + logging.exception( + "Ignoring %s loadout with invalid weapons: %s", + dcs_unit_type.id, + name, + ) + continue + return Loadout(name, pylons, date=None) # TODO: Try group.load_task_default_loadout(loadout_for_task) return cls.empty_loadout()