mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-18 19:35:33 +08:00
refactor: Simplify CInterpolator::getInterpolation()
Avoid requiring a do {} while(false) with nested if & break by using a simple if()
This commit is contained in:
@@ -215,17 +215,16 @@ namespace BlackMisc::Simulation
|
|||||||
CInterpolationResult CInterpolator<Derived>::getInterpolation(qint64 currentTimeSinceEpoc, const CInterpolationAndRenderingSetupPerCallsign &setup, uint32_t aircraftNumber)
|
CInterpolationResult CInterpolator<Derived>::getInterpolation(qint64 currentTimeSinceEpoc, const CInterpolationAndRenderingSetupPerCallsign &setup, uint32_t aircraftNumber)
|
||||||
{
|
{
|
||||||
CInterpolationResult result;
|
CInterpolationResult result;
|
||||||
do
|
|
||||||
|
const bool init = this->initIniterpolationStepData(currentTimeSinceEpoc, setup, aircraftNumber);
|
||||||
|
Q_ASSERT_X(!m_currentInterpolationStatus.isInterpolated(), Q_FUNC_INFO, "Expect reset status");
|
||||||
|
if (init || m_unitTest) // ignore failure in unittest
|
||||||
{
|
{
|
||||||
const bool init = this->initIniterpolationStepData(currentTimeSinceEpoc, setup, aircraftNumber);
|
|
||||||
Q_ASSERT_X(!m_currentInterpolationStatus.isInterpolated(), Q_FUNC_INFO, "Expect reset status");
|
|
||||||
if (!m_unitTest && !init) { break; } // failure in real scenarios, unit tests move on
|
|
||||||
Q_ASSERT_X(m_currentTimeMsSinceEpoch > 0, Q_FUNC_INFO, "No valid timestamp, interpolator initialized?");
|
Q_ASSERT_X(m_currentTimeMsSinceEpoch > 0, Q_FUNC_INFO, "No valid timestamp, interpolator initialized?");
|
||||||
const CAircraftSituation interpolatedSituation = this->getInterpolatedSituation();
|
const CAircraftSituation interpolatedSituation = this->getInterpolatedSituation();
|
||||||
const CAircraftParts interpolatedParts = this->getInterpolatedOrGuessedParts(aircraftNumber);
|
const CAircraftParts interpolatedParts = this->getInterpolatedOrGuessedParts(aircraftNumber);
|
||||||
result.setValues(interpolatedSituation, interpolatedParts);
|
result.setValues(interpolatedSituation, interpolatedParts);
|
||||||
}
|
}
|
||||||
while (false);
|
|
||||||
|
|
||||||
result.setStatus(m_currentInterpolationStatus, m_currentPartsStatus);
|
result.setStatus(m_currentInterpolationStatus, m_currentPartsStatus);
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
Reference in New Issue
Block a user