More save-compatibility changes

This commit is contained in:
Raffson 2023-05-18 22:30:18 +02:00
parent a9e48770b7
commit 386844378e
No known key found for this signature in database
GPG Key ID: B0402B2C9B764D99
7 changed files with 33 additions and 11 deletions

View File

@ -95,7 +95,6 @@ class Migrator:
def _update_squadrons(self) -> None:
for cp in self.game.theater.controlpoints:
for s in cp.squadrons:
print(s.aircraft, s.aircraft.task_priorities)
preferred_task = max(
s.aircraft.task_priorities,
key=lambda x: s.aircraft.task_priorities[x],

View File

@ -19,21 +19,37 @@ 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:
if name == "NightMissions":
from game.weather.conditions import NightMissions
from game.settings import NightMissions
return NightMissions
if name == "Conditions":
from game.weather.conditions import Conditions
return Conditions
if name == "ClearSkies":
from game.weather.conditions import ClearSkies
return ClearSkies
if name == "AtmosphericConditions":
from game.weather.atmosphericconditions import AtmosphericConditions
return AtmosphericConditions
if name == "WindConditions":
from game.weather.wind import WindConditions
return WindConditions
return super().find_class(module, name)
if name == "Clouds":
from game.weather.clouds import Clouds
return Clouds
if name == "ClearSkies":
from game.weather.weather import ClearSkies
return ClearSkies
if name == "Cloudy":
from game.weather.weather import Cloudy
return Cloudy
if name == "Raining":
from game.weather.weather import Raining
return Raining
if name == "Thunderstorm":
from game.weather.weather import Thunderstorm
return Thunderstorm
try:
return super().find_class(module, name)
except AttributeError:
print(module, name)
return None
# fmt: on

View File

@ -2,4 +2,5 @@ description: The An-30M is a military transport aircraft.
price: 15
variants:
An-30M: null
tasks: {}
tasks:
Transport: 150

View File

@ -28,4 +28,5 @@ role: Strike Fighter
max_range: 500
variants:
MiG-25RBT Foxbat-B: {}
tasks: {}
tasks:
Strike: 150

View File

@ -5,4 +5,7 @@ can_carry_crates: false
variants:
SA342Minigun: null
kneeboard_units: "metric"
tasks: {}
tasks:
BAI: 230
CAS: 230
OCA/Aircraft: 230

View File

@ -20,4 +20,5 @@ role: Light Attack
variants:
SA 342M Gazelle Mistral: {}
kneeboard_units: "metric"
tasks: {}
tasks:
Escort: 80

View File

@ -2,4 +2,5 @@ price: 15
max_range: 200
variants:
Su-24MR: null
tasks: {}
tasks:
BARCAP: 0