From d23b1fbb2c23ddff5b27239c7299b00b577af5e7 Mon Sep 17 00:00:00 2001 From: RndName Date: Sun, 20 Mar 2022 19:49:58 +0100 Subject: [PATCH] Temporary Workaround for weapon save compat Adds a temporary workaround for save game loading when weapon data got removed and can not be updated anymore. This can lead to some unexpected behaviour especially when generating the next turn miz as pydcs will most likely crash. This could be solved by just changing the loadout (not tested yet) --- game/data/weapons.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/game/data/weapons.py b/game/data/weapons.py index 8e7c86c9..2fa20374 100644 --- a/game/data/weapons.py +++ b/game/data/weapons.py @@ -52,8 +52,13 @@ class Weapon: def __setstate__(self, state: dict[str, Any]) -> None: # Update any existing models with new data on load. - updated = Weapon.with_clsid(state["clsid"]) - state.update(updated.__dict__) + try: + updated = Weapon.with_clsid(state["clsid"]) + state.update(updated.__dict__) + except KeyError: + logging.exception( + f'CLSID {state["clsid"]} is not available anymore. This could potentially lead to some unexpected results when generating the next turn miz. To solve this issue it is recommended to update the loadout of all affected flights.' + ) self.__dict__.update(state) @classmethod