mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Migration changes
This commit is contained in:
parent
785beffee0
commit
34645560bf
@ -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]()
|
||||
|
||||
@ -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:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user