Disallow squadrons from disabling mission types.

After this change, players will always have the final say in what
missions a squadron can be assigned to. Squadrons are not able to
influence the default auto-assignable missions either because that
property is always overridden by the campaign's air wing configuration
(the primary and secondary task properties). The `mission-types` field
of the squadron definition has been removed since it is no longer
capable of influencing anything. I haven't bothered cleaning up the now
useless data in all the existing squadrons though.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2785.
This commit is contained in:
Dan Albert 2023-04-17 19:21:10 -07:00 committed by Raffson
parent 5e2625ad21
commit 03c48376c4
No known key found for this signature in database
GPG Key ID: B0402B2C9B764D99
6 changed files with 16 additions and 34 deletions

View File

@ -136,6 +136,8 @@ Saves from 6.x are not compatible with 7.0.
* **[Modding]** Updated Community A-4E-C mod version support to 2.1.0 release. * **[Modding]** Updated Community A-4E-C mod version support to 2.1.0 release.
* **[Modding]** Add support for VSN F-4B and F-4C mod. * **[Modding]** Add support for VSN F-4B and F-4C mod.
* **[Modding]** Aircraft task capabilities and preferred aircraft for each task are now moddable in the aircraft unit yaml files. Each aircraft has a weight per task. Higher weights are given higher preference. * **[Modding]** Aircraft task capabilities and preferred aircraft for each task are now moddable in the aircraft unit yaml files. Each aircraft has a weight per task. Higher weights are given higher preference.
* **[Modding]** The `mission_types` field in squadron files has been removed. Squadron task capability is now determined by airframe, and the auto-assignable list has always been overridden by the campaign settings.
* **[Squadrons]** Squadron-specific mission capability lists no longer restrict players from assigning missions outside the squadron's preferences.
## Fixes ## Fixes

View File

@ -2,7 +2,7 @@ from __future__ import annotations
import itertools import itertools
from collections import defaultdict from collections import defaultdict
from typing import Sequence, Iterator, TYPE_CHECKING, Optional from typing import Iterator, Optional, Sequence, TYPE_CHECKING
from game.ato.closestairfields import ObjectiveDistanceCache from game.ato.closestairfields import ObjectiveDistanceCache
from game.dcs.aircrafttype import AircraftType from game.dcs.aircrafttype import AircraftType

View File

@ -1,8 +1,6 @@
from __future__ import annotations from __future__ import annotations
import logging from dataclasses import dataclass
from collections.abc import Iterable
from dataclasses import dataclass, field
from pathlib import Path from pathlib import Path
from typing import Optional, TYPE_CHECKING from typing import Optional, TYPE_CHECKING
@ -38,7 +36,6 @@ class SquadronDef:
def capable_of(self, task: FlightType) -> bool: def capable_of(self, task: FlightType) -> bool:
"""Returns True if the squadron is capable of performing the given task. """Returns True if the squadron is capable of performing the given task.
A squadron may be capable of performing a task even if it will not be A squadron may be capable of performing a task even if it will not be
automatically assigned to it. automatically assigned to it.
""" """

View File

