diff --git a/src/plugins/simulator/xplane/simulatorxplane.cpp b/src/plugins/simulator/xplane/simulatorxplane.cpp index 0a11c9ebc..ed70cdef7 100644 --- a/src/plugins/simulator/xplane/simulatorxplane.cpp +++ b/src/plugins/simulator/xplane/simulatorxplane.cpp @@ -529,7 +529,8 @@ namespace BlackSimPlugin situation.getPitch().value(CAngleUnit::deg()), situation.getBank().value(CAngleUnit::deg()), situation.getHeading().value(CAngleUnit::deg()), - situation.getAdjustedMSecsSinceEpoch() - QDateTime::currentMSecsSinceEpoch()); + situation.getMSecsSinceEpoch() - QDateTime::currentMSecsSinceEpoch(), + situation.getTimeOffsetMs()); if (! isRemoteAircraftSupportingParts(situation.getCallsign())) { @@ -569,7 +570,7 @@ namespace BlackSimPlugin parts.getFlapsPercent() / 100.0, parts.isSpoilersOut() ? 1 : 0, parts.isSpoilersOut() ? 1 : 0, parts.getFlapsPercent() / 100.0, 0, parts.isAnyEngineOn() ? 0 : 0.75, 0, 0, 0, parts.getLights().isLandingOn(), parts.getLights().isBeaconOn(), parts.getLights().isStrobeOn(), parts.getLights().isNavOn(), - 0, parts.isOnGround(), parts.getAdjustedMSecsSinceEpoch() - QDateTime::currentMSecsSinceEpoch()); + 0, parts.isOnGround(), parts.getMSecsSinceEpoch() - QDateTime::currentMSecsSinceEpoch(), parts.getTimeOffsetMs()); m_traffic->setPlaneTransponder(callsign.asString(), 2000, true, false); } diff --git a/src/plugins/simulator/xplane/xswiftbustrafficproxy.cpp b/src/plugins/simulator/xplane/xswiftbustrafficproxy.cpp index 038ffa832..441c1041c 100644 --- a/src/plugins/simulator/xplane/xswiftbustrafficproxy.cpp +++ b/src/plugins/simulator/xplane/xswiftbustrafficproxy.cpp @@ -86,16 +86,16 @@ namespace BlackSimPlugin m_dbusInterface->callDBus(QLatin1String("removeAllPlanes")); } - void CXSwiftBusTrafficProxy::addPlanePosition(const QString &callsign, double latitude, double longitude, double altitude, double pitch, double roll, double heading, qint64 relativeTime) + void CXSwiftBusTrafficProxy::addPlanePosition(const QString &callsign, double latitude, double longitude, double altitude, double pitch, double roll, double heading, qint64 relativeTime, qint64 timeOffset) { - m_dbusInterface->callDBus(QLatin1String("addPlanePosition"), callsign, latitude, longitude, altitude, pitch, roll, heading, relativeTime); + m_dbusInterface->callDBus(QLatin1String("addPlanePosition"), callsign, latitude, longitude, altitude, pitch, roll, heading, relativeTime, timeOffset); } void CXSwiftBusTrafficProxy::addPlaneSurfaces(const QString &callsign, double gear, double flap, double spoiler, double speedBrake, double slat, double wingSweep, double thrust, - double elevator, double rudder, double aileron, bool landLight, bool beaconLight, bool strobeLight, bool navLight, int lightPattern, bool onGround, qint64 relativeTime) + double elevator, double rudder, double aileron, bool landLight, bool beaconLight, bool strobeLight, bool navLight, int lightPattern, bool onGround, qint64 relativeTime, qint64 timeOffset) { m_dbusInterface->callDBus(QLatin1String("addPlaneSurfaces"), callsign, gear, flap, spoiler, speedBrake, slat, wingSweep, thrust, elevator, rudder, aileron, - landLight, beaconLight, strobeLight, navLight, lightPattern, onGround, relativeTime); + landLight, beaconLight, strobeLight, navLight, lightPattern, onGround, relativeTime, timeOffset); } void CXSwiftBusTrafficProxy::setPlaneTransponder(const QString &callsign, int code, bool modeC, bool ident) diff --git a/src/plugins/simulator/xplane/xswiftbustrafficproxy.h b/src/plugins/simulator/xplane/xswiftbustrafficproxy.h index 775cf5644..c349c2ff6 100644 --- a/src/plugins/simulator/xplane/xswiftbustrafficproxy.h +++ b/src/plugins/simulator/xplane/xswiftbustrafficproxy.h @@ -103,11 +103,11 @@ namespace BlackSimPlugin void removeAllPlanes(); //! \copydoc XSwiftBus::CTraffic::addPlanePosition - void addPlanePosition(const QString &callsign, double latitude, double longitude, double altitude, double pitch, double roll, double heading, qint64 relativeTime); + void addPlanePosition(const QString &callsign, double latitude, double longitude, double altitude, double pitch, double roll, double heading, qint64 relativeTime, qint64 timeOffset); //! \copydoc XSwiftBus::CTraffic::addPlaneSurfaces void addPlaneSurfaces(const QString &callsign, double gear, double flap, double spoiler, double speedBrake, double slat, double wingSweep, double thrust, - double elevator, double rudder, double aileron, bool landLight, bool beaconLight, bool strobeLight, bool navLight, int lightPattern, bool onGround, qint64 relativeTime); + double elevator, double rudder, double aileron, bool landLight, bool beaconLight, bool strobeLight, bool navLight, int lightPattern, bool onGround, qint64 relativeTime, qint64 timeOffset); //! \copydoc XSwiftBus::CTraffic::setPlaneTransponder void setPlaneTransponder(const QString &callsign, int code, bool modeC, bool ident); diff --git a/src/xswiftbus/traffic.cpp b/src/xswiftbus/traffic.cpp index d9356dc8c..7cb7d9ad0 100644 --- a/src/xswiftbus/traffic.cpp +++ b/src/xswiftbus/traffic.cpp @@ -257,7 +257,7 @@ namespace XSwiftBus m_planesById.clear(); } - void CTraffic::addPlanePosition(const QString &callsign, double latitude, double longitude, double altitude, double pitch, double roll, double heading, qint64 relativeTime) + void CTraffic::addPlanePosition(const QString &callsign, double latitude, double longitude, double altitude, double pitch, double roll, double heading, qint64 relativeTime, qint64 timeOffset) { const auto plane = m_planesByCallsign.value(callsign, nullptr); if (plane) @@ -273,14 +273,15 @@ namespace XSwiftBus CSpeed(0, CSpeedUnit::kts()) ); situation.setMSecsSinceEpoch(relativeTime + QDateTime::currentMSecsSinceEpoch()); + situation.setTimeOffsetMs(timeOffset); plane->interpolator.addAircraftSituation(situation); } } void CTraffic::addPlaneSurfaces(const QString &callsign, double gear, double flap, double spoiler, double speedBrake, double slat, double wingSweep, double thrust, - double elevator, double rudder, double aileron, bool landLight, bool beaconLight, bool strobeLight, bool navLight, int lightPattern, bool onGround, qint64 relativeTime) + double elevator, double rudder, double aileron, bool landLight, bool beaconLight, bool strobeLight, bool navLight, int lightPattern, bool onGround, qint64 relativeTime, qint64 timeOffset) { - const auto surfaces = std::make_pair(relativeTime + QDateTime::currentMSecsSinceEpoch(), [ = ](Plane *plane) + const auto surfaces = std::make_pair(relativeTime + timeOffset + QDateTime::currentMSecsSinceEpoch(), [ = ](Plane *plane) { plane->hasSurfaces = true; plane->targetGearPosition = gear; @@ -309,6 +310,7 @@ namespace XSwiftBus BlackMisc::Aviation::CAircraftParts parts; parts.setOnGround(onGround); parts.setMSecsSinceEpoch(relativeTime + QDateTime::currentMSecsSinceEpoch()); + parts.setTimeOffsetMs(timeOffset); plane->interpolator.addAircraftParts(parts); } } diff --git a/src/xswiftbus/traffic.h b/src/xswiftbus/traffic.h index 582c9000e..48f6fd438 100644 --- a/src/xswiftbus/traffic.h +++ b/src/xswiftbus/traffic.h @@ -107,11 +107,11 @@ namespace XSwiftBus void removeAllPlanes(); //! Set the position of a traffic aircraft - void addPlanePosition(const QString &callsign, double latitude, double longitude, double altitude, double pitch, double roll, double heading, qint64 relativeTime); + void addPlanePosition(const QString &callsign, double latitude, double longitude, double altitude, double pitch, double roll, double heading, qint64 relativeTime, qint64 timeOffset); //! Set the flight control surfaces and lights of a traffic aircraft void addPlaneSurfaces(const QString &callsign, double gear, double flap, double spoiler, double speedBrake, double slat, double wingSweep, double thrust, - double elevator, double rudder, double aileron, bool landLight, bool beaconLight, bool strobeLight, bool navLight, int lightPattern, bool onGround, qint64 relativeTime); + double elevator, double rudder, double aileron, bool landLight, bool beaconLight, bool strobeLight, bool navLight, int lightPattern, bool onGround, qint64 relativeTime, qint64 timeOffset); //! Set the transponder of a traffic aircraft void setPlaneTransponder(const QString &callsign, int code, bool modeC, bool ident);