Skip to content

Commit

Permalink
Revert "Interpolate the dynamic offset time for aircraft situations"
Browse files Browse the repository at this point in the history
This reverts commit efb6a32.
  • Loading branch information
ltoenning committed Feb 1, 2024
1 parent 0970134 commit 5e98432
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 17 deletions.
17 changes: 2 additions & 15 deletions src/blackcore/fsd/fsdclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1907,7 +1907,6 @@ namespace BlackCore::Fsd

qint64 CFSDClient::receivedPositionFixTsAndGetOffsetTime(const CCallsign &callsign, qint64 markerTs)
{
// \fixme This logic should be in a different class
Q_ASSERT_X(!callsign.isEmpty(), Q_FUNC_INFO, "Need callsign");

if (markerTs < 0) { markerTs = QDateTime::currentMSecsSinceEpoch(); }
Expand All @@ -1925,25 +1924,13 @@ namespace BlackCore::Fsd

int count = 0;
const qint64 avgTimeMs = this->averageOffsetTimeMs(callsign, count, 3); // latest average
qint64 targetOffsetTime = CFsdSetup::c_positionTimeOffsetMsec;
qint64 offsetTime = CFsdSetup::c_positionTimeOffsetMsec;

if (avgTimeMs < CFsdSetup::c_minimumPositionTimeOffsetMsec && count >= 3)
{
targetOffsetTime = CFsdSetup::c_minimumPositionTimeOffsetMsec;
offsetTime = CFsdSetup::c_minimumPositionTimeOffsetMsec;
}

const qint64 previousInterpolatedOffsetTime = m_interpolatedOffsetTime.value(callsign, 0);
qint64 offsetDiff = 0;
if (targetOffsetTime < previousInterpolatedOffsetTime)
{
offsetDiff = std::max(targetOffsetTime - previousInterpolatedOffsetTime, diff / -c_offsetTimeInterpolationInverseRate);
}
else
{
offsetDiff = std::min(targetOffsetTime - previousInterpolatedOffsetTime, diff / c_offsetTimeInterpolationInverseRate);
}
qint64 offsetTime = previousInterpolatedOffsetTime + offsetDiff;
m_interpolatedOffsetTime.insert(callsign, offsetTime);
return m_additionalOffsetTime + offsetTime;
}

Expand Down
2 changes: 0 additions & 2 deletions src/blackcore/fsd/fsdclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -575,8 +575,6 @@ namespace BlackCore::Fsd
QHash<BlackMisc::Aviation::CCallsign, PendingAtisQuery> m_pendingAtisQueries;
QHash<BlackMisc::Aviation::CCallsign, qint64> m_lastPositionUpdate;
QHash<BlackMisc::Aviation::CCallsign, QList<qint64>> m_lastOffsetTimes; //!< latest offset first
QHash<BlackMisc::Aviation::CCallsign, qint64> m_interpolatedOffsetTime;
static const int c_offsetTimeInterpolationInverseRate = 4;

BlackMisc::Aviation::CAtcStationList m_atcStations;

Expand Down

0 comments on commit 5e98432

Please sign in to comment.