mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-23 05:45:35 +08:00
refs #407, FSX driver warnings as described
* also fixed some signed / unsigned issues
This commit is contained in:
@@ -63,7 +63,7 @@ namespace BlackMisc
|
|||||||
CValueObject(name), m_transponderCode(0), m_transponderMode(transponderMode)
|
CValueObject(name), m_transponderCode(0), m_transponderMode(transponderMode)
|
||||||
{
|
{
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
this->m_transponderCode = transponderCode.toUInt(&ok);
|
this->m_transponderCode = transponderCode.toInt(&ok);
|
||||||
if (!ok) this->m_transponderCode = -1; // will cause assert / exception
|
if (!ok) this->m_transponderCode = -1; // will cause assert / exception
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,7 +72,7 @@ namespace BlackMisc
|
|||||||
CValueObject(name), m_transponderCode(0), m_transponderMode(StateStandby)
|
CValueObject(name), m_transponderCode(0), m_transponderMode(StateStandby)
|
||||||
{
|
{
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
this->m_transponderCode = transponderCode.toUInt(&ok);
|
this->m_transponderCode = transponderCode.toInt(&ok);
|
||||||
if (!ok) this->m_transponderCode = -1; // will cause assert / exception
|
if (!ok) this->m_transponderCode = -1; // will cause assert / exception
|
||||||
this->setModeAsString(transponderMode);
|
this->setModeAsString(transponderMode);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ namespace BlackSimPlugin
|
|||||||
// write a default client area so we are not suddenly squawking ident or so
|
// write a default client area so we are not suddenly squawking ident or so
|
||||||
DataDefinitionClientAreaSb sbArea;
|
DataDefinitionClientAreaSb sbArea;
|
||||||
sbArea.setDefaultValues();
|
sbArea.setDefaultValues();
|
||||||
hr += SimConnect_SetClientData(hSimConnect, ClientAreaSquawkBox, CSimConnectDefinitions::DataClientAreaSb, NULL, 0, sbSize, &sbArea);
|
hr += SimConnect_SetClientData(hSimConnect, ClientAreaSquawkBox, CSimConnectDefinitions::DataClientAreaSb, SIMCONNECT_CLIENT_DATA_REQUEST_FLAG_DEFAULT, 0, sbSize, &sbArea);
|
||||||
if (hr != S_OK)
|
if (hr != S_OK)
|
||||||
{
|
{
|
||||||
CLogMessage(static_cast<CSimConnectDefinitions *>(nullptr)).error("SimConnect error: SimConnect_SetClientData %1") << hr;
|
CLogMessage(static_cast<CSimConnectDefinitions *>(nullptr)).error("SimConnect error: SimConnect_SetClientData %1") << hr;
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ namespace BlackSimPlugin
|
|||||||
{
|
{
|
||||||
//! \todo if exists, recreate (new model?, new ICAO code)
|
//! \todo if exists, recreate (new model?, new ICAO code)
|
||||||
QByteArray m = aircraftModel.getModelString().toLocal8Bit();
|
QByteArray m = aircraftModel.getModelString().toLocal8Bit();
|
||||||
HRESULT hr = SimConnect_AICreateNonATCAircraft(m_hSimConnect, m.constData(), qPrintable(callsign.toQString().left(12)), initialPosition, simObj.getRequestId());
|
HRESULT hr = SimConnect_AICreateNonATCAircraft(m_hSimConnect, m.constData(), qPrintable(callsign.toQString().left(12)), initialPosition, static_cast<SIMCONNECT_DATA_REQUEST_ID>(simObj.getRequestId()));
|
||||||
if (hr != S_OK) { CLogMessage(this).error("SimConnect, can not create AI traffic"); }
|
if (hr != S_OK) { CLogMessage(this).error("SimConnect, can not create AI traffic"); }
|
||||||
m_simConnectObjects.insert(callsign, simObj);
|
m_simConnectObjects.insert(callsign, simObj);
|
||||||
CLogMessage(this).info("FSX: Added aircraft %1") << callsign.toQString();
|
CLogMessage(this).info("FSX: Added aircraft %1") << callsign.toQString();
|
||||||
@@ -240,12 +240,12 @@ namespace BlackSimPlugin
|
|||||||
{
|
{
|
||||||
if (m_useSbOffsets)
|
if (m_useSbOffsets)
|
||||||
{
|
{
|
||||||
byte ident = newTransponder.isIdentifying() ? 1 : 0; // 1 is ident
|
byte ident = newTransponder.isIdentifying() ? 1U : 0U; // 1 is ident
|
||||||
byte standby = newTransponder.isInStandby() ? 1 : 0; // 1 is standby
|
byte standby = newTransponder.isInStandby() ? 1U : 0U; // 1 is standby
|
||||||
HRESULT hr = S_OK;
|
HRESULT hr = S_OK;
|
||||||
|
|
||||||
hr += SimConnect_SetClientData(m_hSimConnect, ClientAreaSquawkBox, CSimConnectDefinitions::DataClientAreaSbIdent, NULL, 0, 1, &ident);
|
hr += SimConnect_SetClientData(m_hSimConnect, ClientAreaSquawkBox, CSimConnectDefinitions::DataClientAreaSbIdent, SIMCONNECT_CLIENT_DATA_REQUEST_FLAG_DEFAULT, 0, 1, &ident);
|
||||||
hr += SimConnect_SetClientData(m_hSimConnect, ClientAreaSquawkBox, CSimConnectDefinitions::DataClientAreaSbStandby, NULL, 0, 1, &standby);
|
hr += SimConnect_SetClientData(m_hSimConnect, ClientAreaSquawkBox, CSimConnectDefinitions::DataClientAreaSbStandby, SIMCONNECT_CLIENT_DATA_REQUEST_FLAG_DEFAULT, 0, 1, &standby);
|
||||||
if (hr != S_OK)
|
if (hr != S_OK)
|
||||||
{
|
{
|
||||||
CLogMessage(this).warning("Setting transponder mode failed (SB offsets)");
|
CLogMessage(this).warning("Setting transponder mode failed (SB offsets)");
|
||||||
@@ -282,7 +282,7 @@ namespace BlackSimPlugin
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
HRESULT hr = SimConnect_Text(
|
HRESULT hr = SimConnect_Text(
|
||||||
m_hSimConnect, type, 7.5, EventTextMessage, m.size(),
|
m_hSimConnect, type, 7.5, EventTextMessage, static_cast<DWORD>(m.size()),
|
||||||
m.data()
|
m.data()
|
||||||
);
|
);
|
||||||
Q_UNUSED(hr);
|
Q_UNUSED(hr);
|
||||||
@@ -455,7 +455,7 @@ namespace BlackSimPlugin
|
|||||||
if (it == m_simConnectObjects.end()) { return; }
|
if (it == m_simConnectObjects.end()) { return; }
|
||||||
|
|
||||||
// belongs to us
|
// belongs to us
|
||||||
it->setObjectId(objectID);
|
it->setObjectId(static_cast<int>(objectID));
|
||||||
SimConnect_AIReleaseControl(m_hSimConnect, objectID, requestID);
|
SimConnect_AIReleaseControl(m_hSimConnect, objectID, requestID);
|
||||||
SimConnect_TransmitClientEvent(m_hSimConnect, objectID, EventFreezeLat, 1,
|
SimConnect_TransmitClientEvent(m_hSimConnect, objectID, EventFreezeLat, 1,
|
||||||
SIMCONNECT_GROUP_PRIORITY_HIGHEST, SIMCONNECT_EVENT_FLAG_GROUPID_IS_PRIORITY);
|
SIMCONNECT_GROUP_PRIORITY_HIGHEST, SIMCONNECT_EVENT_FLAG_GROUPID_IS_PRIORITY);
|
||||||
@@ -524,7 +524,7 @@ namespace BlackSimPlugin
|
|||||||
bool CSimulatorFsx::removeRemoteAircraft(const CSimConnectObject &simObject)
|
bool CSimulatorFsx::removeRemoteAircraft(const CSimConnectObject &simObject)
|
||||||
{
|
{
|
||||||
m_simConnectObjects.remove(simObject.getCallsign());
|
m_simConnectObjects.remove(simObject.getCallsign());
|
||||||
SimConnect_AIRemoveObject(m_hSimConnect, simObject.getObjectId(), simObject.getRequestId());
|
SimConnect_AIRemoveObject(m_hSimConnect, static_cast<SIMCONNECT_OBJECT_ID>(simObject.getObjectId()), static_cast<SIMCONNECT_DATA_REQUEST_ID>(simObject.getRequestId()));
|
||||||
remoteAircraft().setRendered(simObject.getCallsign(), false);
|
remoteAircraft().setRendered(simObject.getCallsign(), false);
|
||||||
CLogMessage(this).info("FSX: Removed aircraft %1") << simObject.getCallsign().toQString();
|
CLogMessage(this).info("FSX: Removed aircraft %1") << simObject.getCallsign().toQString();
|
||||||
return true;
|
return true;
|
||||||
@@ -571,7 +571,7 @@ namespace BlackSimPlugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
// facility
|
// facility
|
||||||
hr += SimConnect_SubscribeToFacilities(m_hSimConnect, SIMCONNECT_FACILITY_LIST_TYPE_AIRPORT, m_nextObjID++);
|
hr += SimConnect_SubscribeToFacilities(m_hSimConnect, SIMCONNECT_FACILITY_LIST_TYPE_AIRPORT, static_cast<SIMCONNECT_DATA_REQUEST_ID>(m_nextObjID++));
|
||||||
if (hr != S_OK)
|
if (hr != S_OK)
|
||||||
{
|
{
|
||||||
CLogMessage(this).error("FSX plugin error: %1") << "SimConnect_SubscribeToFacilities failed";
|
CLogMessage(this).error("FSX plugin error: %1") << "SimConnect_SubscribeToFacilities failed";
|
||||||
@@ -655,10 +655,10 @@ namespace BlackSimPlugin
|
|||||||
isOnGround = interpolatedSituation.isOnGroundGuessed();
|
isOnGround = interpolatedSituation.isOnGroundGuessed();
|
||||||
}
|
}
|
||||||
|
|
||||||
position.OnGround = isOnGround ? 1 : 0;
|
position.OnGround = isOnGround ? 1U : 0U;
|
||||||
HRESULT hr = S_OK;
|
HRESULT hr = S_OK;
|
||||||
hr += SimConnect_SetDataOnSimObject(m_hSimConnect, CSimConnectDefinitions::DataRemoteAircraftPosition,
|
hr += SimConnect_SetDataOnSimObject(m_hSimConnect, CSimConnectDefinitions::DataRemoteAircraftPosition,
|
||||||
simObj.getObjectId(), 0, 0,
|
static_cast<SIMCONNECT_OBJECT_ID>(simObj.getObjectId()), 0, 0,
|
||||||
sizeof(SIMCONNECT_DATA_INITPOSITION), &position);
|
sizeof(SIMCONNECT_DATA_INITPOSITION), &position);
|
||||||
if (hr != S_OK) { CLogMessage(this).warning("Failed so set position on SimObject %1 callsign: %2") << simObj.getObjectId() << callsign; }
|
if (hr != S_OK) { CLogMessage(this).warning("Failed so set position on SimObject %1 callsign: %2") << simObj.getObjectId() << callsign; }
|
||||||
|
|
||||||
@@ -754,7 +754,7 @@ namespace BlackSimPlugin
|
|||||||
Q_ASSERT(m_hSimConnect);
|
Q_ASSERT(m_hSimConnect);
|
||||||
HRESULT hr = S_OK;
|
HRESULT hr = S_OK;
|
||||||
hr += SimConnect_SetDataOnSimObject(m_hSimConnect, CSimConnectDefinitions::DataRemoteAircraftParts,
|
hr += SimConnect_SetDataOnSimObject(m_hSimConnect, CSimConnectDefinitions::DataRemoteAircraftParts,
|
||||||
simObj.getObjectId(), 0, 0,
|
static_cast<SIMCONNECT_OBJECT_ID>(simObj.getObjectId()), 0, 0,
|
||||||
sizeof(DataDefinitionRemoteAircraftParts), &ddRemoteAircraftParts);
|
sizeof(DataDefinitionRemoteAircraftParts), &ddRemoteAircraftParts);
|
||||||
|
|
||||||
if (hr != S_OK) { CLogMessage(this).warning("Failed so set parts on SimObject %1 callsign: %2") << simObj.getObjectId() << simObj.getCallsign(); }
|
if (hr != S_OK) { CLogMessage(this).warning("Failed so set parts on SimObject %1 callsign: %2") << simObj.getObjectId() << simObj.getCallsign(); }
|
||||||
@@ -791,8 +791,8 @@ namespace BlackSimPlugin
|
|||||||
myDateTime = myDateTime.addSecs(offsetSeconds);
|
myDateTime = myDateTime.addSecs(offsetSeconds);
|
||||||
}
|
}
|
||||||
QTime myTime = myDateTime.time();
|
QTime myTime = myDateTime.time();
|
||||||
DWORD h = myTime.hour();
|
DWORD h = static_cast<DWORD>(myTime.hour());
|
||||||
DWORD m = myTime.minute();
|
DWORD m = static_cast<DWORD>(myTime.minute());
|
||||||
int targetMins = myTime.hour() * 60 + myTime.minute();
|
int targetMins = myTime.hour() * 60 + myTime.minute();
|
||||||
int simMins = zuluTimeSim.valueRounded(CTimeUnit::min());
|
int simMins = zuluTimeSim.valueRounded(CTimeUnit::min());
|
||||||
int diffMins = qAbs(targetMins - simMins);
|
int diffMins = qAbs(targetMins - simMins);
|
||||||
@@ -824,8 +824,7 @@ namespace BlackSimPlugin
|
|||||||
HRESULT result = SimConnect_Open(&hSimConnect, BlackMisc::CProject::systemNameAndVersionChar(), nullptr, 0, 0, 0);
|
HRESULT result = SimConnect_Open(&hSimConnect, BlackMisc::CProject::systemNameAndVersionChar(), nullptr, 0, 0, 0);
|
||||||
SimConnect_Close(hSimConnect);
|
SimConnect_Close(hSimConnect);
|
||||||
|
|
||||||
if (result == S_OK)
|
if (result == S_OK) { emit simulatorStarted(); }
|
||||||
emit simulatorStarted();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ namespace BlackSimPlugin
|
|||||||
int m_interpolationRequest = 0; //!< current interpolation request
|
int m_interpolationRequest = 0; //!< current interpolation request
|
||||||
int m_interpolationsSkipped = 0; //!< number of skipped interpolation request
|
int m_interpolationsSkipped = 0; //!< number of skipped interpolation request
|
||||||
HANDLE m_hSimConnect = nullptr; //!< Handle to SimConnect object
|
HANDLE m_hSimConnect = nullptr; //!< Handle to SimConnect object
|
||||||
uint m_nextObjID = 1; //!< object ID TODO: also used as request id, where to we place other request ids as for facilities
|
int m_nextObjID = 1; //!< object ID TODO: also used as request id, where to we place other request ids as for facilities
|
||||||
QHash<BlackMisc::Aviation::CCallsign, CSimConnectObject> m_simConnectObjects;
|
QHash<BlackMisc::Aviation::CCallsign, CSimConnectObject> m_simConnectObjects;
|
||||||
QFutureWatcher<bool> m_watcherConnect;
|
QFutureWatcher<bool> m_watcherConnect;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user