From 61a23d700ba4b288c79a6a05b7b92620444025c9 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Mon, 9 Oct 2017 17:37:20 +0200 Subject: [PATCH] Ref T171, driver formatting --- src/blackcore/application.h | 2 +- src/blackcore/simulatorcommon.cpp | 82 +++++++++---------- src/blackcore/simulatorcommon.h | 6 +- .../interpolationrenderingsetup.cpp | 30 +++---- src/plugins/simulator/fs9/fs9client.cpp | 2 +- src/plugins/simulator/fs9/fs9client.h | 3 +- src/plugins/simulator/fs9/simulatorfs9.cpp | 16 ++-- .../simulator/fscommon/simulatorfscommon.cpp | 34 ++++---- .../simulator/fsxcommon/simconnectobject.cpp | 6 +- .../simulator/fsxcommon/simconnectobject.h | 4 +- .../fsxcommon/simulatorfsxcommon.cpp | 56 ++++++------- .../simulator/fsxcommon/simulatorfsxcommon.h | 1 + .../fsxcommon/simulatorfsxsimconnectproc.cpp | 15 ++-- 13 files changed, 126 insertions(+), 131 deletions(-) diff --git a/src/blackcore/application.h b/src/blackcore/application.h index 9b1c9a9ff..d9291f5a2 100644 --- a/src/blackcore/application.h +++ b/src/blackcore/application.h @@ -220,7 +220,7 @@ namespace BlackCore const char *swiftVersionChar(); //! Running in dev.environment? - bool isRunningInDeveloperEnvironment() const { return this->m_devEnv; } + bool isRunningInDeveloperEnvironment() const { return m_devEnv; } //! Signal startup automatically or individually void setSignalStartupAutomatically(bool enabled); diff --git a/src/blackcore/simulatorcommon.cpp b/src/blackcore/simulatorcommon.cpp index 79fd073ca..f194cb04e 100644 --- a/src/blackcore/simulatorcommon.cpp +++ b/src/blackcore/simulatorcommon.cpp @@ -57,7 +57,7 @@ namespace BlackCore // provider signals, hook up with remote aircraft provider m_remoteAircraftProviderConnections.append( - this->m_remoteAircraftProvider->connectRemoteAircraftProviderSignals( + m_remoteAircraftProvider->connectRemoteAircraftProviderSignals( this, // receiver must match object in bind std::bind(&CSimulatorCommon::ps_remoteProviderAddAircraftSituation, this, std::placeholders::_1), std::bind(&CSimulatorCommon::ps_remoteProviderAddAircraftParts, this, std::placeholders::_1, std::placeholders::_2), @@ -102,7 +102,7 @@ namespace BlackCore // if not restriced, directly change if (!renderingRestricted) { this->physicallyAddRemoteAircraft(remoteAircraft); return true; } - // restricted -> will be added with next snapshot ps_recalculateRenderedAircraft + // restricted -> will be added with next snapshot onRecalculatedRenderedAircraft return false; } @@ -135,7 +135,7 @@ namespace BlackCore if (QDateTime::currentMSecsSinceEpoch() < m_highlightEndTimeMsEpoch) { // blink mode, toggle aircraft - for (const CSimulatedAircraft &aircraft : m_highlightedAircraft) + for (const CSimulatedAircraft &aircraft : as_const(m_highlightedAircraft)) { if (m_blinkCycle) { @@ -150,12 +150,12 @@ namespace BlackCore else { // restore - for (const CSimulatedAircraft &aircraft : m_highlightedAircraft) + for (const CSimulatedAircraft &aircraft : as_const(m_highlightedAircraft)) { // get the current state for this aircraft // it might has been removed in the meantime const CCallsign cs(aircraft.getCallsign()); - resetAircraftFromProvider(cs); + this->resetAircraftFromProvider(cs); } m_highlightedAircraft.clear(); m_highlightEndTimeMsEpoch = 0; @@ -164,8 +164,8 @@ namespace BlackCore void CSimulatorCommon::resetAircraftFromProvider(const CCallsign &callsign) { - CSimulatedAircraft aircraft(this->getAircraftInRangeForCallsign(callsign)); - bool enabled = aircraft.isEnabled(); + const CSimulatedAircraft aircraft(this->getAircraftInRangeForCallsign(callsign)); + const bool enabled = aircraft.isEnabled(); if (enabled) { // are we already visible? @@ -187,7 +187,7 @@ namespace BlackCore if (!CWeatherScenario::isRealWeatherScenario(selectedWeatherScenario)) { m_lastWeatherPosition = {}; - injectWeatherGrid(CWeatherGrid::getByScenario(selectedWeatherScenario)); + this->injectWeatherGrid(CWeatherGrid::getByScenario(selectedWeatherScenario)); } } @@ -274,7 +274,7 @@ namespace BlackCore if (!CWeatherScenario::isRealWeatherScenario(selectedWeatherScenario)) { m_lastWeatherPosition = {}; - injectWeatherGrid(CWeatherGrid::getByScenario(selectedWeatherScenario)); + this->injectWeatherGrid(CWeatherGrid::getByScenario(selectedWeatherScenario)); } } } @@ -288,17 +288,17 @@ namespace BlackCore void CSimulatorCommon::ps_allSwiftDataRead() { - // void + // void, can be overridden in specialized drivers } void CSimulatorCommon::ps_modelMatchingEntities() { - // void + // void, can be overridden in specialized drivers } void CSimulatorCommon::ps_airportsRead() { - // void + // void, can be overridden in specialized drivers } CAircraftModel CSimulatorCommon::getDefaultModel() const @@ -319,7 +319,7 @@ namespace BlackCore void CSimulatorCommon::unload() { this->disconnectFrom(); // disconnect from simulator - this->m_remoteAircraftProviderConnections.disconnectAll(); // disconnect signals from provider + m_remoteAircraftProviderConnections.disconnectAll(); // disconnect signals from provider } bool CSimulatorCommon::isShuttingDown() const @@ -330,9 +330,9 @@ namespace BlackCore void CSimulatorCommon::setInterpolationAndRenderingSetup(const CInterpolationAndRenderingSetup &setup) { { - QWriteLocker lock(&this->m_interpolationRenderingSetupMutex); - if (this->m_interpolationRenderingSetup == setup) { return; } - this->m_interpolationRenderingSetup = setup; + QWriteLocker lock(&m_interpolationRenderingSetupMutex); + if (m_interpolationRenderingSetup == setup) { return; } + m_interpolationRenderingSetup = setup; } const bool r = setup.isRenderingRestricted(); @@ -343,19 +343,19 @@ namespace BlackCore CInterpolationAndRenderingSetup CSimulatorCommon::getInterpolationAndRenderingSetup() const { - QReadLocker lock(&this->m_interpolationRenderingSetupMutex); + QReadLocker lock(&m_interpolationRenderingSetupMutex); return m_interpolationRenderingSetup; } void CSimulatorCommon::highlightAircraft(const BlackMisc::Simulation::CSimulatedAircraft &aircraftToHighlight, bool enableHighlight, const BlackMisc::PhysicalQuantities::CTime &displayTime) { const CCallsign cs(aircraftToHighlight.getCallsign()); - this->m_highlightedAircraft.removeByCallsign(cs); + m_highlightedAircraft.removeByCallsign(cs); if (enableHighlight) { const qint64 deltaT = displayTime.valueRounded(CTimeUnit::ms(), 0); - this->m_highlightEndTimeMsEpoch = QDateTime::currentMSecsSinceEpoch() + deltaT; - this->m_highlightedAircraft.push_back(aircraftToHighlight); + m_highlightEndTimeMsEpoch = QDateTime::currentMSecsSinceEpoch() + deltaT; + m_highlightedAircraft.push_back(aircraftToHighlight); } } @@ -364,7 +364,7 @@ namespace BlackCore int removed = 0; for (const CCallsign &callsign : callsigns) { - physicallyRemoveRemoteAircraft(callsign); + this->physicallyRemoveRemoteAircraft(callsign); removed++; } return removed; @@ -395,23 +395,23 @@ namespace BlackCore const QString part2 = parser.part(2).toLower(); if (part2 == "off" || part2 == "false") { - this->m_interpolationRenderingSetup.clearInterpolatorLogCallsigns(); + m_interpolationRenderingSetup.clearInterpolatorLogCallsigns(); CStatusMessage(this).info("Disabled interpolation logging"); return true; } if (part2 == "clear" || part2 == "clr") { - this->m_interpolationLogger.clearLog(); + m_interpolationLogger.clearLog(); CStatusMessage(this).info("Cleared interpolation logging"); return true; } if (part2 == "write" || part2 == "save") { - // stop logging - this->m_interpolationRenderingSetup.clearInterpolatorLogCallsigns(); + // stop logging of other log + m_interpolationRenderingSetup.clearInterpolatorLogCallsigns(); // write - this->m_interpolationLogger.writeLogInBackground(); + m_interpolationLogger.writeLogInBackground(); CLogMessage(this).info("Started writing interpolation log"); return true; } @@ -420,7 +420,7 @@ namespace BlackCore if (!CCallsign::isValidAircraftCallsign(cs)) { return false; } if (this->getAircraftInRangeCallsigns().contains(cs)) { - this->m_interpolationRenderingSetup.addCallsignToLog(CCallsign(cs)); + m_interpolationRenderingSetup.addCallsignToLog(CCallsign(cs)); CLogMessage(this).info("Will log interpolation for '%1'") << cs; return true; } @@ -433,7 +433,7 @@ namespace BlackCore if (part1.startsWith("spline") || part1.startsWith("linear")) { - CCallsign cs(parser.hasPart(2) ? parser.part(2) : ""); + const CCallsign cs(parser.hasPart(2) ? parser.part(2) : ""); const bool changed = this->setInterpolatorMode(CInterpolatorMulti::modeFromString(part1), cs); if (changed) { @@ -452,18 +452,18 @@ namespace BlackCore void CSimulatorCommon::registerHelp() { - if (BlackMisc::CSimpleCommandParser::registered("BlackCore::CSimulatorCommon")) { return; } - BlackMisc::CSimpleCommandParser::registerCommand({".drv", "alias: .driver .plugin"}); - BlackMisc::CSimpleCommandParser::registerCommand({".drv logint callsign", "log interpolator for callsign"}); - BlackMisc::CSimpleCommandParser::registerCommand({".drv logint off", "no log information for interpolator"}); - BlackMisc::CSimpleCommandParser::registerCommand({".drv logint write", "write interpolator log to file"}); - BlackMisc::CSimpleCommandParser::registerCommand({".drv logint clear", "clear current log"}); - BlackMisc::CSimpleCommandParser::registerCommand({".drv spline|linear ", "set spline/linear interpolator for one/all callsign(s)"}); + if (CSimpleCommandParser::registered("BlackCore::CSimulatorCommon")) { return; } + CSimpleCommandParser::registerCommand({".drv", "alias: .driver .plugin"}); + CSimpleCommandParser::registerCommand({".drv logint callsign", "log interpolator for callsign"}); + CSimpleCommandParser::registerCommand({".drv logint off", "no log information for interpolator"}); + CSimpleCommandParser::registerCommand({".drv logint write", "write interpolator log to file"}); + CSimpleCommandParser::registerCommand({".drv logint clear", "clear current log"}); + CSimpleCommandParser::registerCommand({".drv spline|linear ", "set spline/linear interpolator for one/all callsign(s)"}); } void CSimulatorCommon::ps_oneSecondTimer() { - blinkHighlightedAircraft(); + this->blinkHighlightedAircraft(); } void CSimulatorCommon::ps_recalculateRenderedAircraft(const CAirspaceAircraftSnapshot &snapshot) @@ -481,9 +481,9 @@ namespace BlackCore bool changed = false; if (snapshot.isRenderingEnabled()) { - CCallsignSet callsignsInSimulator(physicallyRenderedAircraft()); // state in simulator - CCallsignSet callsignsToBeRemoved(callsignsInSimulator.difference(snapshot.getEnabledAircraftCallsignsByDistance())); - CCallsignSet callsignsToBeAdded(snapshot.getEnabledAircraftCallsignsByDistance().difference(callsignsInSimulator)); + const CCallsignSet callsignsInSimulator(this->physicallyRenderedAircraft()); // state in simulator + const CCallsignSet callsignsToBeRemoved(callsignsInSimulator.difference(snapshot.getEnabledAircraftCallsignsByDistance())); + const CCallsignSet callsignsToBeAdded(snapshot.getEnabledAircraftCallsignsByDistance().difference(callsignsInSimulator)); if (!callsignsToBeRemoved.isEmpty()) { const int r = this->physicallyRemoveMultipleRemoteAircraft(callsignsToBeRemoved); @@ -492,7 +492,7 @@ namespace BlackCore if (!callsignsToBeAdded.isEmpty()) { - CSimulatedAircraftList aircraftToBeAdded(getAircraftInRange().findByCallsigns(callsignsToBeAdded)); // thread safe copy + CSimulatedAircraftList aircraftToBeAdded(this->getAircraftInRange().findByCallsigns(callsignsToBeAdded)); // thread safe copy for (const CSimulatedAircraft &aircraft : aircraftToBeAdded) { Q_ASSERT_X(aircraft.isEnabled(), Q_FUNC_INFO, "Disabled aircraft detected as to be added"); @@ -512,7 +512,7 @@ namespace BlackCore // we have handled snapshot if (changed) { - emit airspaceSnapshotHandled(); + emit this->airspaceSnapshotHandled(); } } diff --git a/src/blackcore/simulatorcommon.h b/src/blackcore/simulatorcommon.h index f756f7b8c..61d887b25 100644 --- a/src/blackcore/simulatorcommon.h +++ b/src/blackcore/simulatorcommon.h @@ -95,7 +95,7 @@ namespace BlackCore //! .drv logint off no log information for interpolator BlackCore::CSimulatorCommon //! .drv logint write write interpolator log to file BlackCore::CSimulatorCommon //! .drv logint clear clear current log BlackCore::CSimulatorCommon - //! .drv spline|linear callsign interpolator spline BlackCore::CSimulatorCommon + //! .drv spline|linear callsign interpolator spline or linear BlackCore::CSimulatorCommon //! //! @} //! \copydoc ISimulator::parseCommandLine @@ -142,7 +142,7 @@ namespace BlackCore BlackMisc::Weather::IWeatherGridProvider *weatherGridProvider, QObject *parent); - //! \name Interface implementations + //! \name Interface implementations, called from context //! @{ virtual bool logicallyAddRemoteAircraft(const BlackMisc::Simulation::CSimulatedAircraft &remoteAircraft) override; virtual bool logicallyRemoveRemoteAircraft(const BlackMisc::Aviation::CCallsign &callsign) override; @@ -225,7 +225,7 @@ namespace BlackCore bool m_blinkCycle = false; //!< used for highlighting qint64 m_highlightEndTimeMsEpoch = 0; //!< end highlighting int m_timerCounter = 0; //!< allows to calculate n seconds - QTimer m_oneSecondTimer {this}; //!< multi purpose timer + QTimer m_oneSecondTimer { this }; //!< multi purpose timer BlackMisc::Simulation::CSimulatorPluginInfo m_simulatorPluginInfo; //!< info object BlackMisc::Simulation::CSimulatedAircraftList m_highlightedAircraft; //!< all other aircraft are to be ignored BlackMisc::Aviation::CCallsignSet m_callsignsToBeRendered; //!< callsigns which will be rendered diff --git a/src/blackmisc/simulation/interpolationrenderingsetup.cpp b/src/blackmisc/simulation/interpolationrenderingsetup.cpp index 8d23c6228..a9de4ccf6 100644 --- a/src/blackmisc/simulation/interpolationrenderingsetup.cpp +++ b/src/blackmisc/simulation/interpolationrenderingsetup.cpp @@ -38,7 +38,7 @@ namespace BlackMisc bool CInterpolationAndRenderingSetup::isAircraftPartsEnabled() const { - return this->m_enabledAircraftParts; + return m_enabledAircraftParts; } int CInterpolationAndRenderingSetup::getMaxRenderedAircraft() const @@ -88,7 +88,7 @@ namespace BlackMisc bool CInterpolationAndRenderingSetup::setEnabledAircraftParts(bool enabled) { - if (this->m_enabledAircraftParts == enabled) { return false; } + if (m_enabledAircraftParts == enabled) { return false; } m_enabledAircraftParts = enabled; return true; } @@ -105,14 +105,14 @@ namespace BlackMisc void CInterpolationAndRenderingSetup::clearAllRenderingRestrictions() { - this->m_maxRenderedDistance = CLength(0, nullptr); - this->m_maxRenderedAircraft = InfiniteAircraft(); + m_maxRenderedDistance = CLength(0, nullptr); + m_maxRenderedAircraft = InfiniteAircraft(); } void CInterpolationAndRenderingSetup::disableRendering() { - this->m_maxRenderedAircraft = 0; - this->m_maxRenderedDistance = CLength(0, CLengthUnit::NM()); // zero distance + m_maxRenderedAircraft = 0; + m_maxRenderedDistance = CLength(0, CLengthUnit::NM()); // zero distance } bool CInterpolationAndRenderingSetup::isMaxDistanceRestricted() const @@ -160,11 +160,11 @@ namespace BlackMisc { Q_UNUSED(i18n); QString s("Setup: debug sim: "); - s += boolToYesNo(this->m_simulatorDebugMessages); + s += boolToYesNo(m_simulatorDebugMessages); s += " debug interpolator: "; - s += boolToYesNo(this->m_interpolatorDebugMessage); + s += boolToYesNo(m_interpolatorDebugMessage); s += " force full interpolation: "; - s += boolToYesNo(this->m_forceFullInterpolation); + s += boolToYesNo(m_forceFullInterpolation); s += " max.aircraft:"; s += QString::number(m_maxRenderedAircraft); s += " max.distance:"; @@ -206,22 +206,22 @@ namespace BlackMisc switch (i) { case IndexInterpolatorDebugMessages: - this->m_interpolatorDebugMessage = variant.toBool(); + m_interpolatorDebugMessage = variant.toBool(); break; case IndexSimulatorDebugMessages: - this->m_simulatorDebugMessages = variant.toBool(); + m_simulatorDebugMessages = variant.toBool(); break; case IndexForceFullInterpolation: - this->m_forceFullInterpolation = variant.toBool(); + m_forceFullInterpolation = variant.toBool(); break; case IndexMaxRenderedAircraft: - this->m_maxRenderedAircraft = variant.toInt(); + m_maxRenderedAircraft = variant.toInt(); break; case IndexMaxRenderedDistance: - this->m_maxRenderedDistance = variant.value(); + m_maxRenderedDistance = variant.value(); break; case IndexEnabledAircraftParts: - this->m_enabledAircraftParts = variant.toBool(); + m_enabledAircraftParts = variant.toBool(); break; default: CValueObject::setPropertyByIndex(index, variant); diff --git a/src/plugins/simulator/fs9/fs9client.cpp b/src/plugins/simulator/fs9/fs9client.cpp index ed306ebbf..94c6dcf22 100644 --- a/src/plugins/simulator/fs9/fs9client.cpp +++ b/src/plugins/simulator/fs9/fs9client.cpp @@ -186,7 +186,7 @@ namespace BlackSimPlugin CInterpolationStatus status; CInterpolationHints hints; // \fixme 201701 #865 KB if there is an elevation provider for FS9 add it here or set elevation hints.setLoggingInterpolation(this->getInterpolationSetup().getLogCallsigns().contains(m_callsign)); - const CAircraftSituation situation = this->m_interpolator.getInterpolatedSituation(-1, this->m_interpolationSetup, hints, status); + const CAircraftSituation situation = m_interpolator.getInterpolatedSituation(-1, m_interpolationSetup, hints, status); // Test only for successful interpolation. FS9 requires constant positions if (!status.didInterpolationSucceed()) { return; } diff --git a/src/plugins/simulator/fs9/fs9client.h b/src/plugins/simulator/fs9/fs9client.h index 7389acaf6..ed90cc539 100644 --- a/src/plugins/simulator/fs9/fs9client.h +++ b/src/plugins/simulator/fs9/fs9client.h @@ -25,7 +25,6 @@ namespace BlackSimPlugin { namespace Fs9 { - //! Class faking a FS9 multiplayer client connection class CFs9Client : public CDirectPlayPeer { @@ -111,4 +110,4 @@ namespace BlackSimPlugin Q_DECLARE_METATYPE(BlackSimPlugin::Fs9::CFs9Client::ClientStatus) -#endif // DIRECTPLAY_CLIENT_H +#endif // guard diff --git a/src/plugins/simulator/fs9/simulatorfs9.cpp b/src/plugins/simulator/fs9/simulatorfs9.cpp index f8bb5585c..fdd0078c8 100644 --- a/src/plugins/simulator/fs9/simulatorfs9.cpp +++ b/src/plugins/simulator/fs9/simulatorfs9.cpp @@ -208,7 +208,7 @@ namespace BlackSimPlugin int CSimulatorFs9::physicallyRemoveAllRemoteAircraft() { if (m_hashFs9Clients.isEmpty()) { return 0; } - QList callsigns(this->m_hashFs9Clients.keys()); + QList callsigns(m_hashFs9Clients.keys()); int r = 0; for (const CCallsign &cs : callsigns) { @@ -234,31 +234,31 @@ namespace BlackSimPlugin const CTransponder newTransponder = ownAircraft.getTransponder(); bool changed = false; - if (newCom1.getFrequencyActive() != this->m_simCom1.getFrequencyActive()) + if (newCom1.getFrequencyActive() != m_simCom1.getFrequencyActive()) { changed = true; } - if (newCom1.getFrequencyStandby() != this->m_simCom1.getFrequencyStandby()) + if (newCom1.getFrequencyStandby() != m_simCom1.getFrequencyStandby()) { changed = true; } - if (newCom2.getFrequencyActive() != this->m_simCom2.getFrequencyActive()) + if (newCom2.getFrequencyActive() != m_simCom2.getFrequencyActive()) { changed = true; } - if (newCom2.getFrequencyStandby() != this->m_simCom2.getFrequencyStandby()) + if (newCom2.getFrequencyStandby() != m_simCom2.getFrequencyStandby()) { changed = true; } - if (newTransponder.getTransponderCode() != this->m_simTransponder.getTransponderCode()) + if (newTransponder.getTransponderCode() != m_simTransponder.getTransponderCode()) { changed = true; } - if (newTransponder.getTransponderMode() != this->m_simTransponder.getTransponderMode()) + if (newTransponder.getTransponderMode() != m_simTransponder.getTransponderMode()) { changed = true; } @@ -275,7 +275,7 @@ namespace BlackSimPlugin if (!this->isSimulating()) { return false; } bool changed = false; - if (selcal != this->m_selcal) + if (selcal != m_selcal) { changed = true; } diff --git a/src/plugins/simulator/fscommon/simulatorfscommon.cpp b/src/plugins/simulator/fscommon/simulatorfscommon.cpp index c4b0b0ba9..6fd380d13 100644 --- a/src/plugins/simulator/fscommon/simulatorfscommon.cpp +++ b/src/plugins/simulator/fscommon/simulatorfscommon.cpp @@ -43,16 +43,16 @@ namespace BlackSimPlugin void CSimulatorFsCommon::initSimulatorInternals() { CSimulatorInternals s; - s.setSimulatorName(this->m_simulatorName); - s.setSimulatorVersion(this->m_simulatorVersion); - s.setValue("fscommon/fsuipc", boolToOnOff(this->m_useFsuipc)); - if (this->m_fsuipc) + s.setSimulatorName(m_simulatorName); + s.setSimulatorVersion(m_simulatorVersion); + s.setValue("fscommon/fsuipc", boolToOnOff(m_useFsuipc)); + if (m_fsuipc) { - const QString v(this->m_fsuipc->getVersion()); + const QString v(m_fsuipc->getVersion()); if (!v.isEmpty()) { s.setValue("fscommon/fsuipcversion", v); } - s.setValue("fscommon/fsuipcconnect", boolToYesNo(this->m_fsuipc->isConnected())); + s.setValue("fscommon/fsuipcconnect", boolToYesNo(m_fsuipc->isConnected())); } - this->m_simulatorInternals = s; + m_simulatorInternals = s; } bool CSimulatorFsCommon::parseDetails(const CSimpleCommandParser &parser) @@ -69,14 +69,14 @@ namespace BlackSimPlugin void CSimulatorFsCommon::registerHelp() { - if (BlackMisc::CSimpleCommandParser::registered("BlackSimPlugin::FsCommon::CSimulatorFsCommon")) { return; } - BlackMisc::CSimpleCommandParser::registerCommand({".drv", "alias: .driver .plugin"}); - BlackMisc::CSimpleCommandParser::registerCommand({".drv fsuipc on|off", "FSUIPC on|off if applicable"}); + if (CSimpleCommandParser::registered("BlackSimPlugin::FsCommon::CSimulatorFsCommon")) { return; } + CSimpleCommandParser::registerCommand({".drv", "alias: .driver .plugin"}); + CSimpleCommandParser::registerCommand({".drv fsuipc on|off", "FSUIPC on|off if applicable"}); } bool CSimulatorFsCommon::disconnectFrom() { - if (this->m_fsuipc) { this->m_fsuipc->disconnect(); } + if (m_fsuipc) { m_fsuipc->disconnect(); } // reset flags m_simPaused = false; @@ -109,10 +109,10 @@ namespace BlackSimPlugin return m_syncTimeOffset; } - bool CSimulatorFsCommon::setTimeSynchronization(bool enable, const BlackMisc::PhysicalQuantities::CTime &offset) + bool CSimulatorFsCommon::setTimeSynchronization(bool enable, const PhysicalQuantities::CTime &offset) { - this->m_simTimeSynced = enable; - this->m_syncTimeOffset = offset; + m_simTimeSynced = enable; + m_syncTimeOffset = offset; return true; } @@ -128,8 +128,8 @@ namespace BlackSimPlugin bool CSimulatorFsCommon::changeRemoteAircraftModel(const CSimulatedAircraft &aircraft) { // remove upfront, and then enable / disable again - const auto callsign = aircraft.getCallsign(); - if (!isPhysicallyRenderedAircraft(callsign)) { return false; } + const CCallsign callsign = aircraft.getCallsign(); + if (!this->isPhysicallyRenderedAircraft(callsign)) { return false; } this->physicallyRemoveRemoteAircraft(callsign); return this->changeRemoteAircraftEnabled(aircraft); } @@ -152,7 +152,7 @@ namespace BlackSimPlugin const CAirportList webServiceAirports = this->getWebServiceAirports(); if (!webServiceAirports.isEmpty()) { - this->m_airportsInRangeFromSimulator.updateMissingParts(webServiceAirports); + m_airportsInRangeFromSimulator.updateMissingParts(webServiceAirports); } CSimulatorCommon::ps_airportsRead(); } diff --git a/src/plugins/simulator/fsxcommon/simconnectobject.cpp b/src/plugins/simulator/fsxcommon/simconnectobject.cpp index 4a0b36820..1a6982a8a 100644 --- a/src/plugins/simulator/fsxcommon/simconnectobject.cpp +++ b/src/plugins/simulator/fsxcommon/simconnectobject.cpp @@ -50,7 +50,7 @@ namespace BlackSimPlugin bool CSimConnectObject::isPendingAdded() const { - return !this->hasValidRequestAndObjectId() || !this->m_confirmedAdded; + return !this->hasValidRequestAndObjectId() || !m_confirmedAdded; } bool CSimConnectObject::isConfirmedAdded() const @@ -79,13 +79,13 @@ namespace BlackSimPlugin void CSimConnectObject::toggleInterpolatorMode() { Q_ASSERT(m_interpolator); - this->m_interpolator->toggleMode(); + m_interpolator->toggleMode(); } bool CSimConnectObject::setInterpolatorMode(CInterpolatorMulti::Mode mode) { Q_ASSERT(m_interpolator); - return this->m_interpolator->setMode(mode); + return m_interpolator->setMode(mode); } bool CSimConnectObjects::setSimConnectObjectIdForRequestId(DWORD requestId, DWORD objectId, bool resetSentParts) diff --git a/src/plugins/simulator/fsxcommon/simconnectobject.h b/src/plugins/simulator/fsxcommon/simconnectobject.h index dd376e66c..c4d88a8c6 100644 --- a/src/plugins/simulator/fsxcommon/simconnectobject.h +++ b/src/plugins/simulator/fsxcommon/simconnectobject.h @@ -97,10 +97,10 @@ namespace BlackSimPlugin DWORD getObjectId() const { return m_objectId; } //! Valid request id? - bool hasValidRequestId() const { return this->m_validRequestId; } + bool hasValidRequestId() const { return m_validRequestId; } //! Valid object id? - bool hasValidObjectId() const { return this->m_validObjectId; } + bool hasValidObjectId() const { return m_validObjectId; } //! Object is requested, not yet added bool isPendingAdded() const; diff --git a/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp b/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp index bcd015a32..d25981b20 100644 --- a/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp +++ b/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp @@ -89,7 +89,7 @@ namespace BlackSimPlugin // reset state as expected for unconnected return false; } - if (m_useFsuipc) { this->m_fsuipc->connect(); } // FSUIPC too + if (m_useFsuipc) { m_fsuipc->connect(); } // FSUIPC too // set structures and move on initEvents(); @@ -135,7 +135,7 @@ namespace BlackSimPlugin const CTransponder newTransponder = ownAircraft.getTransponder(); bool changed = false; - if (newCom1.getFrequencyActive() != this->m_simCom1.getFrequencyActive()) + if (newCom1.getFrequencyActive() != m_simCom1.getFrequencyActive()) { const CFrequency newFreq = newCom1.getFrequencyActive(); SimConnect_TransmitClientEvent(m_hSimConnect, 0, EventSetCom1Active, @@ -143,7 +143,7 @@ namespace BlackSimPlugin changed = true; } - if (newCom1.getFrequencyStandby() != this->m_simCom1.getFrequencyStandby()) + if (newCom1.getFrequencyStandby() != m_simCom1.getFrequencyStandby()) { const CFrequency newFreq = newCom1.getFrequencyStandby(); SimConnect_TransmitClientEvent(m_hSimConnect, 0, EventSetCom1Standby, @@ -151,14 +151,14 @@ namespace BlackSimPlugin changed = true; } - if (newCom2.getFrequencyActive() != this->m_simCom2.getFrequencyActive()) + if (newCom2.getFrequencyActive() != m_simCom2.getFrequencyActive()) { const CFrequency newFreq = newCom2.getFrequencyActive(); SimConnect_TransmitClientEvent(m_hSimConnect, 0, EventSetCom2Active, CBcdConversions::comFrequencyToBcdHz(newFreq), SIMCONNECT_GROUP_PRIORITY_HIGHEST, SIMCONNECT_EVENT_FLAG_GROUPID_IS_PRIORITY); changed = true; } - if (newCom2.getFrequencyStandby() != this->m_simCom2.getFrequencyStandby()) + if (newCom2.getFrequencyStandby() != m_simCom2.getFrequencyStandby()) { const CFrequency newFreq = newCom2.getFrequencyStandby(); SimConnect_TransmitClientEvent(m_hSimConnect, 0, EventSetCom2Standby, @@ -166,14 +166,14 @@ namespace BlackSimPlugin changed = true; } - if (newTransponder.getTransponderCode() != this->m_simTransponder.getTransponderCode()) + if (newTransponder.getTransponderCode() != m_simTransponder.getTransponderCode()) { SimConnect_TransmitClientEvent(m_hSimConnect, 0, EventSetTransponderCode, CBcdConversions::transponderCodeToBcd(newTransponder), SIMCONNECT_GROUP_PRIORITY_HIGHEST, SIMCONNECT_EVENT_FLAG_GROUPID_IS_PRIORITY); changed = true; } - if (newTransponder.getTransponderMode() != this->m_simTransponder.getTransponderMode()) + if (newTransponder.getTransponderMode() != m_simTransponder.getTransponderMode()) { if (m_useSbOffsets) { @@ -233,15 +233,15 @@ namespace BlackSimPlugin bool CSimulatorFsxCommon::isPhysicallyRenderedAircraft(const CCallsign &callsign) const { - return this->m_simConnectObjects.contains(callsign); + return m_simConnectObjects.contains(callsign); } CCallsignSet CSimulatorFsxCommon::physicallyRenderedAircraft() const { - CCallsignSet callsigns(this->m_simConnectObjects.keys()); + CCallsignSet callsigns(m_simConnectObjects.keys()); callsigns.push_back(m_aircraftToAddAgainWhenRemoved.getCallsigns()); // not really rendered right now, but very soon callsigns.push_back(m_addPendingAircraft.getCallsigns()); // not really rendered, but for the logic it should look like it is - return CCallsignSet(this->m_simConnectObjects.keys()); + return CCallsignSet(m_simConnectObjects.keys()); } bool CSimulatorFsxCommon::setInterpolatorMode(CInterpolatorMulti::Mode mode, const CCallsign &callsign) @@ -416,12 +416,12 @@ namespace BlackSimPlugin com1.setFrequencyActive(CFrequency(simulatorOwnAircraft.com1ActiveMHz, CFrequencyUnit::MHz())); com1.setFrequencyStandby(CFrequency(simulatorOwnAircraft.com1StandbyMHz, CFrequencyUnit::MHz())); const bool changedCom1 = myAircraft.getCom1System() != com1; - this->m_simCom1 = com1; + m_simCom1 = com1; com2.setFrequencyActive(CFrequency(simulatorOwnAircraft.com2ActiveMHz, CFrequencyUnit::MHz())); com2.setFrequencyStandby(CFrequency(simulatorOwnAircraft.com2StandbyMHz, CFrequencyUnit::MHz())); const bool changedCom2 = myAircraft.getCom2System() != com2; - this->m_simCom2 = com2; + m_simCom2 = com2; transponder.setTransponderCode(simulatorOwnAircraft.transponderCode); const bool changedXpr = (myAircraft.getTransponderCode() != transponder.getTransponderCode()); @@ -502,7 +502,7 @@ namespace BlackSimPlugin bool CSimulatorFsxCommon::simulatorReportedObjectAdded(DWORD objectId) { - const CSimConnectObject simObject = this->m_simConnectObjects.getSimObjectForObjectId(objectId); + const CSimConnectObject simObject = m_simConnectObjects.getSimObjectForObjectId(objectId); const CCallsign callsign(simObject.getCallsign()); if (!simObject.hasValidRequestAndObjectId() || callsign.isEmpty()) { return false; } @@ -650,13 +650,13 @@ namespace BlackSimPlugin void CSimulatorFsxCommon::removeAsPendingAndAddAgain(const CCallsign &callsign) { if (callsign.isEmpty()) { return; } - this->m_addPendingAircraft.removeByCallsign(callsign); - this->m_aircraftToAddAgainWhenRemoved.removeByCallsign(callsign); + m_addPendingAircraft.removeByCallsign(callsign); + m_aircraftToAddAgainWhenRemoved.removeByCallsign(callsign); } bool CSimulatorFsxCommon::simulatorReportedObjectRemoved(DWORD objectID) { - const CSimConnectObject simObject = this->m_simConnectObjects.getSimObjectForObjectId(objectID); + const CSimConnectObject simObject = m_simConnectObjects.getSimObjectForObjectId(objectID); if (!simObject.hasValidRequestAndObjectId()) { return false; } // object id from somewhere else const CCallsign callsign(simObject.getCallsign()); Q_ASSERT_X(!callsign.isEmpty(), Q_FUNC_INFO, "missing callsign"); @@ -676,7 +676,7 @@ namespace BlackSimPlugin // 3) Simulator not running (ie in stopped mode) if (!simObject.getAircraftModelString().isEmpty()) { - this->m_addPendingAircraft.push_back(simObject.getAircraft()); + m_addPendingAircraft.push_back(simObject.getAircraft()); CLogMessage(this).warning("Aircraft removed, '%1' '%2' object id '%3' out of reality bubble or other reason") << callsign.toQString() << simObject.getAircraftModelString() << objectID; } else @@ -709,7 +709,7 @@ namespace BlackSimPlugin bool CSimulatorFsxCommon::setSimConnectObjectId(DWORD requestId, DWORD objectId) { - return this->m_simConnectObjects.setSimConnectObjectIdForRequestId(requestId, objectId, true); + return m_simConnectObjects.setSimConnectObjectIdForRequestId(requestId, objectId, true); } bool CSimulatorFsxCommon::setCurrentLights(const CCallsign &callsign, const CAircraftLights &lights) @@ -1025,19 +1025,19 @@ namespace BlackSimPlugin Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "thread"); // nothing to do, reset request id and exit - if (this->isPaused() && this->m_pausedSimFreezesInterpolation) { return; } // no interpolation while paused + if (this->isPaused() && m_pausedSimFreezesInterpolation) { return; } // no interpolation while paused const int remoteAircraftNo = this->getAircraftInRangeCount(); if (remoteAircraftNo < 1) { m_interpolationRequest = 0; return; } // interpolate and send to simulator - this->m_interpolationRequest++; - const bool enableAircraftParts = this->m_interpolationRenderingSetup.isAircraftPartsEnabled(); + m_interpolationRequest++; + const bool enableAircraftParts = m_interpolationRenderingSetup.isAircraftPartsEnabled(); const CCallsignSet aircraftWithParts = enableAircraftParts ? this->remoteAircraftSupportingParts() : CCallsignSet(); // optimization, fetch all parts supporting aircraft in one step (one lock) // values used for position and parts const qint64 currentTimestamp = QDateTime::currentMSecsSinceEpoch(); const QList simObjects(m_simConnectObjects.values()); - const CCallsignSet callsignsToLog(this->m_interpolationRenderingSetup.getLogCallsigns()); + const CCallsignSet callsignsToLog(m_interpolationRenderingSetup.getLogCallsigns()); // interpolation for all remote aircraft for (const CSimConnectObject &simObj : simObjects) @@ -1318,7 +1318,7 @@ namespace BlackSimPlugin void CSimulatorFsxCommon::synchronizeTime(const CTime &zuluTimeSim, const CTime &localTimeSim) { - if (!this->m_simTimeSynced) { return; } + if (!m_simTimeSynced) { return; } if (!this->isConnected()) { return; } if (m_syncDeferredCounter > 0) { @@ -1327,9 +1327,9 @@ namespace BlackSimPlugin Q_UNUSED(localTimeSim); QDateTime myDateTime = QDateTime::currentDateTimeUtc(); - if (!this->m_syncTimeOffset.isZeroEpsilonConsidered()) + if (!m_syncTimeOffset.isZeroEpsilonConsidered()) { - int offsetSeconds = this->m_syncTimeOffset.valueRounded(CTimeUnit::s(), 0); + int offsetSeconds = m_syncTimeOffset.valueRounded(CTimeUnit::s(), 0); myDateTime = myDateTime.addSecs(offsetSeconds); } const QTime myTime = myDateTime.time(); @@ -1402,13 +1402,13 @@ namespace BlackSimPlugin void CSimulatorFsxCommon::initSimulatorInternals() { CSimulatorFsCommon::initSimulatorInternals(); - CSimulatorInternals s = this->m_simulatorInternals; + CSimulatorInternals s = m_simulatorInternals; const QString fsxPath = CFsCommonUtil::fsxDirFromRegistry(); // can be empty for remote FSX if (!fsxPath.isEmpty()) { s.setSimulatorInstallationDirectory(fsxPath); } s.setValue("fsx/simConnectCfgFilename", CSimConnectUtilities::getLocalSimConnectCfgFilename()); - s.setValue("fsx/simConnectVersion", this->m_simConnectVersion); - this->m_simulatorInternals = s; + s.setValue("fsx/simConnectVersion", m_simConnectVersion); + m_simulatorInternals = s; } void CSimulatorFsxCommon::reset() diff --git a/src/plugins/simulator/fsxcommon/simulatorfsxcommon.h b/src/plugins/simulator/fsxcommon/simulatorfsxcommon.h index c066ab17f..d9ce9b6b7 100644 --- a/src/plugins/simulator/fsxcommon/simulatorfsxcommon.h +++ b/src/plugins/simulator/fsxcommon/simulatorfsxcommon.h @@ -157,6 +157,7 @@ namespace BlackSimPlugin const QString &modeToString(AircraftAddMode mode); //! Dispatch SimConnect messages + //! \remark very frequently called void dispatch(); //! Implementation of add remote aircraft, which also handles FSX specific adding one by one diff --git a/src/plugins/simulator/fsxcommon/simulatorfsxsimconnectproc.cpp b/src/plugins/simulator/fsxcommon/simulatorfsxsimconnectproc.cpp index 5846a3fff..1d48540b7 100644 --- a/src/plugins/simulator/fsxcommon/simulatorfsxsimconnectproc.cpp +++ b/src/plugins/simulator/fsxcommon/simulatorfsxsimconnectproc.cpp @@ -60,12 +60,9 @@ namespace BlackSimPlugin ex.sprintf("Exception=%lu | SendID=%lu | Index=%lu | cbData=%lu", exceptionId, sendId, index, data); switch (exceptionId) { - case SIMCONNECT_EXCEPTION_OPERATION_INVALID_FOR_OBJECT_TYPE: - break; - case SIMCONNECT_EXCEPTION_UNRECOGNIZED_ID: - break; - default: - break; + case SIMCONNECT_EXCEPTION_OPERATION_INVALID_FOR_OBJECT_TYPE: break; + case SIMCONNECT_EXCEPTION_UNRECOGNIZED_ID: break; + default: break; } CLogMessage(simulatorFsx).warning("Caught FSX simConnect exception: %1 %2") << exStr << ex; break; @@ -293,10 +290,8 @@ namespace BlackSimPlugin SIMCONNECT_RECV_EVENT_FILENAME *event = static_cast(pData); switch (event->uEventID) { - case SystemEventFlightLoaded: - break; - default: - break; + case SystemEventFlightLoaded: break; + default: break; } break; }