From 5d8f6552439100d99b340a91de43f4e053d8c0f9 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Sat, 31 Jul 2021 14:23:46 -0700 Subject: [PATCH] Work around pydcs bug. https://github.com/pydcs/dcs/issues/175 causes setting the AI comm frequency to raise an exception for aircraft without preset channel support. --- gen/aircraft.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/gen/aircraft.py b/gen/aircraft.py index e82893e1..ecd76fbb 100644 --- a/gen/aircraft.py +++ b/gen/aircraft.py @@ -383,7 +383,18 @@ class AircraftConflictGenerator: channel = self.radio_registry.alloc_uhf() else: channel = flight.unit_type.alloc_flight_radio(self.radio_registry) - group.set_frequency(channel.mhz) + + try: + group.set_frequency(channel.mhz) + except TypeError: + # TODO: Remote try/except when pydcs bug is fixed. + # https://github.com/pydcs/dcs/issues/175 + # pydcs now emits an error when attempting to set a preset channel for an + # aircraft that doesn't support them. We're not choosing to set a preset + # here, we're just trying to set the AI's frequency. pydcs automatically + # tries to set channel 1 when it does that and doesn't suppress this new + # error. + pass divert = None if flight.divert is not None: