diff --git a/src/blackcore/context_runtime.cpp b/src/blackcore/context_runtime.cpp index 3a7da72df..fbb8d8956 100644 --- a/src/blackcore/context_runtime.cpp +++ b/src/blackcore/context_runtime.cpp @@ -169,7 +169,7 @@ namespace BlackCore if (this->m_contextOwnAircraft && this->m_contextOwnAircraft->isUsingImplementingObject()) { c = connect(this->m_contextOwnAircraft, &IContextOwnAircraft::changedAircraftCockpit, - this->getCContextSimulator(), &CContextSimulator::ps_updateCockpitFromContext); + this->getCContextSimulator(), &CContextSimulator::ps_updateSimulatorCockpitFromContext); Q_ASSERT(c); } diff --git a/src/blackcore/context_simulator_impl.cpp b/src/blackcore/context_simulator_impl.cpp index 23d5f89ad..3eb08a1f4 100644 --- a/src/blackcore/context_simulator_impl.cpp +++ b/src/blackcore/context_simulator_impl.cpp @@ -32,7 +32,7 @@ namespace BlackCore { m_updateTimer = new QTimer(this); findSimulatorPlugins(); - connect(m_updateTimer, &QTimer::timeout, this, &CContextSimulator::ps_updateOwnAircraft); + connect(m_updateTimer, &QTimer::timeout, this, &CContextSimulator::ps_updateOwnAircraftContext); // do not load plugin here, as it depends on settings // it has to be guaranteed the settings are alredy loaded @@ -243,22 +243,25 @@ namespace BlackCore m_simulator = nullptr; } - void CContextSimulator::ps_updateOwnAircraft() + void CContextSimulator::ps_updateOwnAircraftContext() { Q_ASSERT(this->getIContextOwnAircraft()); + Q_ASSERT(this->m_simulator); // we make sure not to override values we do not have - CAircraft aircraft = this->getIContextOwnAircraft()->getOwnAircraft(); - CAircraft simulatorAircraft = this->m_simulator->getOwnAircraft(); - aircraft.setSituation(simulatorAircraft.getSituation()); - aircraft.setCockpit(simulatorAircraft.getCom1System(), simulatorAircraft.getCom2System(), simulatorAircraft.getTransponderCode()); + CAircraft contextAircraft = this->getIContextOwnAircraft()->getOwnAircraft(); // own aircraft from context + CAircraft simulatorAircraft = this->m_simulator->getOwnAircraft(); // own aircraft from simulator + + // update from simulator to context + contextAircraft.setSituation(simulatorAircraft.getSituation()); + contextAircraft.setCockpit(simulatorAircraft.getCom1System(), simulatorAircraft.getCom2System(), simulatorAircraft.getTransponderCode(), simulatorAircraft.getTransponderMode()); Q_ASSERT(this->getIContextOwnAircraft()); // paranoia against context having been deleted from another thread - redmine issue #270 if (this->getIContextOwnAircraft()) { // the method will check, if an update is really required // these are local (non DBus) calls - this->getIContextOwnAircraft()->updateOwnAircraft(aircraft, this->getPathAndContextId()); + this->getIContextOwnAircraft()->updateOwnAircraft(contextAircraft, this->getPathAndContextId()); } } @@ -283,10 +286,10 @@ namespace BlackCore this->m_simulator->removeRemoteAircraft(callsign); } - void CContextSimulator::ps_updateCockpitFromContext(const CAircraft &ownAircraft, const QString &originator) + void CContextSimulator::ps_updateSimulatorCockpitFromContext(const CAircraft &ownAircraft, const QString &originator) { Q_ASSERT(this->m_simulator); - if (!this->m_simulator) return; + if (!this->m_simulator) { return; } // avoid loops if (originator.isEmpty() || originator == IContextSimulator::InterfaceName()) return; @@ -311,25 +314,6 @@ namespace BlackCore emit connectionChanged(connected); } - void CContextSimulator::ps_statusMessageReceived(const CStatusMessage &statusMessage) - { - if (!this->m_simulator) return; - if (statusMessage.getSeverity() != CStatusMessage::SeverityError) return; - - if (statusMessage.wasHandledBy(this)) return; - statusMessage.markAsHandledBy(this); - - this->m_simulator->displayStatusMessage(statusMessage); - } - - void CContextSimulator::ps_statusMessagesReceived(const CStatusMessageList &statusMessages) - { - for (const CStatusMessage &m : statusMessages) - { - this->ps_statusMessageReceived(m); - } - } - void CContextSimulator::ps_textMessagesReceived(const Network::CTextMessageList &textMessages) { if (!this->m_simulator) return; diff --git a/src/blackcore/context_simulator_impl.h b/src/blackcore/context_simulator_impl.h index 570367152..661f8fcfa 100644 --- a/src/blackcore/context_simulator_impl.h +++ b/src/blackcore/context_simulator_impl.h @@ -108,8 +108,8 @@ namespace BlackCore } private slots: - //! Update own aircraft, because simulator has changed something - void ps_updateOwnAircraft(); + //! Update own aircraft context, because simulator has changed something + void ps_updateOwnAircraftContext(); //! \copydoc ISimulator::addRemoteAircraft void ps_addRemoteAircraft(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CAircraftSituation &initialSituation); @@ -120,19 +120,13 @@ namespace BlackCore //! \copydoc ISimulator::removeRemoteAircraft void ps_removeRemoteAircraft(const BlackMisc::Aviation::CCallsign &callsign); - //! Update cockpit from context, because someone else has changed cockpit (e.g. GUI, 3rd party) + //! Update simulator cockpit from context, because someone else has changed cockpit (e.g. GUI, 3rd party) //! \remarks set by runtime, only to be used locally (not via DBus) - void ps_updateCockpitFromContext(const BlackMisc::Aviation::CAircraft &ownAircraft, const QString &originator); + void ps_updateSimulatorCockpitFromContext(const BlackMisc::Aviation::CAircraft &ownAircraft, const QString &originator); //! Handle new connection status void ps_onConnectionStatusChanged(ISimulator::ConnectionStatus status); - //! Status message received - void ps_statusMessageReceived(const BlackMisc::CStatusMessage &statusMessage); - - //! Status messages received - void ps_statusMessagesReceived(const BlackMisc::CStatusMessageList &statusMessages); - //! Text message received void ps_textMessagesReceived(const BlackMisc::Network::CTextMessageList &textMessages); @@ -140,10 +134,7 @@ namespace BlackCore //! \brief find and catalog all simulator plugins void findSimulatorPlugins(); - BlackMisc::Network::CAircraftModel m_aircraftModel; - BlackMisc::Aviation::CAircraft m_ownAircraft; - BlackCore::ISimulator *m_simulator = nullptr; - + BlackCore::ISimulator *m_simulator = nullptr; //!< simulator plugin QTimer *m_updateTimer = nullptr; QDir m_pluginsDir; QSet m_simulatorFactories;