Ref T436, allow to set a global offset altitude for testing (example: ".altos ? -10m")

This commit is contained in:
Klaus Basan
2018-11-23 02:43:11 +01:00
parent 31ba0c1520
commit 62860eb30b
4 changed files with 37 additions and 20 deletions

View File

@@ -671,24 +671,20 @@ namespace BlackMisc
return m_testOffset.contains(callsign);
}
bool CRemoteAircraftProvider::hasTestAltitudeOffsetGlobalValue() const
{
QReadLocker l(&m_lockSituations);
return m_testOffset.contains(testAltitudeOffsetCallsign());
}
CAircraftSituation CRemoteAircraftProvider::addTestAltitudeOffsetToSituation(const CAircraftSituation &situation) const
{
// for global offset testing set "true"
constexpr bool globalOffsetTest = false;
const CCallsign cs(situation.getCallsign());
// cppcheck-suppress knownConditionTrueFalse
if (!globalOffsetTest && !this->hasTestAltitudeOffset(cs)) { return situation; }
CLength os;
if (globalOffsetTest)
{
os = CLength(100, CLengthUnit::ft());
}
else
{
QReadLocker l(&m_lockSituations);
os = m_testOffset.value(cs);
}
const bool globalOffset = this->hasTestAltitudeOffsetGlobalValue();
if (!globalOffset && !this->hasTestAltitudeOffset(cs)) { return situation; }
QReadLocker l(&m_lockSituations);
const CLength os = m_testOffset.contains(cs) ? m_testOffset.value(cs) : m_testOffset.value(testAltitudeOffsetCallsign());
if (os.isNull() || os.isZeroEpsilonConsidered()) { return situation; }
return situation.withAltitudeOffset(os);
}
@@ -1047,5 +1043,11 @@ namespace BlackMisc
partsList.removeBefore(ts);
Q_ASSERT_X(partsList.size() >= 1, Q_FUNC_INFO, "Need at least 1 value");
}
const CCallsign &IRemoteAircraftProvider::testAltitudeOffsetCallsign()
{
static const CCallsign wildcard("ZZZZ");
return wildcard;
}
} // namespace
} // namespace