mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-20 04:25:42 +08:00
refs #925 XP driver sends parts to xbus, and guesses gear and lights if parts not available.
This commit is contained in:
@@ -527,7 +527,7 @@ namespace BlackSimPlugin
|
|||||||
|
|
||||||
if (! isRemoteAircraftSupportingParts(situation.getCallsign()))
|
if (! isRemoteAircraftSupportingParts(situation.getCallsign()))
|
||||||
{
|
{
|
||||||
// if aircraft not supporting parts then guess (currently only onGround is guessed)
|
// if aircraft not supporting parts then guess the basics (onGround, gear, lights)
|
||||||
//! \todo not working for vtol
|
//! \todo not working for vtol
|
||||||
BlackMisc::Aviation::CAircraftParts parts;
|
BlackMisc::Aviation::CAircraftParts parts;
|
||||||
parts.setMSecsSinceEpoch(situation.getMSecsSinceEpoch());
|
parts.setMSecsSinceEpoch(situation.getMSecsSinceEpoch());
|
||||||
@@ -541,8 +541,17 @@ namespace BlackSimPlugin
|
|||||||
if (nearestAirport != m_airportsInRange.cend() && situation.getAltitude() - nearestAirport->getElevation() < CLength(50, CLengthUnit::ft()))
|
if (nearestAirport != m_airportsInRange.cend() && situation.getAltitude() - nearestAirport->getElevation() < CLength(50, CLengthUnit::ft()))
|
||||||
{
|
{
|
||||||
parts.setOnGround(true);
|
parts.setOnGround(true);
|
||||||
|
parts.setGearDown(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (situation.getAltitude() < CAltitude(10'000, CLengthUnit::ft()))
|
||||||
|
{
|
||||||
|
parts.setLights({ true, true, true, true, true, true, true, true });
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
parts.setLights({ true, false, false, true, true, true, true, true });
|
||||||
|
}
|
||||||
ps_remoteProviderAddAircraftParts(situation.getCallsign(), parts);
|
ps_remoteProviderAddAircraftParts(situation.getCallsign(), parts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -550,9 +559,11 @@ namespace BlackSimPlugin
|
|||||||
void CSimulatorXPlane::ps_remoteProviderAddAircraftParts(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CAircraftParts &parts)
|
void CSimulatorXPlane::ps_remoteProviderAddAircraftParts(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CAircraftParts &parts)
|
||||||
{
|
{
|
||||||
Q_ASSERT(isConnected());
|
Q_ASSERT(isConnected());
|
||||||
//! \fixme Parts currently not used by libxplanemp
|
m_traffic->addPlaneSurfaces(callsign.asString(), parts.isGearDown() ? 1 : 0,
|
||||||
m_traffic->addPlaneSurfaces(callsign.asString(), true, 0, 0, 0, 0, 0, 0, 0, 0, 0, true, true, true, true, 0, parts.isOnGround(),
|
parts.getFlapsPercent() / 100.0, parts.isSpoilersOut() ? 1 : 0, parts.isSpoilersOut() ? 1 : 0, parts.getFlapsPercent() / 100.0,
|
||||||
parts.getAdjustedMSecsSinceEpoch() - QDateTime::currentMSecsSinceEpoch());
|
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());
|
||||||
m_traffic->setPlaneTransponder(callsign.asString(), 2000, true, false);
|
m_traffic->setPlaneTransponder(callsign.asString(), 2000, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -278,8 +278,7 @@ namespace XBus
|
|||||||
void CTraffic::addPlaneSurfaces(const QString &callsign, double gear, double flap, double spoiler, double speedBrake, double slat, double wingSweep, double thrust,
|
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)
|
||||||
{
|
{
|
||||||
const auto plane = m_planesByCallsign.value(callsign, nullptr);
|
const auto surfaces = std::make_pair(relativeTime + QDateTime::currentMSecsSinceEpoch(), [ = ](Plane *plane)
|
||||||
if (plane)
|
|
||||||
{
|
{
|
||||||
plane->hasSurfaces = true;
|
plane->hasSurfaces = true;
|
||||||
plane->surfaces.gearPosition = gear;
|
plane->surfaces.gearPosition = gear;
|
||||||
@@ -297,6 +296,13 @@ namespace XBus
|
|||||||
plane->surfaces.lights.strbLights = strobeLight;
|
plane->surfaces.lights.strbLights = strobeLight;
|
||||||
plane->surfaces.lights.navLights = navLight;
|
plane->surfaces.lights.navLights = navLight;
|
||||||
plane->surfaces.lights.flashPattern = lightPattern;
|
plane->surfaces.lights.flashPattern = lightPattern;
|
||||||
|
});
|
||||||
|
|
||||||
|
const auto plane = m_planesByCallsign.value(callsign, nullptr);
|
||||||
|
if (plane)
|
||||||
|
{
|
||||||
|
if (plane->hasSurfaces) { plane->pendingSurfaces.push_back(surfaces); }
|
||||||
|
else { surfaces.second(plane); }
|
||||||
|
|
||||||
BlackMisc::Aviation::CAircraftParts parts;
|
BlackMisc::Aviation::CAircraftParts parts;
|
||||||
parts.setOnGround(onGround);
|
parts.setOnGround(onGround);
|
||||||
@@ -372,6 +378,12 @@ namespace XBus
|
|||||||
case xpmpDataType_Surfaces:
|
case xpmpDataType_Surfaces:
|
||||||
if (plane->hasSurfaces)
|
if (plane->hasSurfaces)
|
||||||
{
|
{
|
||||||
|
const auto currentTime = QDateTime::currentMSecsSinceEpoch();
|
||||||
|
while (! plane->pendingSurfaces.isEmpty() && plane->pendingSurfaces.front().first <= currentTime)
|
||||||
|
{
|
||||||
|
plane->pendingSurfaces.front().second(plane);
|
||||||
|
plane->pendingSurfaces.pop_front();
|
||||||
|
}
|
||||||
const auto io_surfaces = static_cast<XPMPPlaneSurfaces_t *>(io_data);
|
const auto io_surfaces = static_cast<XPMPPlaneSurfaces_t *>(io_data);
|
||||||
|
|
||||||
if (memcmpPayload(io_surfaces, &plane->surfaces))
|
if (memcmpPayload(io_surfaces, &plane->surfaces))
|
||||||
|
|||||||
@@ -22,6 +22,8 @@
|
|||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include "XPMPMultiplayer.h"
|
#include "XPMPMultiplayer.h"
|
||||||
|
#include <functional>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
//! \cond PRIVATE
|
//! \cond PRIVATE
|
||||||
#define XBUS_TRAFFIC_INTERFACENAME "org.swift_project.xbus.traffic"
|
#define XBUS_TRAFFIC_INTERFACENAME "org.swift_project.xbus.traffic"
|
||||||
@@ -138,6 +140,7 @@ namespace XBus
|
|||||||
CTerrainProbe terrainProbe;
|
CTerrainProbe terrainProbe;
|
||||||
BlackMisc::Simulation::CInterpolationHints hints();
|
BlackMisc::Simulation::CInterpolationHints hints();
|
||||||
XPMPPlaneSurfaces_t surfaces;
|
XPMPPlaneSurfaces_t surfaces;
|
||||||
|
QVector<std::pair<qint64, std::function<void(Plane *)>>> pendingSurfaces;
|
||||||
XPMPPlaneRadar_t xpdr;
|
XPMPPlaneRadar_t xpdr;
|
||||||
Plane(void *id_, QString callsign_, QString aircraftIcao_, QString airlineIcao_, QString livery_);
|
Plane(void *id_, QString callsign_, QString aircraftIcao_, QString airlineIcao_, QString livery_);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user