Ref T372, p3D version of releaseAIControl

This commit is contained in:
Klaus Basan
2018-09-25 01:52:59 +02:00
parent 5323cb09d7
commit 684d2933e7
2 changed files with 39 additions and 18 deletions

View File

@@ -108,12 +108,15 @@ namespace BlackSimPlugin
const SIMCONNECT_DATA_REQUEST_ID requestId = this->obtainRequestIdForSimObjTerrainProbe(); // P3D we use new request id each time (no simobject)
// returns SIMCONNECT_RECV_GROUND_INFO -> SIMCONNECT_DATA_GROUND_INFO
const HRESULT hr = SimConnect_RequestGroundInfo(
m_hSimConnect, requestId, latDeg, lngDeg, 0, latDeg, lngDeg, maxAltFt,
dwGridWidth, dwGridHeight,
SIMCONNECT_GROUND_INFO_LATLON_FORMAT_DEGREES,
SIMCONNECT_GROUND_INFO_ALT_FORMAT_FEET,
SIMCONNECT_GROUND_INFO_SOURCE_FLAG_PLATFORMS);
const HRESULT hr = this->logAndTraceSendId(
SimConnect_RequestGroundInfo(
m_hSimConnect, requestId, latDeg, lngDeg, 0, latDeg, lngDeg, maxAltFt,
dwGridWidth, dwGridHeight,
SIMCONNECT_GROUND_INFO_LATLON_FORMAT_DEGREES,
SIMCONNECT_GROUND_INFO_ALT_FORMAT_FEET,
SIMCONNECT_GROUND_INFO_SOURCE_FLAG_PLATFORMS),
Q_FUNC_INFO, "SimConnect_RequestGroundInfo");
bool ok = false;
if (isOk(hr))
{
@@ -188,27 +191,36 @@ namespace BlackSimPlugin
}
return hr;
}
#else
bool CSimulatorP3D::followAircraft(const CCallsign &callsign)
{
Q_UNUSED(callsign);
return false;
}
bool CSimulatorP3D::releaseAIControl(const CSimConnectObject &simObject, SIMCONNECT_DATA_REQUEST_ID requestId)
{
// completely remove AI control
const SIMCONNECT_OBJECT_ID objectId = simObject.getObjectId();
const HRESULT hr1 = this->logAndTraceSendId(
SimConnect_AIReleaseControlEx(m_hSimConnect, objectId, requestId, TRUE),
simObject, "Release control", Q_FUNC_INFO, "SimConnect_AIReleaseControlEx");
const HRESULT hr2 = this->logAndTraceSendId(
SimConnect_TransmitClientEvent(m_hSimConnect, objectId, EventFreezeLatLng, 1, SIMCONNECT_GROUP_PRIORITY_HIGHEST, SIMCONNECT_EVENT_FLAG_GROUPID_IS_PRIORITY),
simObject, "EventFreezeLatLng", Q_FUNC_INFO, "SimConnect_TransmitClientEvent");
const HRESULT hr3 = this->logAndTraceSendId(
SimConnect_TransmitClientEvent(m_hSimConnect, objectId, EventFreezeAlt, 1, SIMCONNECT_GROUP_PRIORITY_HIGHEST, SIMCONNECT_EVENT_FLAG_GROUPID_IS_PRIORITY),
simObject, "EventFreezeAlt", Q_FUNC_INFO, "SimConnect_TransmitClientEvent");
const HRESULT hr4 = this->logAndTraceSendId(
SimConnect_TransmitClientEvent(m_hSimConnect, objectId, EventFreezeAtt, 1, SIMCONNECT_GROUP_PRIORITY_HIGHEST, SIMCONNECT_EVENT_FLAG_GROUPID_IS_PRIORITY),
simObject, "EventFreezeAtt", Q_FUNC_INFO, "SimConnect_TransmitClientEvent");
return isOk(hr1, hr2, hr3, hr4);
}
#else
HRESULT CSimulatorP3D::initEventsP3D()
{
return S_OK;
return s_ok();
}
void CSimulatorP3D::SimConnectProc(SIMCONNECT_RECV *pData, DWORD cbData, void *pContext)
{
CSimulatorFsxCommon::SimConnectProc(pData, cbData, pContext);
}
bool CSimulatorP3D::requestElevation(const ICoordinateGeodetic &reference, const CCallsign &callsign)
{
return CSimulatorFsxCommon::requestElevation(reference, callsign);
}
#endif
} // namespace
} // namespace

View File

@@ -13,6 +13,7 @@
#define BLACKSIMPLUGIN_SIMULATOR_P3D_H
#include "../fsxcommon/simulatorfsxcommon.h"
#include "../fsxcommon/simconnectobject.h"
namespace BlackSimPlugin
{
@@ -41,16 +42,24 @@ namespace BlackSimPlugin
BlackMisc::Network::IClientProvider *clientProvider,
QObject *parent = nullptr);
#ifdef Q_OS_WIN64
//! \copydoc BlackMisc::Simulation::ISimulationEnvironmentProvider::requestElevation
virtual bool requestElevation(const BlackMisc::Geo::ICoordinateGeodetic &reference, const BlackMisc::Aviation::CCallsign &callsign) override;
//! \copydoc BlackCore::ISimulator::followAircraft
virtual bool followAircraft(const BlackMisc::Aviation::CCallsign &callsign) override;
#endif // guard
protected:
//! \copydoc FsxCommon::CSimulatorFsxCommon::initEventsP3D
virtual HRESULT initEventsP3D() override;
#ifdef Q_OS_WIN64
//! \copydoc FsxCommon::CSimulatorFsxCommon::releaseAIControl
//! \remark P3D API release of control
virtual bool releaseAIControl(const FsxCommon::CSimConnectObject &simObject, SIMCONNECT_DATA_REQUEST_ID requestId) override;
#endif
//! SimConnect Callback
static void CALLBACK SimConnectProc(SIMCONNECT_RECV *pData, DWORD cbData, void *pContext);
};