@ -45,9 +45,6 @@ class QMissionType:
self, mission_type: FlightType, allowed: bool, auto_assignable: bool self, mission_type: FlightType, allowed: bool, auto_assignable: bool
) -> None: ) -> None:
self.flight_type = mission_type self.flight_type = mission_type
self.allowed_checkbox = QCheckBox()
self.allowed_checkbox.setChecked(allowed)
self.allowed_checkbox.toggled.connect(self.update_auto_assignable)
self.auto_assignable_checkbox = QCheckBox() self.auto_assignable_checkbox = QCheckBox()
self.auto_assignable_checkbox.setEnabled(allowed) self.auto_assignable_checkbox.setEnabled(allowed)
self.auto_assignable_checkbox.setChecked(auto_assignable) self.auto_assignable_checkbox.setChecked(auto_assignable)
@ -57,10 +54,6 @@ class QMissionType:
if not checked: if not checked:
self.auto_assignable_checkbox.setChecked(False) self.auto_assignable_checkbox.setChecked(False)
@property
def allowed(self) -> bool:
return self.allowed_checkbox.isChecked()
@property @property
def auto_assignable(self) -> bool: def auto_assignable(self) -> bool:
return self.auto_assignable_checkbox.isChecked() return self.auto_assignable_checkbox.isChecked()
@ -73,27 +66,20 @@ class MissionTypeControls(QGridLayout):
self.mission_types: list[QMissionType] = [] self.mission_types: list[QMissionType] = []
self.addWidget(QLabel("Mission Type"), 0, 0) self.addWidget(QLabel("Mission Type"), 0, 0)
self.addWidget(QLabel("Allow"), 0, 1) self.addWidget(QLabel("Auto-Assign"), 0, 1)
self.addWidget(QLabel("Auto-Assign"), 0, 2)
for i, task in enumerate(FlightType): for i, task in enumerate(FlightType):
if task is FlightType.FERRY: if task is FlightType.FERRY:
# Not plannable so just skip it. # Not plannable so just skip it.
continue continue
allowed = task in squadron.mission_types
auto_assignable = task in squadron.auto_assignable_mission_types auto_assignable = task in squadron.auto_assignable_mission_types
mission_type = QMissionType(task, allowed, auto_assignable) mission_type = QMissionType(
task, squadron.capable_of(task), auto_assignable
)
self.mission_types.append(mission_type) self.mission_types.append(mission_type)
self.addWidget(QLabel(task.value), i + 1, 0) self.addWidget(QLabel(task.value), i + 1, 0)
self.addWidget(mission_type.allowed_checkbox, i + 1, 1) self.addWidget(mission_type.auto_assignable_checkbox, i + 1, 1)
self.addWidget(mission_type.auto_assignable_checkbox, i + 1, 2)
@property
def allowed_mission_types(self) -> Iterator[FlightType]:
for mission_type in self.mission_types:
if mission_type.allowed:
yield mission_type.flight_type
@property @property
def auto_assignable_mission_types(self) -> Iterator[FlightType]: def auto_assignable_mission_types(self) -> Iterator[FlightType]:
@ -280,10 +266,6 @@ class SquadronConfigurationBox(QGroupBox):
self.squadron.pilot_pool = [ self.squadron.pilot_pool = [
Pilot(n, player=True) for n in player_names Pilot(n, player=True) for n in player_names
] + self.squadron.pilot_pool ] + self.squadron.pilot_pool
# Set the allowed mission types
self.squadron.set_allowed_mission_types(
set(self.mission_types.allowed_mission_types)
)
# Also update the auto assignable mission types # Also update the auto assignable mission types
self.squadron.set_auto_assignable_mission_types( self.squadron.set_auto_assignable_mission_types(
set(self.mission_types.auto_assignable_mission_types) set(self.mission_types.auto_assignable_mission_types)

View File

@ -82,11 +82,12 @@ class AutoAssignedTaskControls(QVBoxLayout):
return callback return callback
for task in squadron_model.squadron.mission_types: for task in FlightType:
checkbox = QCheckBox(text=task.value) if self.squadron_model.squadron.capable_of(task):
checkbox.setChecked(squadron_model.is_auto_assignable(task)) checkbox = QCheckBox(text=task.value)
checkbox.toggled.connect(make_callback(task)) checkbox.setChecked(squadron_model.is_auto_assignable(task))
self.addWidget(checkbox) checkbox.toggled.connect(make_callback(task))
self.addWidget(checkbox)
self.addStretch() self.addStretch()

View File

@ -48,7 +48,7 @@ class SquadronSelector(QComboBox):
return return
for squadron in self.air_wing.squadrons_for(aircraft): for squadron in self.air_wing.squadrons_for(aircraft):
valid_task = task in squadron.mission_types valid_task = squadron.capable_of(task)
runway_operational = squadron.location.runway_is_operational() runway_operational = squadron.location.runway_is_operational()
if valid_task and squadron.untasked_aircraft and runway_operational: if valid_task and squadron.untasked_aircraft and runway_operational:
self.addItem(f"{squadron.location}: {squadron}", squadron) self.addItem(f"{squadron.location}: {squadron}", squadron)