diff --git a/changelog.md b/changelog.md index 7965b11d..a875c748 100644 --- a/changelog.md +++ b/changelog.md @@ -25,6 +25,7 @@ Saves from 5.x are not compatible with 6.0. * **[Mission Generation]** Fixed an issue which generated the helipads at FARPs incorrectly and placed the helicopters within each other. * **[Mission Generation]** Fixed an issue with SEAD missions flown by the AI when using the Skynet Plugin and anti-radiation missiles (ARM). The AI now correctly engages the SAM when it comes alive instead of diving into it. * **[Mission Generation]** Fixed an issue where SEAD/DEAD/BAI flights fired all missiles / bombs against a single unit in a group instead of targeting the whole group. +* **[Mission Generation]** Fixed adding additional mission types for a squadron causing error messages when the mission type is not supported by the aircraft type by default * **[UI]** Fixed and issue where the liberation main exe was still running after application close. # 5.2.0 diff --git a/game/squadrons/airwing.py b/game/squadrons/airwing.py index 54339ae8..105f3dd2 100644 --- a/game/squadrons/airwing.py +++ b/game/squadrons/airwing.py @@ -57,6 +57,9 @@ class AirWing: for squadron in control_point.squadrons: if squadron.can_auto_assign_mission(location, task, size, this_turn): capable_at_base.append(squadron) + if squadron.aircraft not in best_aircraft: + # If it is not already in the list it should be the last one + best_aircraft.append(squadron.aircraft) ordered.extend( sorted( @@ -73,11 +76,10 @@ class AirWing: return squadron return None - @property - def available_aircraft_types(self) -> Iterator[AircraftType]: + def available_aircraft_for_task(self, task: FlightType) -> Iterator[AircraftType]: for aircraft, squadrons in self.squadrons.items(): for squadron in squadrons: - if squadron.untasked_aircraft: + if squadron.untasked_aircraft and task in squadron.mission_types: yield aircraft break diff --git a/qt_ui/widgets/combos/QAircraftTypeSelector.py b/qt_ui/widgets/combos/QAircraftTypeSelector.py index ccec8207..7c17db59 100644 --- a/qt_ui/widgets/combos/QAircraftTypeSelector.py +++ b/qt_ui/widgets/combos/QAircraftTypeSelector.py @@ -1,31 +1,24 @@ """Combo box for selecting aircraft types.""" -from typing import Iterable, Type - +from typing import Iterable from PySide2.QtWidgets import QComboBox -from dcs.unittype import FlyingType - -from game.ato.ai_flight_planner_db import aircraft_for_task -from game.ato.flighttype import FlightType +from game.dcs.aircrafttype import AircraftType class QAircraftTypeSelector(QComboBox): """Combo box for selecting among the given aircraft types.""" - def __init__( - self, aircraft_types: Iterable[Type[FlyingType]], mission_type: FlightType - ) -> None: + def __init__(self, aircraft_types: Iterable[AircraftType]) -> None: super().__init__() self.model().sort(0) self.setSizeAdjustPolicy(self.AdjustToContents) - self.update_items(mission_type, aircraft_types) + self.update_items(aircraft_types) - def update_items(self, mission_type: FlightType, aircraft_types): + def update_items(self, aircraft_types: Iterable[AircraftType]): current_aircraft = self.currentData() self.clear() for aircraft in aircraft_types: - if aircraft in aircraft_for_task(mission_type): - self.addItem(f"{aircraft}", userData=aircraft) + self.addItem(f"{aircraft}", userData=aircraft) current_aircraft_index = self.findData(current_aircraft) if current_aircraft_index != -1: self.setCurrentIndex(current_aircraft_index) diff --git a/qt_ui/windows/mission/flight/QFlightCreator.py b/qt_ui/windows/mission/flight/QFlightCreator.py index 385cb7da..d58af13b 100644 --- a/qt_ui/windows/mission/flight/QFlightCreator.py +++ b/qt_ui/windows/mission/flight/QFlightCreator.py @@ -56,8 +56,9 @@ class QFlightCreator(QDialog): layout.addLayout(QLabeledWidget("Task:", self.task_selector)) self.aircraft_selector = QAircraftTypeSelector( - self.game.blue.air_wing.available_aircraft_types, - self.task_selector.currentData(), + self.game.blue.air_wing.available_aircraft_for_task( + self.task_selector.currentData() + ) ) self.aircraft_selector.setCurrentIndex(0) self.aircraft_selector.currentIndexChanged.connect(self.on_aircraft_changed) @@ -216,7 +217,7 @@ class QFlightCreator(QDialog): def on_task_changed(self, index: int) -> None: task = self.task_selector.itemData(index) self.aircraft_selector.update_items( - task, self.game.blue.air_wing.available_aircraft_types + self.game.blue.air_wing.available_aircraft_for_task(task) ) self.squadron_selector.update_items(task, self.aircraft_selector.currentData())