mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Avoid claiming unused aircraft
Probably the final Fix #97 Unused aircraft (assigned upon takeoff) would get claimed but since it's not possible to delete those flights after aborting, these flights wouldn't get released anymore. This should fix that issue, including a migrator change to correct the number of claimed aircraft per squadron.
This commit is contained in:
parent
31cfc333c7
commit
b4b19d3ad5
@ -13,6 +13,7 @@
|
||||
|
||||
## Fixes
|
||||
* **[New Game Wizard]** Settings would not persist when going back to a previous page.
|
||||
* **[Mission Generation]** Unused aircraft are no longer claimed, fixing a bug where these aircraft would no longer be available after aborting the mission.
|
||||
|
||||
|
||||
# Retribution v1.1.1 (hotfix)
|
||||
|
||||
@ -56,13 +56,15 @@ class Flight(SidcDescribable, RadioFrequencyContainer, TacanContainer):
|
||||
frequency: Optional[RadioFrequency] = None,
|
||||
channel: Optional[TacanChannel] = None,
|
||||
callsign: Optional[str] = None,
|
||||
claim_inv: bool = True,
|
||||
) -> None:
|
||||
self.id = uuid.uuid4()
|
||||
self.package = package
|
||||
self.country = country
|
||||
self.coalition = squadron.coalition
|
||||
self.squadron = squadron
|
||||
self.squadron.claim_inventory(count)
|
||||
if claim_inv:
|
||||
self.squadron.claim_inventory(count)
|
||||
if roster is None:
|
||||
self.roster = FlightRoster(self.squadron, initial_size=count)
|
||||
else:
|
||||
|
||||
@ -25,6 +25,7 @@ class Migrator:
|
||||
self._update_package_attributes()
|
||||
self._update_control_points()
|
||||
self._update_flights()
|
||||
self._release_untasked_flights()
|
||||
|
||||
def _update_doctrine(self) -> None:
|
||||
doctrines = [
|
||||
@ -77,3 +78,13 @@ class Migrator:
|
||||
try_set_attr(f, "tacan")
|
||||
try_set_attr(f, "tcn_name")
|
||||
try_set_attr(f, "fuel", f.unit_type.max_fuel)
|
||||
|
||||
def _release_untasked_flights(self) -> None:
|
||||
for cp in self.game.theater.controlpoints:
|
||||
for s in cp.squadrons:
|
||||
claimed = s.owned_aircraft - s.untasked_aircraft
|
||||
count = 0
|
||||
for f in s.flight_db.objects.values():
|
||||
if f.squadron == s:
|
||||
count += f.count
|
||||
s.claim_inventory(count - claimed)
|
||||
|
||||
@ -180,6 +180,7 @@ class AircraftGenerator:
|
||||
FlightType.BARCAP,
|
||||
StartType.COLD,
|
||||
divert=None,
|
||||
claim_inv=False,
|
||||
)
|
||||
flight.state = Completed(flight, self.game.settings)
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
import os
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
|
||||
@ -23,7 +22,6 @@ from jinja2 import Environment, FileSystemLoader, select_autoescape
|
||||
|
||||
from game import Game
|
||||
from game.debriefing import Debriefing
|
||||
from game.persistency import base_path
|
||||
from game.profiling import logged_duration
|
||||
from qt_ui.simcontroller import SimController
|
||||
from qt_ui.windows.GameUpdateSignal import GameUpdateSignal
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user