diff --git a/src/blackcore/simulator.cpp b/src/blackcore/simulator.cpp index 71e910b40..eddb511fe 100644 --- a/src/blackcore/simulator.cpp +++ b/src/blackcore/simulator.cpp @@ -62,7 +62,7 @@ namespace BlackCore bool ISimulator::logicallyRemoveRemoteAircraft(const CCallsign &callsign) { - // if not restriced, directly change + // if not restricted, directly change if (!this->getInterpolationSetupGlobal().isRenderingRestricted()) { m_statsPhysicallyAddedAircraft++; @@ -90,7 +90,7 @@ namespace BlackCore if (this->showDebugLogMessage()) { this->debugLogMessage(Q_FUNC_INFO, QStringLiteral("Restricted: %1 cs: '%2' enabled: %3").arg(boolToYesNo(renderingRestricted), remoteAircraft.getCallsignAsString(), boolToYesNo(remoteAircraft.isEnabled()))); } if (!remoteAircraft.isEnabled()) { return false; } - // if not restriced, directly change + // if not restricted, directly change if (!renderingRestricted) { this->callPhysicallyAddRemoteAircraft(remoteAircraft); @@ -756,8 +756,8 @@ namespace BlackCore this, // receiver must match object in bind nullptr, nullptr, - std::bind(&ISimulator::rapOnRemoteProviderRemovedAircraft, this, std::placeholders::_1), - std::bind(&ISimulator::rapOnRecalculatedRenderedAircraft, this, std::placeholders::_1))); + [](const Aviation::CCallsign &) { /* currently not used, the calls are handled by context call logicallyRemoveRemoteAircraft*/ }, + [this](const CAirspaceAircraftSnapshot &snapshot) { this->rapOnRecalculatedRenderedAircraft(snapshot); })); // timer connect(&m_oneSecondTimer, &QTimer::timeout, this, &ISimulator::oneSecondTimerTimeout); @@ -832,7 +832,7 @@ namespace BlackCore { Q_ASSERT_X(aircraft.isEnabled(), Q_FUNC_INFO, "Disabled aircraft detected as to be added"); Q_ASSERT_X(aircraft.hasModelString(), Q_FUNC_INFO, "Missing model string"); - this->callPhysicallyAddRemoteAircraft(aircraft); // recalcuate snapshot + this->callPhysicallyAddRemoteAircraft(aircraft); // recalculate snapshot changed = true; } } @@ -875,7 +875,7 @@ namespace BlackCore // a default implementation, but normally overridden by the sims const CCallsignSet callsigns = this->getAircraftInRangeCallsigns(); - // normally that would be already done in the specializied implementation + // normally that would be already done in the specialized implementation const int r = this->physicallyRemoveMultipleRemoteAircraft(callsigns); // leave no trash @@ -885,15 +885,15 @@ namespace BlackCore CAirportList ISimulator::getWebServiceAirports() const { - if (this->isShuttingDown()) { return CAirportList(); } - if (!sApp || sApp->isShuttingDown() || !sApp->hasWebDataServices()) { return CAirportList(); } + if (this->isShuttingDown()) { return {}; } + if (!sApp || sApp->isShuttingDown() || !sApp->hasWebDataServices()) { return {}; } return sApp->getWebDataServices()->getAirports(); } CAirport ISimulator::getWebServiceAirport(const CAirportIcaoCode &icao) const { - if (this->isShuttingDown()) { return CAirport(); } - if (!sApp || sApp->isShuttingDown() || !sApp->hasWebDataServices()) { return CAirport(); } + if (this->isShuttingDown()) { return {}; } + if (!sApp || sApp->isShuttingDown() || !sApp->hasWebDataServices()) { return {}; } return sApp->getWebDataServices()->getAirports().findFirstByIcao(icao); } @@ -968,7 +968,7 @@ namespace BlackCore if (oldStatus != newStatus) { // decouple, follow up of signal can include unloading - // simulator so this should happen strictly asyncronously (which is like forcing Qt::QueuedConnection) + // simulator so this should happen strictly asynchronously (which is like forcing Qt::QueuedConnection) QPointer myself(this); QTimer::singleShot(0, this, [=] { if (!myself || !sApp || sApp->isShuttingDown()) { return; } @@ -1012,8 +1012,8 @@ namespace BlackCore CAirportList ISimulator::getAirportsInRange(bool recalculateDistance) const { // default implementation - if (this->isShuttingDown()) { return CAirportList(); } - if (!sApp || !sApp->hasWebDataServices()) { return CAirportList(); } + if (this->isShuttingDown()) { return {}; } + if (!sApp || !sApp->hasWebDataServices()) { return {}; } const CAirportList airports = sApp->getWebDataServices()->getAirports(); if (airports.isEmpty()) { return airports; } @@ -1145,25 +1145,6 @@ namespace BlackCore return true; } - CCallsignSet ISimulator::unrenderedEnabledAircraft() const - { - const CSimulatedAircraftList aircraft = this->getAircraftInRange().findByEnabled(true); - if (aircraft.isEmpty()) { return CCallsignSet(); } - CCallsignSet enabledOnes = aircraft.getCallsigns(); - const CCallsignSet renderedOnes = this->physicallyRenderedAircraft(); - enabledOnes.remove(renderedOnes); - return enabledOnes; - } - - CCallsignSet ISimulator::renderedDisabledAircraft() const - { - const CSimulatedAircraftList aircraft = this->getAircraftInRange().findByEnabled(false); - if (aircraft.isEmpty()) { return CCallsignSet(); } - const CCallsignSet disabledOnes = aircraft.getCallsigns(); - const CCallsignSet renderedOnes = this->physicallyRenderedAircraft(); - return renderedOnes.intersection(disabledOnes); - } - bool ISimulator::changeRemoteAircraftEnabled(const CSimulatedAircraft &aircraft) { if (this->isShuttingDown()) { return false; } @@ -1279,7 +1260,7 @@ namespace BlackCore CAircraftModelList ISimulator::getModelSet() const { const CSimulatorInfo simulator = this->getSimulatorInfo(); - if (!simulator.isSingleSimulator()) { return CAircraftModelList(); } + if (!simulator.isSingleSimulator()) { return {}; } CCentralMultiSimulatorModelSetCachesProvider::modelCachesInstance().synchronizeCache(simulator); return CCentralMultiSimulatorModelSetCachesProvider::modelCachesInstance().getCachedModels(simulator); @@ -1335,12 +1316,6 @@ namespace BlackCore this->onRecalculatedRenderedAircraft(snapshot); } - void ISimulator::rapOnRemoteProviderRemovedAircraft(const CCallsign &callsign) - { - Q_UNUSED(callsign) - // currently not used, the calls are handled by context call logicallyRemoveRemoteAircraft - } - void ISimulator::callPhysicallyAddRemoteAircraft(const CSimulatedAircraft &remoteAircraft) { m_statsPhysicallyAddedAircraft++; @@ -1405,7 +1380,7 @@ namespace BlackCore { if (CDatabaseUtils::hasDbAircraftData()) { - const CAircraftModel newModel = this->reverseLookupModel(model); + const CAircraftModel newModel = BlackCore::ISimulator::reverseLookupModel(model); const bool updated = this->updateOwnModel(newModel); // update in provider (normally the context) if (updated) { diff --git a/src/blackcore/simulator.h b/src/blackcore/simulator.h index f1df6f870..a06d20cb1 100644 --- a/src/blackcore/simulator.h +++ b/src/blackcore/simulator.h @@ -40,16 +40,9 @@ #include #include -namespace BlackMisc +namespace BlackMisc::Network { - namespace Aviation - { - class CCallsign; - } - namespace Network - { - class CTextMessage; - } + class CTextMessage; } namespace BlackCore @@ -85,11 +78,8 @@ namespace BlackCore //! Log categories static const QStringList &getLogCategories(); - //! Render all aircraft if number of aircraft >= MaxAircraftInfinite - const int MaxAircraftInfinite = 100; - //! Destructor - virtual ~ISimulator() override; + ~ISimulator() override; //! Combined status virtual SimulatorStatus getSimulatorStatus() const; @@ -127,12 +117,6 @@ namespace BlackCore return this->physicallyRemoveAllRemoteAircraft(); } - //! Find the unrendered enabled aircraft - virtual BlackMisc::Aviation::CCallsignSet unrenderedEnabledAircraft() const; - - //! Find the rendered disabled aircraft - virtual BlackMisc::Aviation::CCallsignSet renderedDisabledAircraft() const; - //! Change remote aircraft per property virtual bool changeRemoteAircraftModel(const BlackMisc::Simulation::CSimulatedAircraft &aircraft); @@ -225,7 +209,7 @@ namespace BlackCore //! Number of track miles over-reported, due to low FPS double getTrackMilesShort() const { return m_trackMilesShort; } - //! Number of minutes behind scedule, due to low FPS + //! Number of minutes behind schedule, due to low FPS double getMinutesLate() const { return m_minutesLate; } //! Send situation/parts for testing @@ -262,7 +246,7 @@ namespace BlackCore //! \copydoc BlackMisc::Simulation::ISimulationEnvironmentProvider::requestElevation //! \remark needs to be overridden if the concrete driver supports such an option //! \sa ISimulator::callbackReceivedRequestedElevation - virtual bool requestElevation(const BlackMisc::Geo::ICoordinateGeodetic &reference, const BlackMisc::Aviation::CCallsign &callsign) override; + bool requestElevation(const BlackMisc::Geo::ICoordinateGeodetic &reference, const BlackMisc::Aviation::CCallsign &callsign) override; //! \copydoc BlackMisc::Simulation::ISimulationEnvironmentProvider::requestElevation bool requestElevation(const BlackMisc::Aviation::CAircraftSituation &situation) { return this->requestElevation(situation, situation.getCallsign()); } @@ -275,13 +259,13 @@ namespace BlackCore virtual void injectWeatherGrid(const BlackMisc::Weather::CWeatherGrid &weatherGrid); //! Allows to print out simulator specific statistics - virtual QString getStatisticsSimulatorSpecific() const { return QString(); } + virtual QString getStatisticsSimulatorSpecific() const { return {}; } //! Reset the statistics virtual void resetAircraftStatistics(); //! \copydoc BlackMisc::IProvider::asQObject - virtual QObject *asQObject() override { return this; } + QObject *asQObject() override { return this; } //! Is this the emulated driver just pretending to be P3D, FSX, or XPlane bool isEmulatedDriver() const; @@ -310,7 +294,7 @@ namespace BlackCore BlackMisc::Simulation::CInterpolationAndRenderingSetupPerCallsign getInterpolationSetupConsolidated(const BlackMisc::Aviation::CCallsign &callsign, bool forceFullUpdate) const; //! \copydoc BlackMisc::Simulation::IInterpolationSetupProvider::setInterpolationSetupGlobal - virtual bool setInterpolationSetupGlobal(const BlackMisc::Simulation::CInterpolationAndRenderingSetupGlobal &setup) override; + bool setInterpolationSetupGlobal(const BlackMisc::Simulation::CInterpolationAndRenderingSetupGlobal &setup) override; //! Interpolation messages for callsign virtual BlackMisc::CStatusMessageList getInterpolationMessages(const BlackMisc::Aviation::CCallsign &callsign) const = 0; @@ -325,7 +309,7 @@ namespace BlackCore int getStatisticsPhysicallyRemovedAircraft() const { return m_statsPhysicallyRemovedAircraft; } //! Current update time in ms - double getStatisticsCurrentUpdateTimeMs() const { return m_statsCurrentUpdateTimeMs; } + qint64 getStatisticsCurrentUpdateTimeMs() const { return m_statsCurrentUpdateTimeMs; } //! Average update time in ms double getStatisticsAverageUpdateTimeMs() const { return m_statsUpdateAircraftTimeAvgMs; } @@ -475,7 +459,7 @@ namespace BlackCore void emitSimulatorCombinedStatus(SimulatorStatus oldStatus = Unspecified); //! \copydoc BlackMisc::Simulation::IInterpolationSetupProvider::emitInterpolationSetupChanged - virtual void emitInterpolationSetupChanged() override; + void emitInterpolationSetupChanged() override; //! Display a debug log message based on BlackMisc::Simulation::CInterpolationAndRenderingSetup //! remark shows log messages of functions calls @@ -586,7 +570,6 @@ namespace BlackCore //! Lookup against DB data static BlackMisc::Simulation::CAircraftModel reverseLookupModel(const BlackMisc::Simulation::CAircraftModel &model); - bool m_pausedSimFreezesInterpolation = false; //!< paused simulator will also pause interpolation (so AI aircraft will hold) bool m_updateRemoteAircraftInProgress = false; //!< currently updating remote aircraft bool m_enablePseudoElevation = false; //!< return faked elevations (testing) int m_timerId = -1; //!< dispatch timer id @@ -633,7 +616,6 @@ namespace BlackCore private: // remote aircraft provider ("rap") bound void rapOnRecalculatedRenderedAircraft(const BlackMisc::Simulation::CAirspaceAircraftSnapshot &snapshot); - void rapOnRemoteProviderRemovedAircraft(const BlackMisc::Aviation::CCallsign &callsign); // call with counters updated void callPhysicallyAddRemoteAircraft(const BlackMisc::Simulation::CSimulatedAircraft &remoteAircraft); @@ -653,7 +635,6 @@ namespace BlackCore BlackMisc::Simulation::CSimulatedAircraftList m_highlightedAircraft; //!< all other aircraft are to be ignored // timer - int m_timerCounter = 0; //!< allows to calculate n seconds QTimer m_oneSecondTimer; //!< multi purpose timer with 1 sec. interval // misc. @@ -673,7 +654,7 @@ namespace BlackCore public: //! Destructor - virtual ~ISimulatorListener() = default; + ~ISimulatorListener() override = default; //! Corresponding info const BlackMisc::Simulation::CSimulatorPluginInfo &getPluginInfo() const { return m_info; } @@ -704,7 +685,7 @@ namespace BlackCore protected: //! Constructor //! \sa ISimulatorFactory::createListener(). - ISimulatorListener(const BlackMisc::Simulation::CSimulatorPluginInfo &info); + explicit ISimulatorListener(const BlackMisc::Simulation::CSimulatorPluginInfo &info); //! Overall (swift) application shutting down virtual bool isShuttingDown() const; @@ -732,7 +713,7 @@ namespace BlackCore { public: //! ISimulatorVirtual destructor - virtual ~ISimulatorFactory() {} + virtual ~ISimulatorFactory() = default; //! @{ //! Not copyable diff --git a/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp b/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp index cb54821f7..13a5d9307 100644 --- a/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp +++ b/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp @@ -1973,9 +1973,6 @@ namespace BlackSimPlugin::FsxCommon static_assert(sizeof(DataDefinitionRemoteAircraftPartsWithoutLights) == sizeof(double) * 10, "DataDefinitionRemoteAircraftPartsWithoutLights has an incorrect size."); Q_ASSERT_X(CThreadUtils::isInThisThread(this), Q_FUNC_INFO, "thread"); - // Freeze interpolation while paused - if (this->isPaused() && m_pausedSimFreezesInterpolation) { return; } - // nothing to do, reset request id and exit const int remoteAircraftNo = this->getAircraftInRangeCount(); if (remoteAircraftNo < 1)