mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Fix bugs while loading air wing configs (#552)
* fix bugs with air wing config loading * add aircraft type to airwing config for better loading
This commit is contained in:
parent
52fbc75e1c
commit
afad73ac27
@ -17,6 +17,7 @@
|
|||||||
## Fixes
|
## Fixes
|
||||||
* **[Flight Plans]** Fixed a bug when a package was created with only escort flights
|
* **[Flight Plans]** Fixed a bug when a package was created with only escort flights
|
||||||
* **[Flight Plans]** Added AntiShipStrike as a fallback task for OCA/Aircraft to fix a bug where the S-3B could not do OCA/Aircraft
|
* **[Flight Plans]** Added AntiShipStrike as a fallback task for OCA/Aircraft to fix a bug where the S-3B could not do OCA/Aircraft
|
||||||
|
* **[Squadrons]** Fixed a bug where loading an air wing config would not properly load all squadrons
|
||||||
|
|
||||||
# Retribution v1.4.1 (hotfix)
|
# Retribution v1.4.1 (hotfix)
|
||||||
|
|
||||||
|
|||||||
@ -26,6 +26,7 @@ class SquadronConfig:
|
|||||||
name: Optional[str]
|
name: Optional[str]
|
||||||
nickname: Optional[str]
|
nickname: Optional[str]
|
||||||
female_pilot_percentage: Optional[int]
|
female_pilot_percentage: Optional[int]
|
||||||
|
aircraft_type: Optional[str]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def auto_assignable(self) -> set[FlightType]:
|
def auto_assignable(self) -> set[FlightType]:
|
||||||
@ -51,6 +52,7 @@ class SquadronConfig:
|
|||||||
data.get("name", None),
|
data.get("name", None),
|
||||||
data.get("nickname", None),
|
data.get("nickname", None),
|
||||||
data.get("female_pilot_percentage", None),
|
data.get("female_pilot_percentage", None),
|
||||||
|
data.get("aircraft_type", None),
|
||||||
)
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -83,15 +85,14 @@ class CampaignAirWingConfig:
|
|||||||
try:
|
try:
|
||||||
base = theater.control_point_named(base_id)
|
base = theater.control_point_named(base_id)
|
||||||
except:
|
except:
|
||||||
if base_id == "Red CV":
|
logging.warning(
|
||||||
base = next((c for c in carriers if not c.captured), None)
|
f"Control point {base_id} not found, trying to match by full name"
|
||||||
elif base_id == "Blue CV":
|
)
|
||||||
base = next((c for c in carriers if c.captured), None)
|
if not base:
|
||||||
elif base_id == "Red LHA":
|
try:
|
||||||
base = next((l for l in lhas if not l.captured), None)
|
base = theater.control_point_by_full_name(base_id)
|
||||||
elif base_id == "Blue LHA":
|
except KeyError:
|
||||||
base = next((l for l in lhas if l.captured), None)
|
logging.error(f"Control point {base_id} not found, skipping")
|
||||||
|
|
||||||
for squadron_data in squadron_configs:
|
for squadron_data in squadron_configs:
|
||||||
if base is None:
|
if base is None:
|
||||||
logging.warning(
|
logging.warning(
|
||||||
|
|||||||
@ -60,7 +60,7 @@ class DefaultSquadronAssigner:
|
|||||||
) -> Optional[SquadronDef]:
|
) -> Optional[SquadronDef]:
|
||||||
for preferred_aircraft in config.aircraft:
|
for preferred_aircraft in config.aircraft:
|
||||||
squadron_def = self.find_preferred_squadron(
|
squadron_def = self.find_preferred_squadron(
|
||||||
preferred_aircraft, config.primary, control_point
|
preferred_aircraft, config.aircraft_type, config.primary, control_point
|
||||||
)
|
)
|
||||||
if squadron_def is not None:
|
if squadron_def is not None:
|
||||||
return squadron_def
|
return squadron_def
|
||||||
@ -78,7 +78,11 @@ class DefaultSquadronAssigner:
|
|||||||
)
|
)
|
||||||
|
|
||||||
def find_preferred_squadron(
|
def find_preferred_squadron(
|
||||||
self, preferred_aircraft: str, task: FlightType, control_point: ControlPoint
|
self,
|
||||||
|
preferred_aircraft: str,
|
||||||
|
aircraft_type: Optional[str],
|
||||||
|
task: FlightType,
|
||||||
|
control_point: ControlPoint,
|
||||||
) -> Optional[SquadronDef]:
|
) -> Optional[SquadronDef]:
|
||||||
# Attempt to find a squadron with the name in the request.
|
# Attempt to find a squadron with the name in the request.
|
||||||
squadron_def = self.find_squadron_by_name(
|
squadron_def = self.find_squadron_by_name(
|
||||||
@ -90,7 +94,7 @@ class DefaultSquadronAssigner:
|
|||||||
# If the name didn't match a squadron available to this coalition, try to find
|
# If the name didn't match a squadron available to this coalition, try to find
|
||||||
# an aircraft with the matching name that meets the requirements.
|
# an aircraft with the matching name that meets the requirements.
|
||||||
try:
|
try:
|
||||||
aircraft = AircraftType.named(preferred_aircraft)
|
aircraft = AircraftType.named(aircraft_type or preferred_aircraft)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logging.warning(
|
logging.warning(
|
||||||
"%s is neither a compatible squadron or a known aircraft type, "
|
"%s is neither a compatible squadron or a known aircraft type, "
|
||||||
|
|||||||
@ -292,6 +292,12 @@ class ConflictTheater:
|
|||||||
return cp
|
return cp
|
||||||
raise KeyError(f"Cannot find ControlPoint named {name}")
|
raise KeyError(f"Cannot find ControlPoint named {name}")
|
||||||
|
|
||||||
|
def control_point_by_full_name(self, full_name: str) -> ControlPoint:
|
||||||
|
for cp in self.controlpoints:
|
||||||
|
if cp.full_name == full_name:
|
||||||
|
return cp
|
||||||
|
raise KeyError(f"Cannot find ControlPoint with full name {full_name}")
|
||||||
|
|
||||||
def find_carriers(self) -> List[ControlPoint]:
|
def find_carriers(self) -> List[ControlPoint]:
|
||||||
try:
|
try:
|
||||||
carriers = [cp for cp in self.controlpoints if cp.is_carrier]
|
carriers = [cp for cp in self.controlpoints if cp.is_carrier]
|
||||||
|
|||||||
@ -866,6 +866,7 @@ class AirWingConfigurationDialog(QDialog):
|
|||||||
if sec.value != s.primary_task.value
|
if sec.value != s.primary_task.value
|
||||||
],
|
],
|
||||||
"aircraft": [name],
|
"aircraft": [name],
|
||||||
|
"aircraft_type": s.aircraft.display_name,
|
||||||
"size": s.max_size,
|
"size": s.max_size,
|
||||||
}
|
}
|
||||||
if squadrons.get(key):
|
if squadrons.get(key):
|
||||||
@ -900,6 +901,9 @@ class AirWingConfigurationDialog(QDialog):
|
|||||||
w = self.tab_widget.currentWidget()
|
w = self.tab_widget.currentWidget()
|
||||||
assert isinstance(w, AirWingConfigurationTab)
|
assert isinstance(w, AirWingConfigurationTab)
|
||||||
c = w.coalition
|
c = w.coalition
|
||||||
|
for s in c.air_wing.squadrons.values():
|
||||||
|
for squadron in s:
|
||||||
|
c.air_wing.unclaim_squadron_def(squadron)
|
||||||
c.air_wing.squadrons = defaultdict(list)
|
c.air_wing.squadrons = defaultdict(list)
|
||||||
config = CampaignAirWingConfig.from_campaign_data(airwing, c.game.theater)
|
config = CampaignAirWingConfig.from_campaign_data(airwing, c.game.theater)
|
||||||
c.configure_default_air_wing(config)
|
c.configure_default_air_wing(config)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user