Ref T268, check in XPlane driver

This commit is contained in:
Klaus Basan
2018-07-11 23:41:31 +02:00
parent b98a405ed2
commit a508ad4ccb
3 changed files with 36 additions and 2 deletions

View File

@@ -52,6 +52,7 @@
#include "blackmisc/dbusserver.h"
#include "blackmisc/iterator.h"
#include "blackmisc/logmessage.h"
#include "blackconfig/buildconfig.h"
#include <QColor>
#include <QDBusServiceWatcher>
@@ -60,6 +61,7 @@
#include <QtGlobal>
#include <QPointer>
using namespace BlackConfig;
using namespace BlackMisc;
using namespace BlackMisc::Aviation;
using namespace BlackMisc::Network;
@@ -558,7 +560,11 @@ namespace BlackSimPlugin
if (callsign.isEmpty()) { return false; } // can happen if an object is not an aircraft
// really remove from simulator
if (!m_xplaneAircraftObjects.contains(callsign) && !m_pendingToBeAddedAircraft.containsCallsign(callsign)) { return false; } // already fully removed or not yet added
if (!m_xplaneAircraftObjects.contains(callsign) && !m_pendingToBeAddedAircraft.containsCallsign(callsign) && !m_addingInProgressAircraft.contains(callsign))
{
// not existing aircraft
return false;
}
// mark in provider
const bool updated = this->updateAircraftRendered(callsign, false);
@@ -577,6 +583,17 @@ namespace BlackSimPlugin
aircraft.setRendered(false);
emit this->aircraftRenderingChanged(aircraft);
}
else if (m_addingInProgressAircraft.contains(callsign))
{
// we are just about to add that aircraft
QPointer<CSimulatorXPlane> myself(this);
QTimer::singleShot(TimeoutAdding, this, [ = ]
{
if (!myself) { return; }
m_addingInProgressAircraft.remove(callsign); // remove as "in progress"
this->physicallyRemoveRemoteAircraft(callsign); // and remove from sim. if it was added in the mean time
});
}
}
m_trafficProxy->removePlane(callsign.asString());
@@ -777,6 +794,10 @@ namespace BlackSimPlugin
if (!planesPositions.isEmpty())
{
if (CBuildConfig::isLocalDeveloperDebugBuild())
{
Q_ASSERT_X(planesPositions.hasSameSizes(), Q_FUNC_INFO, "Mismatching sizes");
}
m_trafficProxy->setPlanesPositions(planesPositions);
}

View File

@@ -6,7 +6,7 @@ TARGET = simulatorxplane
TEMPLATE = lib
CONFIG += plugin shared
CONFIG += blackmisc blackcore blackgui
CONFIG += blackmisc blackcore blackgui blackconfig
DEPENDPATH += . $$SourceRoot/src
INCLUDEPATH += . $$SourceRoot/src

View File

@@ -40,6 +40,19 @@ namespace BlackSimPlugin
//! Is empty?
bool isEmpty() const { return callsigns.isEmpty(); }
//! Check function
bool hasSameSizes() const
{
const int s = callsigns.size();
if (s != latitudes.size()) { return false; }
if (s != longitudes.size()) { return false; }
if (s != altitudes.size()) { return false; }
if (s != pitches.size()) { return false; }
if (s != rolls.size()) { return false; }
if (s != headings.size()) { return false; }
return true;
}
QStringList callsigns; //!< List of callsigns
QList<double> latitudes; //!< List of latitudes
QList<double> longitudes; //!< List of longitudes