diff --git a/src/blackcore/airspaceanalyzer.cpp b/src/blackcore/airspaceanalyzer.cpp index 1d4c3ec4c..66f5ebcba 100644 --- a/src/blackcore/airspaceanalyzer.cpp +++ b/src/blackcore/airspaceanalyzer.cpp @@ -24,10 +24,11 @@ #include using namespace BlackMisc; -using namespace BlackMisc::Network; -using namespace BlackMisc::Simulation; using namespace BlackMisc::Aviation; +using namespace BlackMisc::Geo; +using namespace BlackMisc::Network; using namespace BlackMisc::PhysicalQuantities; +using namespace BlackMisc::Simulation; using namespace BlackCore::Fsd; namespace BlackCore @@ -63,7 +64,7 @@ namespace BlackCore // Monitor c = connect(airspaceMonitorParent, &CAirspaceMonitor::addedAircraftSituation, this, &CAirspaceAnalyzer::watchdogTouchAircraftCallsign); Q_ASSERT(c); - Q_UNUSED(c); + Q_UNUSED(c) // start in own thread this->start(QThread::LowestPriority); @@ -89,7 +90,7 @@ namespace BlackCore void CAirspaceAnalyzer::onNetworkPositionUpdate(const CAircraftSituation &situation, const CTransponder &transponder) { - Q_UNUSED(transponder); + Q_UNUSED(transponder) this->watchdogTouchAircraftCallsign(situation); } @@ -99,17 +100,17 @@ namespace BlackCore m_aircraftCallsignTimestamps[situation.getCallsign()] = QDateTime::currentMSecsSinceEpoch(); } - void CAirspaceAnalyzer::watchdogTouchAtcCallsign(const CCallsign &callsign, const CFrequency &frequency, const Geo::CCoordinateGeodetic &position, const CLength &range) + void CAirspaceAnalyzer::watchdogTouchAtcCallsign(const CCallsign &callsign, const CFrequency &frequency, const CCoordinateGeodetic &position, const CLength &range) { - Q_UNUSED(frequency); - Q_UNUSED(position); - Q_UNUSED(range); + Q_UNUSED(frequency) + Q_UNUSED(position) + Q_UNUSED(range) m_atcCallsignTimestamps[callsign] = QDateTime::currentMSecsSinceEpoch(); } void CAirspaceAnalyzer::onConnectionStatusChanged(CConnectionStatus oldStatus, CConnectionStatus newStatus) { - Q_UNUSED(oldStatus); + Q_UNUSED(oldStatus) if (newStatus.isDisconnected()) { this->clear(); @@ -164,11 +165,11 @@ namespace BlackCore m_doNotRunAgainBefore = -1; // checks - const qint64 aircraftTimeoutMs = m_timeoutAircraft.valueInteger(CTimeUnit::ms()); - const qint64 atcTimeoutMs = m_timeoutAtc.valueInteger(CTimeUnit::ms()); + const qint64 aircraftTimeoutMs = m_timeoutAircraft.valueInteger(CTimeUnit::ms()); + const qint64 atcTimeoutMs = m_timeoutAtc.valueInteger(CTimeUnit::ms()); const qint64 timeoutAircraftEpochMs = currentTimeMsEpoch - aircraftTimeoutMs; - const qint64 timeoutAtcEpochMs = currentTimeMsEpoch - atcTimeoutMs; - const bool enabled = m_enabledWatchdog; + const qint64 timeoutAtcEpochMs = currentTimeMsEpoch - atcTimeoutMs; + const bool enabled = m_enabledWatchdog; const QList callsignsAircraft = m_aircraftCallsignTimestamps.keys(); for (const CCallsign &callsign : callsignsAircraft) // clazy:exclude=container-anti-pattern,range-loop diff --git a/src/blackcore/airspaceanalyzer.h b/src/blackcore/airspaceanalyzer.h index a4a2e0c71..a975084fa 100644 --- a/src/blackcore/airspaceanalyzer.h +++ b/src/blackcore/airspaceanalyzer.h @@ -69,7 +69,7 @@ namespace BlackCore CAirspaceMonitor *airspaceMonitorParent); //! Destructor - virtual ~CAirspaceAnalyzer(); + virtual ~CAirspaceAnalyzer() override; //! Get the latest snapshot //! \threadsafe @@ -128,7 +128,7 @@ namespace BlackCore CCallsignTimestampSet m_aircraftCallsignTimestamps; //!< for watchdog (pilots) CCallsignTimestampSet m_atcCallsignTimestamps; //!< for watchdog (ATC) BlackMisc::PhysicalQuantities::CTime m_timeoutAircraft = { 15, BlackMisc::PhysicalQuantities::CTimeUnit::s() }; //!< Timeout value for watchdog functionality - BlackMisc::PhysicalQuantities::CTime m_timeoutAtc = { 50, BlackMisc::PhysicalQuantities::CTimeUnit::s() }; //!< Timeout value for watchdog functionality + BlackMisc::PhysicalQuantities::CTime m_timeoutAtc = { 50, BlackMisc::PhysicalQuantities::CTimeUnit::s() }; //!< Timeout value for watchdog functionality qint64 m_lastWatchdogCallMsSinceEpoch; //!< when last called qint64 m_doNotRunAgainBefore = -1; //!< do not run again before, also used to detect debugging std::atomic_bool m_enabledWatchdog { true }; //!< watchdog enabled diff --git a/src/blackcore/airspacemonitor.cpp b/src/blackcore/airspacemonitor.cpp index d295d5f65..f279129ec 100644 --- a/src/blackcore/airspacemonitor.cpp +++ b/src/blackcore/airspacemonitor.cpp @@ -729,15 +729,6 @@ namespace BlackCore if (changedAtis) { emit this->changedAtisReceived(callsign); } } - void CAirspaceMonitor::onAtisVoiceRoomReceived(const CCallsign &callsign, const QString &url) - { - Q_ASSERT(CThreadUtils::isCurrentThreadObjectThread(this)); - if (!this->isConnectedAndNotShuttingDown()) { return; } - Q_UNUSED(url) - Q_UNUSED(callsign) - return; - } - void CAirspaceMonitor::onAtisLogoffTimeReceived(const CCallsign &callsign, const QString &zuluTime) { Q_ASSERT(CThreadUtils::isCurrentThreadObjectThread(this)); diff --git a/src/blackcore/airspacemonitor.h b/src/blackcore/airspacemonitor.h index 7e34c5fc5..1800c2eb7 100644 --- a/src/blackcore/airspacemonitor.h +++ b/src/blackcore/airspacemonitor.h @@ -391,9 +391,6 @@ namespace BlackCore void onAircraftConfigReceived(const BlackMisc::Aviation::CCallsign &callsign, const QJsonObject &jsonObject, qint64 currentOffsetMs); void onAircraftInterimUpdateReceived(const BlackMisc::Aviation::CAircraftSituation &situation); void onConnectionStatusChanged(BlackMisc::Network::CConnectionStatus oldStatus, BlackMisc::Network::CConnectionStatus newStatus); - - //! \deprecated - void onAtisVoiceRoomReceived(const BlackMisc::Aviation::CCallsign &callsign, const QString &url); }; } // namespace diff --git a/src/blackcore/fsd/deletepilot.cpp b/src/blackcore/fsd/deletepilot.cpp index ab8d17f94..ff5fdbc8f 100644 --- a/src/blackcore/fsd/deletepilot.cpp +++ b/src/blackcore/fsd/deletepilot.cpp @@ -7,9 +7,10 @@ */ #include "deletepilot.h" - #include "blackmisc/logmessage.h" +using namespace BlackMisc; + namespace BlackCore { namespace Fsd @@ -34,9 +35,10 @@ namespace BlackCore { if (tokens.size() < 1) { - BlackMisc::CLogMessage(static_cast(nullptr)).debug(u"Wrong number of arguments."); + CLogMessage(static_cast(nullptr)).debug(u"Wrong number of arguments."); return {}; - }; + } + // VATSIM FSD will always supply the CERTIFICATE ID when it rebroadcasts this PDU without regard for whether // the client originally specified it. But other FSDs might not. DeletePilot packet(tokens[0], (tokens.size() >= 2) ? tokens[1] : ""); diff --git a/src/plugins/simulator/fs9/lobbyclient.cpp b/src/plugins/simulator/fs9/lobbyclient.cpp index 00abd9ee0..09b82761c 100644 --- a/src/plugins/simulator/fs9/lobbyclient.cpp +++ b/src/plugins/simulator/fs9/lobbyclient.cpp @@ -14,7 +14,9 @@ #include "directplayutils.h" #include "fs9.h" #include "lobbyclient.h" + #include "blackmisc/logmessage.h" + #include #include #include @@ -22,6 +24,8 @@ #include #include +using namespace BlackMisc; + namespace BlackSimPlugin { namespace Fs9 @@ -90,20 +94,20 @@ namespace BlackSimPlugin bool CLobbyClient::canLobbyConnect() { if (!m_dpLobbyClient) { return false; } - GUID appGuid = CFs9Sdk::guid(); - DWORD dwSize = 0; + GUID appGuid = CFs9Sdk::guid(); + DWORD dwSize = 0; DWORD dwItems = 0; - HRESULT hr = m_dpLobbyClient->EnumLocalPrograms(&appGuid, nullptr, &dwSize, &dwItems, 0); + const HRESULT hr = m_dpLobbyClient->EnumLocalPrograms(&appGuid, nullptr, &dwSize, &dwItems, 0); if (hr == DPNERR_BUFFERTOOSMALL) { - QScopedArrayPointer memPtr (new BYTE[dwSize]); + QScopedArrayPointer memPtr(new BYTE[dwSize]); DPL_APPLICATION_INFO *appInfo = reinterpret_cast(memPtr.data()); m_dpLobbyClient->EnumLocalPrograms(&appGuid, memPtr.data(), &dwSize, &dwItems, 0); if (dwItems > 0) { - BlackMisc::CLogMessage(this).debug() << "Found lobby application:" << QString::fromWCharArray(appInfo->pwszApplicationName);; + CLogMessage(this).debug() << "Found lobby application:" << QString::fromWCharArray(appInfo->pwszApplicationName); return true; } else @@ -133,23 +137,20 @@ namespace BlackSimPlugin dnConnectInfo.guidApplication = pAppGuid; if (FAILED(hr = allocAndInitConnectSettings(address, &pAppGuid, &dnConnectInfo.pdplConnectionSettings))) + { return S_FALSE; + } hr = m_dpLobbyClient->ConnectApplication(&dnConnectInfo, nullptr, &m_applicationHandle, INFINITE, 0); - if (FAILED(hr)) - { - return hr; - } - else - { - qDebug() << "Connected!"; - freeConnectSettings(dnConnectInfo.pdplConnectionSettings); - return S_OK; - } + if (FAILED(hr)) { return hr; } + + CLogMessage(this).info(u"Lobby client '%1' connected!") << address; + freeConnectSettings(dnConnectInfo.pdplConnectionSettings); + return S_OK; } HRESULT CLobbyClient::allocAndInitConnectSettings(const QString &address, GUID *pAppGuid, DPL_CONNECTION_SETTINGS **ppdplConnectSettings) @@ -269,7 +270,7 @@ namespace BlackSimPlugin { PDPL_MESSAGE_DISCONNECT pDisconnectMsg; pDisconnectMsg = (PDPL_MESSAGE_DISCONNECT)msgBuffer; - Q_UNUSED(pDisconnectMsg); + Q_UNUSED(pDisconnectMsg) emit disconnected(); @@ -312,10 +313,11 @@ namespace BlackSimPlugin case DPLSESSION_HOSTMIGRATEDHERE: message.append("Host migrated to this client"); break; default: - message.append(QString("Unknown PDPL_MESSAGE_SESSION_STATUS: %1").arg(pStatusMsg->dwStatus)); + message.append(QStringLiteral("Unknown PDPL_MESSAGE_SESSION_STATUS: %1").arg(pStatusMsg->dwStatus)); break; } - qDebug() << message; + + CLogMessage(this).info(message); break; }