mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-07 02:35:33 +08:00
Load X-Plane remote aircrafts one by one sequentially
This commit is contained in:
@@ -76,8 +76,7 @@ namespace XSwiftBus
|
||||
{
|
||||
if (! s_legacyDataOK) { return false; }
|
||||
|
||||
auto dir = g_xplanePath + "Resources" + g_sep + "plugins" + g_sep + "xswiftbus" + g_sep;
|
||||
auto err = XPMPMultiplayerInit(preferences, preferences, dir.c_str());
|
||||
auto err = XPMPMultiplayerInit(preferences, preferences);
|
||||
if (*err) { cleanup(); return false; }
|
||||
m_initialized = true;
|
||||
|
||||
@@ -124,6 +123,22 @@ namespace XSwiftBus
|
||||
sendDBusMessage(signalRemoteAircraftData);
|
||||
}
|
||||
|
||||
void CTraffic::emitPlaneAdded(const std::string &callsign)
|
||||
{
|
||||
CDBusMessage signalPlaneAdded = CDBusMessage::createSignal(XSWIFTBUS_TRAFFIC_OBJECTPATH, XSWIFTBUS_TRAFFIC_INTERFACENAME, "remoteAircraftAdded");
|
||||
signalPlaneAdded.beginArgumentWrite();
|
||||
signalPlaneAdded.appendArgument(callsign);
|
||||
sendDBusMessage(signalPlaneAdded);
|
||||
}
|
||||
|
||||
void CTraffic::emitPlaneAddingFailed(const std::string &callsign)
|
||||
{
|
||||
CDBusMessage signalPlaneAddingFailed = CDBusMessage::createSignal(XSWIFTBUS_TRAFFIC_OBJECTPATH, XSWIFTBUS_TRAFFIC_INTERFACENAME, "remoteAircraftAddingFailed");
|
||||
signalPlaneAddingFailed.beginArgumentWrite();
|
||||
signalPlaneAddingFailed.appendArgument(callsign);
|
||||
sendDBusMessage(signalPlaneAddingFailed);
|
||||
}
|
||||
|
||||
void CTraffic::orbitRemotePlane(const std::string &callsign)
|
||||
{
|
||||
m_planeViewCallsign = callsign;
|
||||
@@ -216,7 +231,7 @@ namespace XSwiftBus
|
||||
}
|
||||
else
|
||||
{
|
||||
id = XPMPCreatePlaneWithModelName(modelName.c_str(), aircraftIcao.c_str(), airlineIcao.c_str(), livery.c_str(), getPlaneData, static_cast<void *>(this));
|
||||
id = XPMPCreatePlaneWithModelName(modelName.c_str(), aircraftIcao.c_str(), airlineIcao.c_str(), livery.c_str(), getPlaneData, planeLoaded, static_cast<void *>(this));
|
||||
}
|
||||
|
||||
if (id)
|
||||
|
||||
@@ -125,6 +125,8 @@ namespace XSwiftBus
|
||||
|
||||
void emitSimFrame();
|
||||
void emitRemoteAircraftData(const std::string &callsign, double latitude, double longitude, double elevation, double modelVerticalOffset);
|
||||
void emitPlaneAdded(const std::string &callsign);
|
||||
void emitPlaneAddingFailed(const std::string &callsign);
|
||||
void orbitRemotePlane(const std::string &callsign);
|
||||
|
||||
static int preferences(const char *section, const char *name, int def);
|
||||
@@ -169,6 +171,16 @@ namespace XSwiftBus
|
||||
{
|
||||
return static_cast<CTraffic *>(self)->getPlaneData(id, dataType, io_data);
|
||||
}
|
||||
|
||||
static void planeLoaded(void *id, bool succeeded, void *self)
|
||||
{
|
||||
auto *traffic = static_cast<CTraffic *>(self);
|
||||
auto planeIt = traffic->m_planesById.find(id);
|
||||
if (planeIt == traffic->m_planesById.end()) { return; }
|
||||
|
||||
if (succeeded) { traffic->emitPlaneAdded(planeIt->second->callsign); }
|
||||
else { traffic->emitPlaneAddingFailed(planeIt->second->callsign); }
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user