diff --git a/src/blackmisc/simulation/ownaircraftprovider.cpp b/src/blackmisc/simulation/ownaircraftprovider.cpp index e77a6f288c..0c2c28d212 100644 --- a/src/blackmisc/simulation/ownaircraftprovider.cpp +++ b/src/blackmisc/simulation/ownaircraftprovider.cpp @@ -32,6 +32,18 @@ namespace BlackMisc::Simulation return this->provider()->getOwnCallsign(); } + CComSystem COwnAircraftAware::getOwnComSystem(CComSystem::ComUnit unit) const + { + Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available"); + return this->provider()->getOwnComSystem(unit); + } + + CTransponder COwnAircraftAware::getOwnTransponder() const + { + Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available"); + return this->provider()->getOwnTransponder(); + } + CCoordinateGeodetic COwnAircraftAware::getOwnAircraftPosition() const { Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available"); diff --git a/src/blackmisc/simulation/ownaircraftprovider.h b/src/blackmisc/simulation/ownaircraftprovider.h index 5c01f2f7a3..dd0411ae8a 100644 --- a/src/blackmisc/simulation/ownaircraftprovider.h +++ b/src/blackmisc/simulation/ownaircraftprovider.h @@ -131,6 +131,12 @@ namespace BlackMisc //! \copydoc IOwnAircraftProvider::getOwnCallsign Aviation::CCallsign getOwnCallsign() const; + //! \copydoc IOwnAircraftProvider::getOwnComSystem + Aviation::CComSystem getOwnComSystem(Aviation::CComSystem::ComUnit unit) const; + + //! \copydoc IOwnAircraftProvider::getOwnTransponder + Aviation::CTransponder getOwnTransponder() const; + //! \copydoc IOwnAircraftProvider::getOwnAircraftPosition BlackMisc::Geo::CCoordinateGeodetic getOwnAircraftPosition() const; diff --git a/src/plugins/simulator/fs9/simulatorfs9.cpp b/src/plugins/simulator/fs9/simulatorfs9.cpp index 35538f782c..ffd11f4fc2 100644 --- a/src/plugins/simulator/fs9/simulatorfs9.cpp +++ b/src/plugins/simulator/fs9/simulatorfs9.cpp @@ -417,11 +417,25 @@ namespace BlackSimPlugin::Fs9 // To avoid jitters, I wait some update cylces to stabilize the values if (m_skipCockpitUpdateCycles < 1) { - this->updateCockpit( - simDataOwnAircraft.getCom1System(), - simDataOwnAircraft.getCom2System(), - simDataOwnAircraft.getTransponder(), - this->identifier()); + const auto dontOverwrite = [](const CFrequency &from, const CFrequency &to) { + // don't overwrite 8.33 kHz frequencies + return CComSystem::isExclusiveWithin8_33kHzChannel(from) && + from.valueInteger(CFrequencyUnit::kHz()) / 10 == to.valueInteger(CFrequencyUnit::kHz()) / 10; + }; + CComSystem com1 = simDataOwnAircraft.getCom1System(); + CComSystem com2 = simDataOwnAircraft.getCom2System(); + const CComSystem oldCom1 = getOwnComSystem(CComSystem::Com1); + const CComSystem oldCom2 = getOwnComSystem(CComSystem::Com2); + if (dontOverwrite(oldCom1.getFrequencyActive(), com1.getFrequencyActive())) + com1.setFrequencyActive(oldCom1.getFrequencyActive()); + if (dontOverwrite(oldCom1.getFrequencyStandby(), com1.getFrequencyStandby())) + com1.setFrequencyStandby(oldCom1.getFrequencyStandby()); + if (dontOverwrite(oldCom2.getFrequencyActive(), com2.getFrequencyActive())) + com2.setFrequencyActive(oldCom2.getFrequencyActive()); + if (dontOverwrite(oldCom2.getFrequencyStandby(), com2.getFrequencyStandby())) + com2.setFrequencyStandby(oldCom2.getFrequencyStandby()); + + this->updateCockpit(com1, com2, simDataOwnAircraft.getTransponder(), this->identifier()); } else {