Ref T423, force update if simulator was paused or interrupted before

* force full updates for some cycles "m_updateAllRemoteAircraftCycles"
* only use "emitSimulatorCombinedStatus" to emit changed simulator status
* renamed to "finishUpdateRemoteAircraftAndSetStatistics"
* override "forced" in "getInterpolationSetupConsolidated"

This addresses the issue that aircraft appear below ground after moving the aircraft
This commit is contained in:
Klaus Basan
2018-11-02 18:15:04 +01:00
parent 4d7ca00324
commit 2b8e388ba1
8 changed files with 52 additions and 33 deletions

View File

@@ -292,11 +292,12 @@ namespace BlackCore
}
}
CInterpolationAndRenderingSetupPerCallsign ISimulator::getInterpolationSetupConsolidated(const CCallsign &callsign) const
CInterpolationAndRenderingSetupPerCallsign ISimulator::getInterpolationSetupConsolidated(const CCallsign &callsign, bool forceFullUpdate) const
{
CInterpolationAndRenderingSetupPerCallsign setup = this->getInterpolationSetupPerCallsignOrDefault(callsign);
const CClient client = this->getClientOrDefaultForCallsign(callsign);
setup.consolidateWithClient(client);
if (forceFullUpdate) { setup.setForceFullInterpolation(forceFullUpdate); }
return setup;
}
@@ -709,14 +710,14 @@ namespace BlackCore
CAirportList ISimulator::getWebServiceAirports() const
{
if (this->isShuttingDown()) { return CAirportList(); }
if (!sApp->hasWebDataServices()) { return CAirportList(); }
if (!sApp || sApp->isShuttingDown() || !sApp->hasWebDataServices()) { return CAirportList(); }
return sApp->getWebDataServices()->getAirports();
}
CAirport ISimulator::getWebServiceAirport(const CAirportIcaoCode &icao) const
{
if (this->isShuttingDown()) { return CAirport(); }
if (!sApp->hasWebDataServices()) { return CAirport(); }
if (!sApp || sApp->isShuttingDown() || !sApp->hasWebDataServices()) { return CAirport(); }
return sApp->getWebDataServices()->getAirports().findFirstByIcao(icao);
}
@@ -771,8 +772,15 @@ namespace BlackCore
QPointer<ISimulator> myself(this);
QTimer::singleShot(0, this, [ = ]
{
if (!myself) { return; }
emit myself->simulatorStatusChanged(newStatus);
if (!myself || !sApp || sApp->isShuttingDown()) { return; }
// now simulating
if (newStatus.testFlag(Simulating))
{
m_updateAllRemoteAircraftCycles = 10; // force an update of every remote aircraft
}
emit this->simulatorStatusChanged(newStatus); // only place where we should emit the signal, use emitSimulatorCombinedStatus to emit
});
}
}
@@ -833,7 +841,7 @@ namespace BlackCore
bool ISimulator::isUpdateAircraftLimitedWithStats(qint64 startTime)
{
const bool limited = this->isUpdateAircraftLimited(startTime);
this->setStatsRemoteAircraftUpdate(startTime, limited);
this->finishUpdateRemoteAircraftAndSetStatistics(startTime, limited);
return limited;
}
@@ -991,7 +999,7 @@ namespace BlackCore
}
depreatced **/
void ISimulator::setStatsRemoteAircraftUpdate(qint64 startTime, bool limited)
void ISimulator::finishUpdateRemoteAircraftAndSetStatistics(qint64 startTime, bool limited)
{
const qint64 now = QDateTime::currentMSecsSinceEpoch();
const qint64 dt = now - startTime;
@@ -1002,6 +1010,7 @@ namespace BlackCore
m_updateRemoteAircraftInProgress = false;
m_statsLastUpdateAircraftRequestedMs = startTime;
if (m_updateAllRemoteAircraftCycles > 0) { m_updateAllRemoteAircraftCycles--; }
if (m_statsMaxUpdateTimeMs < dt) { m_statsMaxUpdateTimeMs = dt; }
if (m_statsLastUpdateAircraftRequestedMs > 0) { m_statsUpdateAircraftRequestedDeltaMs = startTime - m_statsLastUpdateAircraftRequestedMs; }
if (limited) { m_statsUpdateAircraftLimited++; }
@@ -1098,6 +1107,7 @@ namespace BlackCore
Q_ASSERT_X(sApp->hasWebDataServices(), Q_FUNC_INFO, "Missing web services");
if (!model.hasModelString()) { return; }
if (this->isShuttingDown()) { return; }
if (this->getOwnAircraftModel() != model)
{
if (CDatabaseUtils::hasDbAircraftData())

View File

@@ -266,7 +266,7 @@ namespace BlackCore
//! Consolidate setup with other data like from BlackMisc::Simulation::IRemoteAircraftProvider
//! \threadsafe
BlackMisc::Simulation::CInterpolationAndRenderingSetupPerCallsign getInterpolationSetupConsolidated(const BlackMisc::Aviation::CCallsign &callsign) const;
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;
@@ -328,7 +328,7 @@ namespace BlackCore
signals:
//! Simulator combined status
void simulatorStatusChanged(SimulatorStatus status);
void simulatorStatusChanged(SimulatorStatus status); // use emitSimulatorCombinedStatus to emit
//! Emitted when own aircraft model has changed
void ownAircraftModelChanged(const BlackMisc::Simulation::CAircraftModel &model);
@@ -518,13 +518,14 @@ namespace BlackCore
// void removedClampedLog(const BlackMisc::Aviation::CCallsign &callsign);
//! Update stats and flags
void setStatsRemoteAircraftUpdate(qint64 startTime, bool limited = false);
void finishUpdateRemoteAircraftAndSetStatistics(qint64 startTime, bool limited = false);
//! 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_pausedSimFreezesInterpolation = false; //!< paused simulator will also pause interpolation (so AI aircraft will hold)
bool m_updateRemoteAircraftInProgress = false; //!< currently updating remote aircraft
int m_updateAllRemoteAircraftCycles = 0; //!< force an update of all remote aircraft, used when own aircraft is moved, paused to make sure all remote aircraft are updated
int m_timerId = -1; //!< dispatch timer id
int m_statsUpdateAircraftRuns = 0; //!< statistics update count
int m_statsUpdateAircraftLimited = 0; //!< skipped because of max.update limitations
@@ -573,7 +574,7 @@ namespace BlackCore
// 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_statsPhysicallyAddedAircraft = 0; //!< statistics, how many aircraft added
int m_statsPhysicallyRemovedAircraft = 0; //!< statistics, how many aircraft removed
// highlighting
@@ -585,8 +586,8 @@ namespace BlackCore
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
// misc.
bool m_networkConnected = false; //!< flight network connected
BlackMisc::Aviation::CCallsignSet m_callsignsToBeRendered; //!< callsigns which will be rendered
BlackMisc::CConnectionGuard m_remoteAircraftProviderConnections; //!< connected signal/slots
};