refs #852 Add a time offset to CAircraftParts.

This commit is contained in:
Mathew Sutcliffe
2017-01-09 01:42:17 +00:00
parent 4d30ce40c7
commit 3e70ab1207
2 changed files with 22 additions and 1 deletions

View File

@@ -1227,11 +1227,21 @@ namespace BlackCore
BLACK_VERIFY_X(!callsign.isEmpty(), Q_FUNC_INFO, "empty callsign");
if (callsign.isEmpty()) { return; }
// get time offset from situation
qint64 timeOffsetMs = 6000; //! \fixme 6000 is assumed default offset, copied from CNetworkVatlib::onPilotPositionUpdate
{
QReadLocker lock(&m_lockSituations);
const CAircraftSituationList &situationList = this->m_situationsByCallsign[callsign];
if (!situationList.isEmpty()) { timeOffsetMs = situationList[0].getTimeOffsetMs(); }
}
// list sorted from new to old
QWriteLocker lock(&m_lockParts);
CAircraftPartsList &partsList = this->m_partsByCallsign[callsign];
partsList.push_frontMaxElements(parts, MaxPartsPerCallsign);
partsList.front().setTimeOffsetMs(timeOffsetMs);
if (!m_aircraftSupportingParts.contains(callsign))
{
m_aircraftSupportingParts.push_back(callsign); // mark as callsign which supports parts

View File

@@ -116,6 +116,15 @@ namespace BlackMisc
//! Set aircraft on ground
void setOnGround(bool onGround) { m_isOnGround = onGround; }
//! Milliseconds to add to timestamp for interpolation
void setTimeOffsetMs(qint64 offset) { this->m_timeOffsetMs = offset; }
//! Milliseconds to add to timestamp for interpolation
qint64 getTimeOffsetMs() const { return this->m_timeOffsetMs; }
//! Timestamp with offset added for interpolation
qint64 getAdjustedMSecsSinceEpoch() const { return this->getMSecsSinceEpoch() + this->getTimeOffsetMs(); }
//! \copydoc BlackMisc::Mixin::String::toQString
QString convertToQString(bool i18n = false) const;
@@ -126,6 +135,7 @@ namespace BlackMisc
bool m_gearDown = false;
bool m_spoilersOut = false;
bool m_isOnGround = false;
qint64 m_timeOffsetMs = 0;
BLACK_METACLASS(
CAircraftParts,
@@ -135,7 +145,8 @@ namespace BlackMisc
BLACK_METAMEMBER_NAMED(spoilersOut, "spoilers_out"),
BLACK_METAMEMBER_NAMED(engines, "engines"),
BLACK_METAMEMBER_NAMED(isOnGround, "on_ground"),
BLACK_METAMEMBER(timestampMSecsSinceEpoch, 0, DisabledForJson | DisabledForComparison)
BLACK_METAMEMBER(timestampMSecsSinceEpoch, 0, DisabledForJson | DisabledForComparison),
BLACK_METAMEMBER(timeOffsetMs, 0, DisabledForJson | DisabledForComparison)
);
};
} // namespace