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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user