diff --git a/src/blackcore/context/contextnetworkimpl.cpp b/src/blackcore/context/contextnetworkimpl.cpp index ad4164333..08e8c4c53 100644 --- a/src/blackcore/context/contextnetworkimpl.cpp +++ b/src/blackcore/context/contextnetworkimpl.cpp @@ -21,6 +21,7 @@ #include "blackmisc/aviation/aircrafticaocode.h" #include "blackmisc/aviation/aircraftparts.h" #include "blackmisc/aviation/atcstationlist.h" +#include "blackmisc/aviation/comsystem.h" #include "blackmisc/aviation/callsign.h" #include "blackmisc/aviation/comsystem.h" #include "blackmisc/dbusserver.h" @@ -296,7 +297,7 @@ namespace BlackCore } // set receiver - const QString receiver = parser.part(1).trimmed(); // receiver + const QString receiver = parser.part(1).trimmed().toLower(); // receiver const CSimulatedAircraft ownAircraft(this->getIContextOwnAircraft()->getOwnAircraft()); if (ownAircraft.getCallsign().isEmpty()) { @@ -307,15 +308,15 @@ namespace BlackCore CTextMessage tm; tm.setSenderCallsign(ownAircraft.getCallsign()); - if (receiver == "c1" || receiver == "com1") + if (receiver.startsWith("c") && receiver.endsWith("1")) { tm.setFrequency(ownAircraft.getCom1System().getFrequencyActive()); } - else if (receiver == "c2" || receiver == "com2") + else if (receiver.startsWith("c") && receiver.endsWith("2")) { tm.setFrequency(ownAircraft.getCom2System().getFrequencyActive()); } - else if (receiver == "u" || receiver == "unicom" || receiver == "uni") + else if (receiver == "u" || receiver.startsWith("uni")) { tm.setFrequency(CPhysicalQuantitiesConstants::FrequencyUnicom()); } @@ -326,6 +327,7 @@ namespace BlackCore if (isNumber) { CFrequency radioFrequency = CFrequency(frequencyMhz, CFrequencyUnit::MHz()); + CComSystem::roundToChannelSpacing(radioFrequency, CComSystem::ChannelSpacing8_33KHz); if (CComSystem::isValidCivilAviationFrequency(radioFrequency)) { tm.setFrequency(radioFrequency); @@ -338,7 +340,7 @@ namespace BlackCore } else { - CCallsign toCallsign(receiver); + const CCallsign toCallsign(receiver); tm.setRecipientCallsign(toCallsign); } } diff --git a/src/blackcore/pluginmanagersimulator.cpp b/src/blackcore/pluginmanagersimulator.cpp index b16f2666b..ecddd4b0f 100644 --- a/src/blackcore/pluginmanagersimulator.cpp +++ b/src/blackcore/pluginmanagersimulator.cpp @@ -79,6 +79,7 @@ namespace BlackCore for (PluginExtended &pi : m_plugins.values()) { if (!pi.listener) { continue; } + if (!pi.listener->isRunning()) { continue; } pi.listener->check(); c++; } diff --git a/src/blackcore/simulator.cpp b/src/blackcore/simulator.cpp index 0c080dce9..072e06a6a 100644 --- a/src/blackcore/simulator.cpp +++ b/src/blackcore/simulator.cpp @@ -1165,7 +1165,7 @@ namespace BlackCore void ISimulatorListener::check() { - if (m_isRunning) { return; } + if (!m_isRunning) { return; } if (!CThreadUtils::isCurrentThreadObjectThread(this)) { // call in correct thread diff --git a/src/blackcore/simulator.h b/src/blackcore/simulator.h index 4fc269262..40a311500 100644 --- a/src/blackcore/simulator.h +++ b/src/blackcore/simulator.h @@ -585,6 +585,9 @@ namespace BlackCore //! Info about the backend system (if available) virtual QString backendInfo() const; + //! Running? + bool isRunning() const { return m_isRunning; } + public slots: //! Start listening for the simulator to start. //! \threadsafe