mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 11:55:35 +08:00
refs #369, adjusted simulator drivers to changed interpolator and
removed addAircraftSituation
This commit is contained in:
@@ -19,23 +19,25 @@
|
||||
#include <QScopedArrayPointer>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackCore;
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackMisc::Simulation;
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
|
||||
namespace BlackSimPlugin
|
||||
{
|
||||
namespace Fs9
|
||||
{
|
||||
CFs9Client::CFs9Client(QObject *owner, const QString &callsign, const CTime &updateInterval) :
|
||||
CFs9Client::CFs9Client(
|
||||
IRenderedAircraftProviderReadOnly *renderedAircraftProvider, QObject *owner, const QString &callsign, const CTime &updateInterval) :
|
||||
CDirectPlayPeer(owner, callsign),
|
||||
m_updateInterval(updateInterval)
|
||||
{
|
||||
}
|
||||
m_renderedAircraftProvider(renderedAircraftProvider), m_updateInterval(updateInterval)
|
||||
{ }
|
||||
|
||||
CFs9Client::~CFs9Client()
|
||||
{
|
||||
if(m_hostAddress) m_hostAddress->Release();
|
||||
m_hostAddress = nullptr;
|
||||
if (m_hostAddress) m_hostAddress->Release();
|
||||
m_hostAddress = nullptr;
|
||||
}
|
||||
|
||||
void CFs9Client::sendTextMessage(const QString &textMessage)
|
||||
@@ -54,59 +56,55 @@ namespace BlackSimPlugin
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
// Create our IDirectPlay8Address Host Address
|
||||
if( FAILED( hr = CoCreateInstance(CLSID_DirectPlay8Address, nullptr,
|
||||
CLSCTX_INPROC_SERVER,
|
||||
IID_IDirectPlay8Address,
|
||||
reinterpret_cast<void **>(&m_hostAddress) ) ) )
|
||||
if (FAILED(hr = CoCreateInstance(CLSID_DirectPlay8Address, nullptr,
|
||||
CLSCTX_INPROC_SERVER,
|
||||
IID_IDirectPlay8Address,
|
||||
reinterpret_cast<void **>(&m_hostAddress))))
|
||||
{
|
||||
printDirectPlayError(hr);
|
||||
return;
|
||||
}
|
||||
|
||||
if (FAILED (hr = m_hostAddress->BuildFromURLA(hostAddress.toLatin1().data())))
|
||||
if (FAILED(hr = m_hostAddress->BuildFromURLA(hostAddress.toLatin1().data())))
|
||||
{
|
||||
printDirectPlayError(hr);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void CFs9Client::addAircraftSituation(const CAircraftSituation &situation)
|
||||
void CFs9Client::timerEvent(QTimerEvent *event)
|
||||
{
|
||||
QMutexLocker locker(&m_mutexInterpolator);
|
||||
m_interpolator.addAircraftSituation(situation);
|
||||
}
|
||||
Q_UNUSED(event);
|
||||
if (m_clientStatus == Disconnected) { return; }
|
||||
|
||||
void CFs9Client::timerEvent(QTimerEvent * /*event*/)
|
||||
{
|
||||
if (m_clientStatus == Disconnected) return;
|
||||
|
||||
QMutexLocker locker(&m_mutexInterpolator);
|
||||
CInterpolatorLinear interpolator(m_renderedAircraftProvider);
|
||||
if (!interpolator.hasEnoughAircraftSituations(this->m_callsign)) { return; }
|
||||
|
||||
if (m_interpolator.hasEnoughAircraftSituations())
|
||||
{
|
||||
CAircraftSituation situation = m_interpolator.getCurrentSituation();
|
||||
MPPositionSlewMode positionSlewMode = aircraftSituationToFS9(situation);
|
||||
CAircraftSituation situation = interpolator.getCurrentInterpolatedSituation(m_callsign);
|
||||
MPPositionSlewMode positionSlewMode = aircraftSituationToFS9(situation);
|
||||
|
||||
QByteArray positionMessage;
|
||||
MultiPlayerPacketParser::writeType(positionMessage, CFs9Sdk::MULTIPLAYER_PACKET_ID_POSITION_SLEWMODE);
|
||||
MultiPlayerPacketParser::writeSize(positionMessage, positionSlewMode.size());
|
||||
positionSlewMode.packet_index = m_packetIndex;
|
||||
++m_packetIndex;
|
||||
positionMessage = MultiPlayerPacketParser::writeMessage(positionMessage, positionSlewMode);
|
||||
QByteArray positionMessage;
|
||||
MultiPlayerPacketParser::writeType(positionMessage, CFs9Sdk::MULTIPLAYER_PACKET_ID_POSITION_SLEWMODE);
|
||||
MultiPlayerPacketParser::writeSize(positionMessage, positionSlewMode.size());
|
||||
positionSlewMode.packet_index = m_packetIndex;
|
||||
++m_packetIndex;
|
||||
positionMessage = MultiPlayerPacketParser::writeMessage(positionMessage, positionSlewMode);
|
||||
|
||||
sendMessage(positionMessage);
|
||||
sendMessage(positionMessage);
|
||||
|
||||
QByteArray paramMessage;
|
||||
MPParam param;
|
||||
MultiPlayerPacketParser::writeType(paramMessage, CFs9Sdk::MULTIPLAYER_PACKET_ID_PARAMS);
|
||||
MultiPlayerPacketParser::writeSize(paramMessage, param.size());
|
||||
param.packet_index = m_packetIndex;
|
||||
++m_packetIndex;
|
||||
paramMessage = MultiPlayerPacketParser::writeMessage(paramMessage, param);
|
||||
sendMessage(paramMessage);
|
||||
QByteArray paramMessage;
|
||||
MPParam param;
|
||||
MultiPlayerPacketParser::writeType(paramMessage, CFs9Sdk::MULTIPLAYER_PACKET_ID_PARAMS);
|
||||
MultiPlayerPacketParser::writeSize(paramMessage, param.size());
|
||||
param.packet_index = m_packetIndex;
|
||||
++m_packetIndex;
|
||||
paramMessage = MultiPlayerPacketParser::writeMessage(paramMessage, param);
|
||||
sendMessage(paramMessage);
|
||||
|
||||
m_lastAircraftSituation = situation;
|
||||
|
||||
m_lastAircraftSituation = situation;
|
||||
}
|
||||
}
|
||||
|
||||
void CFs9Client::initialize()
|
||||
@@ -126,7 +124,7 @@ namespace BlackSimPlugin
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
if( FAILED( hr = createHostAddress() ) )
|
||||
if (FAILED(hr = createHostAddress()))
|
||||
{
|
||||
qWarning() << "Failed to create host address!";
|
||||
return hr;
|
||||
@@ -139,16 +137,16 @@ namespace BlackSimPlugin
|
||||
dpAppDesc.guidApplication = CFs9Sdk::guid();
|
||||
|
||||
// We now have the host address so lets enum
|
||||
if( FAILED( hr = m_directPlayPeer->EnumHosts(&dpAppDesc, // pApplicationDesc
|
||||
m_hostAddress, // pdpaddrHost
|
||||
m_deviceAddress, // pdpaddrDeviceInfo
|
||||
nullptr, 0, // pvUserEnumData, size
|
||||
0, // dwEnumCount
|
||||
0, // dwRetryInterval
|
||||
0, // dwTimeOut
|
||||
nullptr, // pvUserContext
|
||||
nullptr, // pAsyncHandle
|
||||
DPNENUMHOSTS_SYNC ) ) ) // dwFlags
|
||||
if (FAILED(hr = m_directPlayPeer->EnumHosts(&dpAppDesc, // pApplicationDesc
|
||||
m_hostAddress, // pdpaddrHost
|
||||
m_deviceAddress, // pdpaddrDeviceInfo
|
||||
nullptr, 0, // pvUserEnumData, size
|
||||
0, // dwEnumCount
|
||||
0, // dwRetryInterval
|
||||
0, // dwTimeOut
|
||||
nullptr, // pvUserContext
|
||||
nullptr, // pAsyncHandle
|
||||
DPNENUMHOSTS_SYNC))) // dwFlags
|
||||
{
|
||||
return printDirectPlayError(hr);
|
||||
}
|
||||
@@ -160,16 +158,16 @@ namespace BlackSimPlugin
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
// Create our IDirectPlay8Address Host Address
|
||||
if( FAILED( hr = CoCreateInstance(CLSID_DirectPlay8Address, nullptr,
|
||||
CLSCTX_INPROC_SERVER,
|
||||
IID_IDirectPlay8Address,
|
||||
reinterpret_cast<void **>(&m_hostAddress) ) ) )
|
||||
if (FAILED(hr = CoCreateInstance(CLSID_DirectPlay8Address, nullptr,
|
||||
CLSCTX_INPROC_SERVER,
|
||||
IID_IDirectPlay8Address,
|
||||
reinterpret_cast<void **>(&m_hostAddress))))
|
||||
{
|
||||
return printDirectPlayError(hr);
|
||||
}
|
||||
|
||||
// Set the SP for our Host Address
|
||||
if( FAILED( hr = m_hostAddress->SetSP(&CLSID_DP8SP_TCPIP ) ) )
|
||||
if (FAILED(hr = m_hostAddress->SetSP(&CLSID_DP8SP_TCPIP)))
|
||||
{
|
||||
return printDirectPlayError(hr);
|
||||
}
|
||||
@@ -178,9 +176,9 @@ namespace BlackSimPlugin
|
||||
const wchar_t hostname[] = L"localhost";
|
||||
|
||||
// Set the hostname into the address
|
||||
if( FAILED( hr = m_hostAddress->AddComponent(DPNA_KEY_HOSTNAME, hostname,
|
||||
2*(wcslen(hostname) + 1), /*bytes*/
|
||||
DPNA_DATATYPE_STRING ) ) )
|
||||
if (FAILED(hr = m_hostAddress->AddComponent(DPNA_KEY_HOSTNAME, hostname,
|
||||
2 * (wcslen(hostname) + 1), /*bytes*/
|
||||
DPNA_DATATYPE_STRING)))
|
||||
{
|
||||
return printDirectPlayError(hr);
|
||||
}
|
||||
@@ -192,7 +190,7 @@ namespace BlackSimPlugin
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
if(m_clientStatus == Connected) return hr;
|
||||
if (m_clientStatus == Connected) return hr;
|
||||
|
||||
QMutexLocker locker(&m_mutexHostList);
|
||||
|
||||
@@ -201,18 +199,18 @@ namespace BlackSimPlugin
|
||||
callsign.toWCharArray(wszPlayername.data());
|
||||
wszPlayername[callsign.size()] = 0;
|
||||
|
||||
ZeroMemory(&m_playerInfo, sizeof (PLAYER_INFO_STRUCT) );
|
||||
strcpy (m_playerInfo.szAircraft, "Boeing 737-400 Paint1");
|
||||
ZeroMemory(&m_playerInfo, sizeof(PLAYER_INFO_STRUCT));
|
||||
strcpy(m_playerInfo.szAircraft, "Boeing 737-400 Paint1");
|
||||
m_playerInfo.dwFlags = 6;
|
||||
|
||||
// Prepare and set the player information structure.
|
||||
ZeroMemory( &m_player, sizeof( DPN_PLAYER_INFO ) );
|
||||
m_player.dwSize = sizeof( DPN_PLAYER_INFO );
|
||||
ZeroMemory(&m_player, sizeof(DPN_PLAYER_INFO));
|
||||
m_player.dwSize = sizeof(DPN_PLAYER_INFO);
|
||||
m_player.pvData = &m_playerInfo;
|
||||
m_player.dwDataSize = sizeof( PLAYER_INFO_STRUCT );
|
||||
m_player.dwDataSize = sizeof(PLAYER_INFO_STRUCT);
|
||||
m_player.dwInfoFlags = DPNINFO_NAME | DPNINFO_DATA;
|
||||
m_player.pwszName = wszPlayername.data();
|
||||
if( FAILED( hr = m_directPlayPeer->SetPeerInfo( &m_player, nullptr, nullptr, DPNSETPEERINFO_SYNC ) ) )
|
||||
if (FAILED(hr = m_directPlayPeer->SetPeerInfo(&m_player, nullptr, nullptr, DPNSETPEERINFO_SYNC)))
|
||||
{
|
||||
return printDirectPlayError(hr);
|
||||
}
|
||||
@@ -224,16 +222,16 @@ namespace BlackSimPlugin
|
||||
dpAppDesc.guidApplication = CFs9Sdk::guid();
|
||||
|
||||
// We are now ready to host the app
|
||||
if( FAILED( hr = m_directPlayPeer->Connect( &dpAppDesc, // AppDesc
|
||||
m_hostAddress,
|
||||
m_deviceAddress,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr, 0,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
DPNCONNECT_SYNC ) ) )
|
||||
if (FAILED(hr = m_directPlayPeer->Connect(&dpAppDesc, // AppDesc
|
||||
m_hostAddress,
|
||||
m_deviceAddress,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr, 0,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
DPNCONNECT_SYNC)))
|
||||
{
|
||||
return printDirectPlayError(hr);
|
||||
}
|
||||
@@ -263,7 +261,7 @@ namespace BlackSimPlugin
|
||||
if (m_clientStatus == Disconnected) return hr;
|
||||
|
||||
BlackMisc::CLogMessage(this).debug() << "Closing DirectPlay connection for " << m_callsign;
|
||||
if( FAILED( hr = m_directPlayPeer->Close(0) ))
|
||||
if (FAILED(hr = m_directPlayPeer->Close(0)))
|
||||
{
|
||||
return printDirectPlayError(hr);
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace BlackSimPlugin
|
||||
};
|
||||
|
||||
//! Constructor
|
||||
CFs9Client(QObject *owner, const QString &callsign, const BlackMisc::PhysicalQuantities::CTime &updateInterval);
|
||||
CFs9Client(BlackMisc::Simulation::IRenderedAircraftProviderReadOnly *renderedAircraftProvider, QObject *owner, const QString &callsign, const BlackMisc::PhysicalQuantities::CTime &updateInterval);
|
||||
|
||||
//! Destructor
|
||||
virtual ~CFs9Client();
|
||||
@@ -85,10 +85,10 @@ namespace BlackSimPlugin
|
||||
|
||||
BlackMisc::Aviation::CAircraftSituation m_lastAircraftSituation;
|
||||
BlackMisc::PhysicalQuantities::CTime m_updateInterval;
|
||||
BlackCore::CInterpolatorLinear m_interpolator;
|
||||
int m_timerId = 0;
|
||||
|
||||
QMutex m_mutexInterpolator;
|
||||
BlackMisc::Simulation::IRenderedAircraftProviderReadOnly *m_renderedAircraftProvider = nullptr;
|
||||
IDirectPlay8Address *m_hostAddress = nullptr;
|
||||
ClientStatus m_clientStatus = Disconnected;
|
||||
|
||||
|
||||
@@ -113,29 +113,17 @@ namespace BlackSimPlugin
|
||||
this->removeRenderedAircraft(callsign);
|
||||
}
|
||||
|
||||
CFs9Client *client = new CFs9Client(this, callsign.toQString(), CTime(25, CTimeUnit::ms()));
|
||||
CFs9Client *client = new CFs9Client(this->m_renderedAircraftProvider, this, callsign.toQString(), CTime(25, CTimeUnit::ms()));
|
||||
client->setHostAddress(m_fs9Host->getHostAddress());
|
||||
client->setPlayerUserId(m_fs9Host->getPlayerUserId());
|
||||
|
||||
client->start();
|
||||
m_hashFs9Clients.insert(callsign, client);
|
||||
addAircraftSituation(callsign, remoteAircraft.getSituation());
|
||||
renderedAircraft().applyIfCallsign(callsign, CPropertyIndexVariantMap(CSimulatedAircraft::IndexRendered, CVariant::fromValue(true)));
|
||||
CLogMessage(this).info("FS9: Added aircraft %1") << callsign.toQString();
|
||||
return true;
|
||||
}
|
||||
|
||||
void CSimulatorFs9::addAircraftSituation(const CCallsign &callsign, const CAircraftSituation &situation)
|
||||
{
|
||||
Q_ASSERT(m_hashFs9Clients.contains(callsign));
|
||||
|
||||
CFs9Client *client = m_hashFs9Clients.value(callsign);
|
||||
if (!client)
|
||||
return;
|
||||
|
||||
client->addAircraftSituation(situation);
|
||||
}
|
||||
|
||||
bool CSimulatorFs9::removeRenderedAircraft(const CCallsign &callsign)
|
||||
{
|
||||
if (!m_hashFs9Clients.contains(callsign)) { return false; }
|
||||
|
||||
@@ -88,9 +88,6 @@ namespace BlackSimPlugin
|
||||
//! \copydoc ISimulator::addRemoteAircraft()
|
||||
virtual bool addRemoteAircraft(const BlackMisc::Simulation::CSimulatedAircraft &remoteAircraft) override;
|
||||
|
||||
//! \copydoc ISimulator::addAircraftSituation()
|
||||
virtual void addAircraftSituation(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CAircraftSituation &initialSituation) override;
|
||||
|
||||
//! \copydoc ISimulator::removeRemoteAircraft()
|
||||
virtual bool removeRenderedAircraft(const BlackMisc::Aviation::CCallsign &callsign) override;
|
||||
|
||||
|
||||
@@ -16,8 +16,6 @@ namespace BlackSimPlugin
|
||||
{
|
||||
namespace Fsx
|
||||
{
|
||||
CSimConnectObject::CSimConnectObject() :
|
||||
m_interpolator(new CInterpolatorLinear())
|
||||
{ }
|
||||
CSimConnectObject::CSimConnectObject() { }
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -49,13 +49,9 @@ namespace BlackSimPlugin
|
||||
//! Set Simconnect object id
|
||||
int getObjectId() const { return m_objectId; }
|
||||
|
||||
//! Get interpolator
|
||||
QSharedPointer<BlackCore::IInterpolator> getInterpolator() const { return m_interpolator; }
|
||||
|
||||
private:
|
||||
|
||||
BlackMisc::Aviation::CCallsign m_callsign;
|
||||
QSharedPointer<BlackCore::IInterpolator> m_interpolator;
|
||||
int m_requestId = -1;
|
||||
int m_objectId = -1;
|
||||
};
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "blackmisc/avairportlist.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include "blackmisc/nwaircraftmappinglist.h"
|
||||
#include "blackcore/interpolator_linear.h"
|
||||
|
||||
#include <QTimer>
|
||||
#include <QtConcurrent>
|
||||
@@ -156,8 +157,6 @@ namespace BlackSimPlugin
|
||||
simObj.setObjectId(0);
|
||||
++m_nextObjID;
|
||||
|
||||
addAircraftSituation(callsign, remoteAircraft.getSituation());
|
||||
|
||||
// matched models
|
||||
CAircraftModel aircraftModel = modelMatching(remoteAircraft);
|
||||
Q_ASSERT(remoteAircraft.getCallsign() == aircraftModel.getCallsign());
|
||||
@@ -185,16 +184,6 @@ namespace BlackSimPlugin
|
||||
}
|
||||
}
|
||||
|
||||
void CSimulatorFsx::addAircraftSituation(const CCallsign &callsign, const CAircraftSituation &initialSituation)
|
||||
{
|
||||
// Q_ASSERT(m_simConnectObjects.contains(callsign));
|
||||
if (!m_simConnectObjects.contains(callsign)) { return; }
|
||||
|
||||
CSimConnectObject simObj = m_simConnectObjects.value(callsign);
|
||||
simObj.getInterpolator()->addAircraftSituation(initialSituation);
|
||||
m_simConnectObjects.insert(callsign, simObj);
|
||||
}
|
||||
|
||||
bool CSimulatorFsx::removeRenderedAircraft(const CCallsign &callsign)
|
||||
{
|
||||
// only remove from sim
|
||||
@@ -580,24 +569,24 @@ namespace BlackSimPlugin
|
||||
|
||||
void CSimulatorFsx::updateOtherAircraft()
|
||||
{
|
||||
BlackCore::CInterpolatorLinear interpolator(this->m_renderedAircraftProvider);
|
||||
for (const CSimConnectObject &simObj : m_simConnectObjects)
|
||||
{
|
||||
if (simObj.getInterpolator()->hasEnoughAircraftSituations())
|
||||
if (!interpolator.hasEnoughAircraftSituations(simObj.getCallsign())) { continue; }
|
||||
|
||||
SIMCONNECT_DATA_INITPOSITION position = aircraftSituationToFsxInitPosition(interpolator.getCurrentInterpolatedSituation(simObj.getCallsign()));
|
||||
DataDefinitionRemoteAircraftSituation ddAircraftSituation;
|
||||
ddAircraftSituation.position = position;
|
||||
|
||||
DataDefinitionGearHandlePosition gearHandle;
|
||||
gearHandle.gearHandlePosition = position.Altitude < 1000 ? 1 : 0;
|
||||
|
||||
if (simObj.getObjectId() != 0)
|
||||
{
|
||||
SIMCONNECT_DATA_INITPOSITION position = aircraftSituationToFsxInitPosition(simObj.getInterpolator()->getCurrentSituation());
|
||||
DataDefinitionRemoteAircraftSituation ddAircraftSituation;
|
||||
ddAircraftSituation.position = position;
|
||||
SimConnect_SetDataOnSimObject(m_hSimConnect, CSimConnectDefinitions::DataRemoteAircraftSituation, simObj.getObjectId(), SIMCONNECT_DATA_SET_FLAG_DEFAULT, 0, sizeof(ddAircraftSituation), &ddAircraftSituation);
|
||||
|
||||
DataDefinitionGearHandlePosition gearHandle;
|
||||
gearHandle.gearHandlePosition = position.Altitude < 1000 ? 1 : 0;
|
||||
|
||||
if (simObj.getObjectId() != 0)
|
||||
{
|
||||
SimConnect_SetDataOnSimObject(m_hSimConnect, CSimConnectDefinitions::DataRemoteAircraftSituation, simObj.getObjectId(), SIMCONNECT_DATA_SET_FLAG_DEFAULT, 0, sizeof(ddAircraftSituation), &ddAircraftSituation);
|
||||
|
||||
// With the following SimConnect call all aircrafts loose their red tag. No idea why though.
|
||||
SimConnect_SetDataOnSimObject(m_hSimConnect, CSimConnectDefinitions::DataGearHandlePosition, simObj.getObjectId(), SIMCONNECT_DATA_SET_FLAG_DEFAULT, 0, sizeof(DataDefinitionGearHandlePosition), &gearHandle);
|
||||
}
|
||||
// With the following SimConnect call all aircrafts loose their red tag. No idea why though.
|
||||
SimConnect_SetDataOnSimObject(m_hSimConnect, CSimConnectDefinitions::DataGearHandlePosition, simObj.getObjectId(), SIMCONNECT_DATA_SET_FLAG_DEFAULT, 0, sizeof(DataDefinitionGearHandlePosition), &gearHandle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,9 +106,6 @@ namespace BlackSimPlugin
|
||||
//! \copydoc ISimulator::addRemoteAircraft()
|
||||
virtual bool addRemoteAircraft(const BlackMisc::Simulation::CSimulatedAircraft &remoteAircraft) override;
|
||||
|
||||
//! \copydoc ISimulator::addAircraftSituation()
|
||||
virtual void addAircraftSituation(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CAircraftSituation &initialSituation) override;
|
||||
|
||||
//! \copydoc ISimulator::removeRenderedAircraft()
|
||||
virtual bool removeRenderedAircraft(const BlackMisc::Aviation::CCallsign &callsign) override;
|
||||
|
||||
|
||||
@@ -312,27 +312,27 @@ namespace BlackSimPlugin
|
||||
// Is there any model matching required ????
|
||||
CAircraftIcao icao = remoteAircraft.getIcaoInfo();
|
||||
m_traffic->addPlane(remoteAircraft.getCallsign().asString(), icao.getAircraftDesignator(), icao.getAirlineDesignator(), icao.getLivery());
|
||||
addAircraftSituation(remoteAircraft.getCallsign(), remoteAircraft.getSituation());
|
||||
renderedAircraft().applyIfCallsign(remoteAircraft.getCallsign(), CPropertyIndexVariantMap(CSimulatedAircraft::IndexRendered, CVariant::fromValue(true)));
|
||||
CLogMessage(this).info("XP: Added aircraft %1") << remoteAircraft.getCallsign().toQString();
|
||||
return true;
|
||||
}
|
||||
|
||||
void CSimulatorXPlane::addAircraftSituation(const BlackMisc::Aviation::CCallsign &callsign,
|
||||
const BlackMisc::Aviation::CAircraftSituation &situ)
|
||||
{
|
||||
if (! isConnected()) { return; }
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
m_traffic->setPlanePosition(callsign.asString(),
|
||||
situ.latitude().value(CAngleUnit::deg()),
|
||||
situ.longitude().value(CAngleUnit::deg()),
|
||||
situ.getAltitude().value(CLengthUnit::ft()),
|
||||
situ.getPitch().value(CAngleUnit::deg()),
|
||||
situ.getBank().value(CAngleUnit::deg()),
|
||||
situ.getHeading().value(CAngleUnit::deg()));
|
||||
m_traffic->setPlaneSurfaces(callsign.asString(), true, 0, 0, 0, 0, 0, 0, 0, 0, 0, true, true, true, true, 0); // TODO landing gear, lights, control surfaces
|
||||
m_traffic->setPlaneTransponder(callsign.asString(), 2000, true, false); // TODO transponder
|
||||
}
|
||||
//! \todo XPlane driver, where would this go?
|
||||
// void CSimulatorXPlane::addAircraftSituation(const BlackMisc::Aviation::CCallsign &callsign,
|
||||
// const BlackMisc::Aviation::CAircraftSituation &situ)
|
||||
// {
|
||||
// if (! isConnected()) { return; }
|
||||
// using namespace BlackMisc::PhysicalQuantities;
|
||||
// m_traffic->setPlanePosition(callsign.asString(),
|
||||
// situ.latitude().value(CAngleUnit::deg()),
|
||||
// situ.longitude().value(CAngleUnit::deg()),
|
||||
// situ.getAltitude().value(CLengthUnit::ft()),
|
||||
// situ.getPitch().value(CAngleUnit::deg()),
|
||||
// situ.getBank().value(CAngleUnit::deg()),
|
||||
// situ.getHeading().value(CAngleUnit::deg()));
|
||||
// m_traffic->setPlaneSurfaces(callsign.asString(), true, 0, 0, 0, 0, 0, 0, 0, 0, 0, true, true, true, true, 0); // TODO landing gear, lights, control surfaces
|
||||
// m_traffic->setPlaneTransponder(callsign.asString(), 2000, true, false); // TODO transponder
|
||||
// }
|
||||
|
||||
bool CSimulatorXPlane::removeRenderedAircraft(const BlackMisc::Aviation::CCallsign &callsign)
|
||||
{
|
||||
|
||||
@@ -71,10 +71,6 @@ namespace BlackSimPlugin
|
||||
//! \copydoc ISimulator::addRemoteAircraft()
|
||||
virtual bool addRemoteAircraft(const BlackMisc::Simulation::CSimulatedAircraft &remoteAircraft) override;
|
||||
|
||||
//! \copydoc BlackCore::ISimulator::addAircraftSituation
|
||||
virtual void addAircraftSituation(const BlackMisc::Aviation::CCallsign &callsign,
|
||||
const BlackMisc::Aviation::CAircraftSituation &situation) override;
|
||||
|
||||
//! \copydoc BlackCore::ISimulator::removeRemoteAircraft
|
||||
virtual bool removeRenderedAircraft(const BlackMisc::Aviation::CCallsign &callsign) override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user