Migration changes

This commit is contained in:
Raffson 2023-05-14 21:57:12 +02:00
parent 785beffee0
commit 34645560bf
No known key found for this signature in database
GPG Key ID: B0402B2C9B764D99
2 changed files with 23 additions and 9 deletions

View File

@ -2,7 +2,8 @@ from __future__ import annotations
from typing import TYPE_CHECKING, Any
from game.ato.packagewaypoints import PackageWaypoints
from dcs.countries import countries_by_name
from game.data.doctrine import MODERN_DOCTRINE, COLDWAR_DOCTRINE, WWII_DOCTRINE
if TYPE_CHECKING:
@ -24,7 +25,9 @@ class Migrator:
self._update_packagewaypoints()
self._update_package_attributes()
self._update_control_points()
self._update_factions()
self._update_flights()
self._update_squadrons()
self._release_untasked_flights()
def _update_doctrine(self) -> None:
@ -88,3 +91,17 @@ class Migrator:
if f.squadron == s:
count += f.count
s.claim_inventory(count - claimed)
def _update_squadrons(self) -> None:
for cp in self.game.theater.controlpoints:
for s in cp.squadrons:
preferred_task = max(
s.aircraft.task_priorities, key=lambda x: s.aircraft.task_priorities[x]
)
try_set_attr(s, "primary_task", preferred_task)
try_set_attr(s, "max_size", 12)
def _update_factions(self) -> None:
for c in self.game.coalitions:
if isinstance(c.faction.country, str):
c.faction.country = countries_by_name[c.faction.country]()

View File

@ -108,14 +108,11 @@ class QLiberationWindow(QMainWindow):
if self.game is None:
last_save_file = liberation_install.get_last_save_file()
if last_save_file:
try:
logging.info("Loading last saved game : " + str(last_save_file))
game = persistency.load_game(last_save_file)
Migrator(game)
self.onGameGenerated(game)
self.updateWindowTitle(last_save_file if game else None)
except:
logging.info("Error loading latest save game")
logging.info("Loading last saved game : " + str(last_save_file))
game = persistency.load_game(last_save_file)
Migrator(game)
self.onGameGenerated(game)
self.updateWindowTitle(last_save_file if game else None)
else:
logging.info("No existing save game")
else: