Save-compat changes to allow loading Liberation saves

May be incomplete, some discrepancies in naming may still exist, but at least Kerbo's campaign can be loaded.
This commit is contained in:
Raffson
2023-07-01 17:08:12 +02:00
parent aaaa9847b1
commit 3b745c43eb
5 changed files with 30 additions and 3 deletions

View File

@@ -17,6 +17,11 @@ _dcs_saved_game_folder: Optional[str] = None
# fmt: off
class DummyObject:
def __setstate__(self, state):
self.__dict__.update(state)
class MigrationUnpickler(pickle.Unpickler):
"""Custom unpickler to migrate campaign save-files for when components have been moved"""
def find_class(self, module: Any, name: str) -> Any:
@@ -52,6 +57,8 @@ class MigrationUnpickler(pickle.Unpickler):
return Thunderstorm
if name == "Hipico":
return dcs.terrain.falklands.airports.Hipico_Flying_Club
if name in ["SaveManager", "SaveGameBundle"]:
return DummyObject
return super().find_class(module, name)
# fmt: on