[FG] Update compatibility check

This commit is contained in:
Lars Toenning
2020-07-06 23:52:27 +02:00
parent e7bc66076c
commit 89434c355d
2 changed files with 16 additions and 10 deletions

View File

@@ -62,8 +62,6 @@
#include <QPointer> #include <QPointer>
#include <math.h> #include <math.h>
#define FGSWIFTBUS_API_VERSION 1
using namespace BlackConfig; using namespace BlackConfig;
using namespace BlackMisc; using namespace BlackMisc;
using namespace BlackMisc::Aviation; using namespace BlackMisc::Aviation;
@@ -88,6 +86,8 @@ namespace BlackSimPlugin
{ {
namespace Flightgear namespace Flightgear
{ {
int FGSWIFTBUS_API_VERSION = -1;
QList<int> incompatibleVersions = {};
CSimulatorFlightgear::CSimulatorFlightgear(const CSimulatorPluginInfo &info, CSimulatorFlightgear::CSimulatorFlightgear(const CSimulatorPluginInfo &info,
IOwnAircraftProvider *ownAircraftProvider, IOwnAircraftProvider *ownAircraftProvider,
IRemoteAircraftProvider *remoteAircraftProvider, IRemoteAircraftProvider *remoteAircraftProvider,
@@ -166,7 +166,7 @@ namespace BlackSimPlugin
u++; u++;
} }
if (!parts.isNull()) if (parts.isNull() && Flightgear::FGSWIFTBUS_API_VERSION >= 2)
{ {
PlanesSurfaces surfaces; PlanesSurfaces surfaces;
surfaces.push_back(callsign, parts); surfaces.push_back(callsign, parts);
@@ -536,10 +536,12 @@ namespace BlackSimPlugin
PlanesPositions pos; PlanesPositions pos;
pos.push_back(newRemoteAircraft.getSituation()); pos.push_back(newRemoteAircraft.getSituation());
m_trafficProxy->setPlanesPositions(pos); m_trafficProxy->setPlanesPositions(pos);
if(Flightgear::FGSWIFTBUS_API_VERSION >= 2)
{
PlanesSurfaces surfaces; PlanesSurfaces surfaces;
surfaces.push_back(newRemoteAircraft.getCallsign(), newRemoteAircraft.getParts()); surfaces.push_back(newRemoteAircraft.getCallsign(), newRemoteAircraft.getParts());
m_trafficProxy->setPlanesSurfaces(surfaces); m_trafficProxy->setPlanesSurfaces(surfaces);
}
} }
else else
@@ -690,7 +692,7 @@ namespace BlackSimPlugin
} // all callsigns } // all callsigns
if (!planesTransponders.isEmpty()) if (!planesTransponders.isEmpty() && Flightgear::FGSWIFTBUS_API_VERSION >= 2)
{ {
m_trafficProxy->setPlanesTransponders(planesTransponders); m_trafficProxy->setPlanesTransponders(planesTransponders);
} }
@@ -704,7 +706,7 @@ namespace BlackSimPlugin
m_trafficProxy->setPlanesPositions(planesPositions); m_trafficProxy->setPlanesPositions(planesPositions);
} }
if (! planesSurfaces.isEmpty()) if (! planesSurfaces.isEmpty() && Flightgear::FGSWIFTBUS_API_VERSION >= 2)
{ {
m_trafficProxy->setPlanesSurfaces(planesSurfaces); m_trafficProxy->setPlanesSurfaces(planesSurfaces);
} }
@@ -1086,7 +1088,9 @@ namespace BlackSimPlugin
bool result = service.isValid() && traffic.isValid(); bool result = service.isValid() && traffic.isValid();
if (! result) { return; } if (! result) { return; }
if (service.getVersionNumber() != FGSWIFTBUS_API_VERSION) Flightgear::FGSWIFTBUS_API_VERSION = service.getVersionNumber();
if (Flightgear::incompatibleVersions.contains(Flightgear::FGSWIFTBUS_API_VERSION))
{ {
CLogMessage(this).error(u"This version of swift is not compatible with this Flightgear version. For further information check http://wiki.flightgear.org/Swift."); CLogMessage(this).error(u"This version of swift is not compatible with this Flightgear version. For further information check http://wiki.flightgear.org/Swift.");
return; return;

View File

@@ -65,6 +65,8 @@ namespace BlackSimPlugin
{ {
namespace Flightgear namespace Flightgear
{ {
extern int FGSWIFTBUS_API_VERSION;
extern QList<int> incompatibleVersions;
class CFGSwiftBusServiceProxy; class CFGSwiftBusServiceProxy;
class CFGSwiftBusTrafficProxy; class CFGSwiftBusTrafficProxy;