mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Better save-compat w.r.t. changes in AC's yaml
This commit is contained in:
@@ -239,6 +239,16 @@ class AircraftType(UnitType[Type[FlyingType]]):
|
||||
list
|
||||
)
|
||||
|
||||
def __setstate__(self, state: dict[str, Any]) -> None:
|
||||
# Save compat: the `name` field has been renamed `variant_id`.
|
||||
if "name" in state:
|
||||
state["variant_id"] = state.pop("name")
|
||||
|
||||
# Update any existing models with new data on load.
|
||||
updated = AircraftType.named(state["variant_id"])
|
||||
updated.__dict__.update(state)
|
||||
self.__dict__.update(updated.__dict__)
|
||||
|
||||
def __post_init__(self) -> None:
|
||||
enrich = {}
|
||||
if FlightType.SEAD_SWEEP not in self.task_priorities:
|
||||
@@ -419,16 +429,6 @@ class AircraftType(UnitType[Type[FlyingType]]):
|
||||
def task_priority(self, task: FlightType) -> int:
|
||||
return self.task_priorities[task]
|
||||
|
||||
def __setstate__(self, state: dict[str, Any]) -> None:
|
||||
# Save compat: the `name` field has been renamed `variant_id`.
|
||||
if "name" in state:
|
||||
state["variant_id"] = state.pop("name")
|
||||
|
||||
# Update any existing models with new data on load.
|
||||
updated = AircraftType.named(state["variant_id"])
|
||||
state.update(updated.__dict__)
|
||||
self.__dict__.update(state)
|
||||
|
||||
@staticmethod
|
||||
def _migrator() -> Dict[str, str]:
|
||||
return {"F-15E Strike Eagle (AI)": "F-15E Strike Eagle"}
|
||||
|
||||
Reference in New Issue
Block a user