Fix bugs reported in Discord

- Fixes ferry flights causing errors when "Nothing" is not available
- Logs a warning when a frontline stance is suddenly no longer available and uses defense stance as fallback which used to be the default. An investigation is still required to determine the cause of this...
This commit is contained in:
Raffson 2023-06-09 19:28:18 +02:00
parent 055519411b
commit 9c1be534c7
No known key found for this signature in database
GPG Key ID: B0402B2C9B764D99
2 changed files with 13 additions and 2 deletions

View File

@ -151,7 +151,12 @@ class GroundPlanner:
while available > 0:
if len(self.connected_enemy_cp) > 0:
enemy_cp: ControlPoint = random.choice(self.connected_enemy_cp)
frontline_stance = self.cp.stances[enemy_cp.id]
frontline_stance = self.cp.stances.get(enemy_cp.id)
if not frontline_stance:
logging.warning(
f"{self.cp.name} lost its frontline stance for {enemy_cp.name}"
)
frontline_stance = CombatStance.DEFENSIVE
group_size_choice = GROUP_SIZES_BY_COMBAT_STANCE[frontline_stance]
if role == CombatGroupRole.SHORAD:
count = 1

View File

@ -351,6 +351,8 @@ class AircraftBehavior:
preferred_task: Type[MainTask],
fallback_task: Optional[Type[MainTask]] = None,
) -> None:
ac_type = flight.unit_type.dcs_unit_type.id
# Not all aircraft are always compatible with the preferred task,
# so a common fallback is to use CAS instead.
# Sometimes it's also the other way around,
@ -362,8 +364,12 @@ class AircraftBehavior:
group.task = preferred_task.name
elif fallback_task and fallback_task in flight.unit_type.dcs_unit_type.tasks:
group.task = fallback_task.name
elif flight.unit_type.dcs_unit_type.task_default and preferred_task == Nothing:
group.task = flight.unit_type.dcs_unit_type.task_default.name
logging.warning(
f"{ac_type} is not capable of 'Nothing', using default task '{group.task}'"
)
else:
ac_type = flight.unit_type.dcs_unit_type.id
fallback_part = f" nor {fallback_task.name}" if fallback_task else ""
raise RuntimeError(
f"{ac_type} is neither capable of {preferred_task.name}"