diff --git a/src/blackcore/context/contextsimulatorimpl.cpp b/src/blackcore/context/contextsimulatorimpl.cpp index 6ac59b391..8b00001fe 100644 --- a/src/blackcore/context/contextsimulatorimpl.cpp +++ b/src/blackcore/context/contextsimulatorimpl.cpp @@ -414,6 +414,12 @@ namespace BlackCore // try to connect to simulator const bool connected = simulator->connectTo(); + if (!connected) + { + CLogMessage(this).error("Simulator plugin connection to simulator '%1' failed") << simulatorPluginInfo.toQString(true); + return false; + } + simulator->setWeatherActivated(m_isWeatherActivated); // when everything is set up connected, update the current plugin info @@ -626,6 +632,10 @@ namespace BlackCore if (to == INetwork::Connected && this->getIContextNetwork()) { m_networkSessionId = this->getIContextNetwork()->getConnectedServer().getServerSessionId(); + if (m_simulatorPlugin.second) // check in case the plugin has been unloaded + { + m_simulatorPlugin.second->setFlightNetworkConnected(true); + } } else if (INetwork::isDisconnectedStatus(to)) { @@ -637,6 +647,7 @@ namespace BlackCore { const CStatusMessageList verifyMessages = m_simulatorPlugin.second->debugVerifyStateAfterAllAircraftRemoved(); m_simulatorPlugin.second->clearAllRemoteAircraftData(); + m_simulatorPlugin.second->setFlightNetworkConnected(false); if (!verifyMessages.isEmpty()) { emit this->driverMessages(verifyMessages); } } } diff --git a/src/blackcore/simulator.cpp b/src/blackcore/simulator.cpp index 8b0bb00f6..53338666d 100644 --- a/src/blackcore/simulator.cpp +++ b/src/blackcore/simulator.cpp @@ -123,6 +123,11 @@ namespace BlackCore } } + void ISimulator::setFlightNetworkConnected(bool connected) + { + m_networkConnected = connected; + } + void ISimulator::reloadWeatherSettings() { if (!m_isWeatherActivated) { return; } diff --git a/src/blackcore/simulator.h b/src/blackcore/simulator.h index e39040a05..b1f72b271 100644 --- a/src/blackcore/simulator.h +++ b/src/blackcore/simulator.h @@ -169,6 +169,14 @@ namespace BlackCore //! Activates or deactivates simulator weather virtual void setWeatherActivated(bool activated); + //! Flight network has been connected + //! \remark hint if network connected and we expect any planes + //! \sa ISimulator::isFlightNetworkConnected + virtual void setFlightNetworkConnected(bool connected); + + //! Is the flight network connected + bool isFlightNetworkConnected() const { return m_networkConnected; } + //! Reload weather settings void reloadWeatherSettings(); @@ -538,18 +546,24 @@ namespace BlackCore //! Display a logged situation in simulator void displayLoggedSituationInSimulator(const BlackMisc::Aviation::CCallsign &cs, bool stopLogging, int times = 40); - 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; //!< multi purpose timer with 1 sec. interval - BlackMisc::Aviation::CCallsignSet m_callsignsToBeRendered; //!< callsigns which will be rendered - BlackMisc::CConnectionGuard m_remoteAircraftProviderConnections; //!< connected signal/slots - BlackMisc::Simulation::CSimulatedAircraftList m_highlightedAircraft; //!< all other aircraft are to be ignored - // statistics values of how often those functions are called // those are the added counters, overflow will not be an issue here (discussed in T171 review) int m_statsPhysicallyAddedAircraft = 0; //!< statistics, how many aircraft added int m_statsPhysicallyRemovedAircraft = 0; //!< statistics, how many aircraft removed + + // highlighting + bool m_blinkCycle = false; //!< used for highlighting + qint64 m_highlightEndTimeMsEpoch = 0; //!< end highlighting + 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. as callsigns + bool m_networkConnected = false; //!< flight network connected + BlackMisc::Aviation::CCallsignSet m_callsignsToBeRendered; //!< callsigns which will be rendered + BlackMisc::CConnectionGuard m_remoteAircraftProviderConnections; //!< connected signal/slots }; //! \brief Interface to a simulator listener. diff --git a/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp b/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp index 6eba88acf..1f9e3c246 100644 --- a/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp +++ b/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp @@ -343,6 +343,17 @@ namespace BlackSimPlugin CSimulatorPluginCommon::resetAircraftStatistics(); } + void CSimulatorFsxCommon::setFlightNetworkConnected(bool connected) + { + if (connected == !this->isFlightNetworkConnected()) + { + // toggling, we trace for a while to better monitor those "critical" phases + this->triggerAutoTraceSendId(); + } + + ISimulator::setFlightNetworkConnected(connected); + } + CSimConnectDefinitions::SimObjectRequest CSimulatorFsxCommon::requestToSimObjectRequest(DWORD requestId) { DWORD v = static_cast(CSimConnectDefinitions::SimObjectEndMarker); diff --git a/src/plugins/simulator/fsxcommon/simulatorfsxcommon.h b/src/plugins/simulator/fsxcommon/simulatorfsxcommon.h index e36f67c13..dd8c84b42 100644 --- a/src/plugins/simulator/fsxcommon/simulatorfsxcommon.h +++ b/src/plugins/simulator/fsxcommon/simulatorfsxcommon.h @@ -132,6 +132,7 @@ namespace BlackSimPlugin virtual BlackMisc::CStatusMessageList debugVerifyStateAfterAllAircraftRemoved() const override; virtual QString getStatisticsSimulatorSpecific() const override; virtual void resetAircraftStatistics() override; + virtual void setFlightNetworkConnected(bool connected) override; //! @} //! \copydoc BlackMisc::Simulation::ISimulationEnvironmentProvider::requestElevation