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.
This commit is contained in:
Dan Albert 2021-07-31 14:23:46 -07:00
parent 0cb41469ab
commit 5d8f655243

View File

@ -383,7 +383,18 @@ class AircraftConflictGenerator:
channel = self.radio_registry.alloc_uhf() channel = self.radio_registry.alloc_uhf()
else: else:
channel = flight.unit_type.alloc_flight_radio(self.radio_registry) 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 divert = None
if flight.divert is not None: if flight.divert is not None: