Drop save compat hacks.

The CAS flight plan tweaks break save compat in a way that's not as easy
to fix. Accept it and drop the existing hacks since they won't be useful
any more.
This commit is contained in:
Dan Albert 2023-08-10 00:33:38 -07:00
parent cb3bf56d84
commit 3f0b565b82
6 changed files with 1 additions and 40 deletions

View File

@ -12,7 +12,6 @@ from .flightmembers import FlightMembers
from .flightroster import FlightRoster
from .flightstate import FlightState, Navigating, Uninitialized
from .flightstate.killed import Killed
from ..savecompat import has_save_compat_for
from ..sidc import (
Entity,
SidcDescribable,
@ -108,14 +107,9 @@ class Flight(SidcDescribable):
del state["state"]
return state
@has_save_compat_for(9)
def __setstate__(self, state: dict[str, Any]) -> None:
state["state"] = Uninitialized(self, state["squadron"].settings)
if "use_same_loadout_for_all_members" not in state:
state["use_same_loadout_for_all_members"] = True
self.__dict__.update(state)
if isinstance(self.roster, FlightRoster):
self.roster = FlightMembers.from_roster(self, self.roster)
@property
def blue(self) -> bool:

View File

@ -1,10 +1,9 @@
from __future__ import annotations
from typing import TYPE_CHECKING, Any
from typing import TYPE_CHECKING
from game.ato.loadouts import Loadout
from game.lasercodes import LaserCode
from game.savecompat import has_save_compat_for
if TYPE_CHECKING:
from game.squadrons import Pilot
@ -19,14 +18,6 @@ class FlightMember:
self.weapon_laser_code: LaserCode | None = None
self.properties: dict[str, bool | float | int] = {}
@has_save_compat_for(9)
def __setstate__(self, state: dict[str, Any]) -> None:
if "tgp_laser_code" not in state:
state["tgp_laser_code"] = None
if "weapon_laser_code" not in state:
state["weapon_laser_code"] = None
self.__dict__.update(state)
def assign_tgp_laser_code(self, code: LaserCode) -> None:
if self.tgp_laser_code is not None:
raise RuntimeError(

View File

@ -35,7 +35,6 @@ from game.radio.channels import (
ViperChannelNamer,
WarthogChannelNamer,
)
from game.savecompat import has_save_compat_for
from game.utils import (
Distance,
ImperialUnits,
@ -348,12 +347,7 @@ class AircraftType(UnitType[Type[FlyingType]]):
def task_priority(self, task: FlightType) -> int:
return self.task_priorities[task]
@has_save_compat_for(9)
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__)

View File

@ -11,7 +11,6 @@ from dcs.vehicles import vehicle_map
from game.data.units import UnitClass
from game.dcs.unittype import UnitType
from game.savecompat import has_save_compat_for
@dataclass
@ -65,12 +64,7 @@ class GroundUnitType(UnitType[Type[VehicleType]]):
dict[type[VehicleType], list[GroundUnitType]]
] = defaultdict(list)
@has_save_compat_for(9)
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 = GroundUnitType.named(state["variant_id"])
state.update(updated.__dict__)

View File

@ -10,7 +10,6 @@ from dcs.unittype import ShipType
from game.data.units import UnitClass
from game.dcs.unittype import UnitType
from game.savecompat import has_save_compat_for
@dataclass(frozen=True)
@ -20,12 +19,7 @@ class ShipUnitType(UnitType[Type[ShipType]]):
list
)
@has_save_compat_for(9)
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 = ShipUnitType.named(state["variant_id"])
state.update(updated.__dict__)

View File

@ -27,7 +27,6 @@ from .infos.information import Information
from .lasercodes.lasercoderegistry import LaserCodeRegistry
from .persistence import SaveManager
from .profiling import logged_duration
from .savecompat import has_save_compat_for
from .settings import Settings
from .theater import ConflictTheater
from .theater.bullseye import Bullseye
@ -142,13 +141,8 @@ class Game:
self.on_load(game_still_initializing=True)
@has_save_compat_for(9)
def __setstate__(self, state: dict[str, Any]) -> None:
self.__dict__.update(state)
if not hasattr(self, "laser_code_registry"):
self.laser_code_registry = LaserCodeRegistry()
for front_line in self.theater.conflicts():
front_line.laser_code = self.laser_code_registry.alloc_laser_code()
# Regenerate any state that was not persisted.
self.on_load()