From a871579479d1107cfb2edb82c668cffa0acd316b Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Tue, 25 Sep 2018 01:46:35 +0200 Subject: [PATCH] Ref T370, added public removeAllRemoteAircraft * protected clearAllRemoteAircraftData * ISimulator::clearAllRemoteAircraftData no longer calls clearAllRemoteAircraftData (circular) --- .../context/contextsimulatorimpl.cpp | 2 +- src/blackcore/simulator.cpp | 5 ++++- src/blackcore/simulator.h | 19 ++++++++++++++----- src/plugins/simulator/fs9/simulatorfs9.cpp | 2 ++ .../fsxcommon/simulatorfsxcommon.cpp | 2 ++ .../simulator/fsxcommon/simulatorfsxcommon.h | 2 +- .../simulator/xplane/simulatorxplane.h | 2 +- 7 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/blackcore/context/contextsimulatorimpl.cpp b/src/blackcore/context/contextsimulatorimpl.cpp index 37e91e51f..28ac1c12f 100644 --- a/src/blackcore/context/contextsimulatorimpl.cpp +++ b/src/blackcore/context/contextsimulatorimpl.cpp @@ -652,7 +652,7 @@ namespace BlackCore if (m_simulatorPlugin.second) // check in case the plugin has been unloaded { - m_simulatorPlugin.second->clearAllRemoteAircraftData(); // also removes aircraft + m_simulatorPlugin.second->removeAllRemoteAircraft(); // also removes aircraft m_simulatorPlugin.second->setFlightNetworkConnected(false); } } diff --git a/src/blackcore/simulator.cpp b/src/blackcore/simulator.cpp index 9e85fd6bb..dcbc55bcf 100644 --- a/src/blackcore/simulator.cpp +++ b/src/blackcore/simulator.cpp @@ -143,7 +143,6 @@ namespace BlackCore void ISimulator::clearAllRemoteAircraftData() { // rendering related stuff - this->physicallyRemoveAllRemoteAircraft(); m_addAgainAircraftWhenRemoved.clear(); m_callsignsToBeRendered.clear(); m_clampedLogMsg.clear(); @@ -698,7 +697,11 @@ 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 const int r = this->physicallyRemoveMultipleRemoteAircraft(callsigns); + + // leave no trash this->clearAllRemoteAircraftData(); return r; } diff --git a/src/blackcore/simulator.h b/src/blackcore/simulator.h index 89a65b0eb..c9fbe9d36 100644 --- a/src/blackcore/simulator.h +++ b/src/blackcore/simulator.h @@ -119,6 +119,13 @@ namespace BlackCore //! \sa logicallyAddRemoteAircraft virtual bool logicallyReAddRemoteAircraft(const BlackMisc::Aviation::CCallsign &callsign); + //! Public version to remove all aircraft + //! \sa physicallyRemoveAllRemoteAircraft + int removeAllRemoteAircraft() + { + return this->physicallyRemoveAllRemoteAircraft(); + } + //! Find the unrendered enabled aircraft virtual BlackMisc::Aviation::CCallsignSet unrenderedEnabledAircraft() const; @@ -196,9 +203,6 @@ namespace BlackCore //! Simulator running? virtual bool isSimulating() const { return this->isConnected(); } - //! Clear all aircraft related data - virtual void clearAllRemoteAircraftData(); - //! Debug function to check state after all aircraft have been removed //! \remarks only in local developer builds virtual BlackMisc::CStatusMessageList debugVerifyStateAfterAllAircraftRemoved() const; @@ -400,8 +404,13 @@ namespace BlackCore //! Remove remote aircraft from simulator virtual int physicallyRemoveMultipleRemoteAircraft(const BlackMisc::Aviation::CCallsignSet &callsigns); - //! Remove all remote aircraft - virtual int physicallyRemoveAllRemoteAircraft() = 0; + //! Clear all aircraft related data, but do not physically remove the aircraft + virtual void clearAllRemoteAircraftData(); + + //! Remove all remote aircraft and their data via ISimulator::clearAllRemoteAircraftData + //! \remark each driver is supposed to override that, implement the "physically removing part" (simulator specific) and the call the base class + //! \sa ISimulator::clearAllRemoteAircraftData + virtual int physicallyRemoveAllRemoteAircraft(); //! Set elevation and CG in the providers void rememberElevationAndCG(const BlackMisc::Aviation::CCallsign &callsign, const QString &modelString, const BlackMisc::Geo::CElevationPlane &elevation, const BlackMisc::PhysicalQuantities::CLength &cg); diff --git a/src/plugins/simulator/fs9/simulatorfs9.cpp b/src/plugins/simulator/fs9/simulatorfs9.cpp index 784508772..2bb29a7c3 100644 --- a/src/plugins/simulator/fs9/simulatorfs9.cpp +++ b/src/plugins/simulator/fs9/simulatorfs9.cpp @@ -213,6 +213,8 @@ namespace BlackSimPlugin { if (physicallyRemoveRemoteAircraft(cs)) { r++; } } + + CSimulatorFsCommon::physicallyRemoveAllRemoteAircraft(); return r; } diff --git a/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp b/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp index 697028132..bb3a392dc 100644 --- a/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp +++ b/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp @@ -1548,6 +1548,8 @@ namespace BlackSimPlugin { if (this->physicallyRemoveRemoteAircraft(cs)) { r++; } } + + CSimulatorFsCommon::physicallyRemoveAllRemoteAircraft(); return r; } diff --git a/src/plugins/simulator/fsxcommon/simulatorfsxcommon.h b/src/plugins/simulator/fsxcommon/simulatorfsxcommon.h index 94fb7a3f2..7ccda1323 100644 --- a/src/plugins/simulator/fsxcommon/simulatorfsxcommon.h +++ b/src/plugins/simulator/fsxcommon/simulatorfsxcommon.h @@ -144,7 +144,6 @@ namespace BlackSimPlugin virtual void displayTextMessage(const BlackMisc::Network::CTextMessage &message) const override; virtual bool isPhysicallyRenderedAircraft(const BlackMisc::Aviation::CCallsign &callsign) const override; virtual BlackMisc::Aviation::CCallsignSet physicallyRenderedAircraft() const override; - virtual void clearAllRemoteAircraftData() override; virtual BlackMisc::CStatusMessageList debugVerifyStateAfterAllAircraftRemoved() const override; virtual QString getStatisticsSimulatorSpecific() const override; virtual void resetAircraftStatistics() override; @@ -207,6 +206,7 @@ namespace BlackSimPlugin virtual void reset() override; virtual void initSimulatorInternals() override; virtual void injectWeatherGrid(const BlackMisc::Weather::CWeatherGrid &weatherGrid) override; + virtual void clearAllRemoteAircraftData() override; //! @} //! Timer event (our SimConnect event loop), runs dispatch diff --git a/src/plugins/simulator/xplane/simulatorxplane.h b/src/plugins/simulator/xplane/simulatorxplane.h index 419826fe7..b287fbc18 100644 --- a/src/plugins/simulator/xplane/simulatorxplane.h +++ b/src/plugins/simulator/xplane/simulatorxplane.h @@ -138,7 +138,6 @@ namespace BlackSimPlugin virtual void unload() override; virtual QString getStatisticsSimulatorSpecific() const override; virtual void resetAircraftStatistics() override; - virtual void clearAllRemoteAircraftData() override; //! @} //! \copydoc BlackMisc::Simulation::ISimulationEnvironmentProvider::requestElevation @@ -154,6 +153,7 @@ namespace BlackSimPlugin virtual bool physicallyAddRemoteAircraft(const BlackMisc::Simulation::CSimulatedAircraft &newRemoteAircraft) override; virtual bool physicallyRemoveRemoteAircraft(const BlackMisc::Aviation::CCallsign &callsign) override; virtual int physicallyRemoveAllRemoteAircraft() override; + virtual void clearAllRemoteAircraftData() override; virtual void injectWeatherGrid(const BlackMisc::Weather::CWeatherGrid &weatherGrid) override; virtual bool isPaused() const override {