From 2b76b27f97e9050322898fac4cc30e85fdf5625a Mon Sep 17 00:00:00 2001 From: Mathew Sutcliffe Date: Tue, 10 Jan 2017 03:00:07 +0000 Subject: [PATCH] refs #852 On each position update for aircraft not supporting parts, X-Plane driver synthesizes a parts update with guessed onGround flag. --- .../simulator/xplane/simulatorxplane.cpp | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/plugins/simulator/xplane/simulatorxplane.cpp b/src/plugins/simulator/xplane/simulatorxplane.cpp index 4ea4b5950..193d524ed 100644 --- a/src/plugins/simulator/xplane/simulatorxplane.cpp +++ b/src/plugins/simulator/xplane/simulatorxplane.cpp @@ -516,6 +516,27 @@ namespace BlackSimPlugin situation.getBank().value(CAngleUnit::deg()), situation.getHeading().value(CAngleUnit::deg()), situation.getAdjustedMSecsSinceEpoch() - QDateTime::currentMSecsSinceEpoch()); + + if (! isRemoteAircraftSupportingParts(situation.getCallsign())) + { + // if aircraft not supporting parts then guess (currently only onGround is guessed) + //! \todo not working for vtol + BlackMisc::Aviation::CAircraftParts parts; + parts.setMSecsSinceEpoch(situation.getMSecsSinceEpoch()); + parts.setTimeOffsetMs(situation.getTimeOffsetMs()); + if (situation.getGroundSpeed() < CSpeed(50, CSpeedUnit::kts())) + { + const auto nearestAirport = std::min_element(m_airportsInRange.cbegin(), m_airportsInRange.cend(), [&situation](auto &&a, auto &&b) + { + return calculateEuclideanDistanceSquared(situation, a) < calculateEuclideanDistanceSquared(situation, b); + }); + if (nearestAirport != m_airportsInRange.cend() && situation.getAltitude() - nearestAirport->getElevation() < CLength(50, CLengthUnit::ft())) + { + parts.setOnGround(true); + } + } + ps_remoteProviderAddAircraftParts(situation.getCallsign(), parts); + } } void CSimulatorXPlane::ps_remoteProviderAddAircraftParts(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CAircraftParts &parts)