mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 12:55:33 +08:00
refs #852 Add a time offset to CAircraftParts.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user