From dba47d6c8c7c7d7d0a9e490600e6be2e59c3123c Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Sun, 19 Apr 2015 01:33:04 +0200 Subject: [PATCH] refs #407, FSX driver warnings as described * also fixed some signed / unsigned issues --- src/blackmisc/aviation/transponder.h | 4 +-- .../fsx/simconnect_datadefinition.cpp | 2 +- src/plugins/simulator/fsx/simulator_fsx.cpp | 31 +++++++++---------- src/plugins/simulator/fsx/simulator_fsx.h | 4 +-- 4 files changed, 20 insertions(+), 21 deletions(-) diff --git a/src/blackmisc/aviation/transponder.h b/src/blackmisc/aviation/transponder.h index f877d58b9..55c58f9d4 100644 --- a/src/blackmisc/aviation/transponder.h +++ b/src/blackmisc/aviation/transponder.h @@ -63,7 +63,7 @@ namespace BlackMisc CValueObject(name), m_transponderCode(0), m_transponderMode(transponderMode) { 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 } @@ -72,7 +72,7 @@ namespace BlackMisc CValueObject(name), m_transponderCode(0), m_transponderMode(StateStandby) { 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 this->setModeAsString(transponderMode); } diff --git a/src/plugins/simulator/fsx/simconnect_datadefinition.cpp b/src/plugins/simulator/fsx/simconnect_datadefinition.cpp index f7b3d11ed..b4e3d376b 100644 --- a/src/plugins/simulator/fsx/simconnect_datadefinition.cpp +++ b/src/plugins/simulator/fsx/simconnect_datadefinition.cpp @@ -151,7 +151,7 @@ namespace BlackSimPlugin // write a default client area so we are not suddenly squawking ident or so DataDefinitionClientAreaSb sbArea; 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) { CLogMessage(static_cast(nullptr)).error("SimConnect error: SimConnect_SetClientData %1") << hr; diff --git a/src/plugins/simulator/fsx/simulator_fsx.cpp b/src/plugins/simulator/fsx/simulator_fsx.cpp index 9c99808cc..a5a5a22d8 100644 --- a/src/plugins/simulator/fsx/simulator_fsx.cpp +++ b/src/plugins/simulator/fsx/simulator_fsx.cpp @@ -174,7 +174,7 @@ namespace BlackSimPlugin { //! \todo if exists, recreate (new model?, new ICAO code) 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(simObj.getRequestId())); if (hr != S_OK) { CLogMessage(this).error("SimConnect, can not create AI traffic"); } m_simConnectObjects.insert(callsign, simObj); CLogMessage(this).info("FSX: Added aircraft %1") << callsign.toQString(); @@ -240,12 +240,12 @@ namespace BlackSimPlugin { if (m_useSbOffsets) { - byte ident = newTransponder.isIdentifying() ? 1 : 0; // 1 is ident - byte standby = newTransponder.isInStandby() ? 1 : 0; // 1 is standby + byte ident = newTransponder.isIdentifying() ? 1U : 0U; // 1 is ident + byte standby = newTransponder.isInStandby() ? 1U : 0U; // 1 is standby HRESULT hr = S_OK; - hr += SimConnect_SetClientData(m_hSimConnect, ClientAreaSquawkBox, CSimConnectDefinitions::DataClientAreaSbIdent, NULL, 0, 1, &ident); - hr += SimConnect_SetClientData(m_hSimConnect, ClientAreaSquawkBox, CSimConnectDefinitions::DataClientAreaSbStandby, NULL, 0, 1, &standby); + 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, SIMCONNECT_CLIENT_DATA_REQUEST_FLAG_DEFAULT, 0, 1, &standby); if (hr != S_OK) { CLogMessage(this).warning("Setting transponder mode failed (SB offsets)"); @@ -282,7 +282,7 @@ namespace BlackSimPlugin break; } HRESULT hr = SimConnect_Text( - m_hSimConnect, type, 7.5, EventTextMessage, m.size(), + m_hSimConnect, type, 7.5, EventTextMessage, static_cast(m.size()), m.data() ); Q_UNUSED(hr); @@ -455,7 +455,7 @@ namespace BlackSimPlugin if (it == m_simConnectObjects.end()) { return; } // belongs to us - it->setObjectId(objectID); + it->setObjectId(static_cast(objectID)); SimConnect_AIReleaseControl(m_hSimConnect, objectID, requestID); SimConnect_TransmitClientEvent(m_hSimConnect, objectID, EventFreezeLat, 1, SIMCONNECT_GROUP_PRIORITY_HIGHEST, SIMCONNECT_EVENT_FLAG_GROUPID_IS_PRIORITY); @@ -524,7 +524,7 @@ namespace BlackSimPlugin bool CSimulatorFsx::removeRemoteAircraft(const CSimConnectObject &simObject) { m_simConnectObjects.remove(simObject.getCallsign()); - SimConnect_AIRemoveObject(m_hSimConnect, simObject.getObjectId(), simObject.getRequestId()); + SimConnect_AIRemoveObject(m_hSimConnect, static_cast(simObject.getObjectId()), static_cast(simObject.getRequestId())); remoteAircraft().setRendered(simObject.getCallsign(), false); CLogMessage(this).info("FSX: Removed aircraft %1") << simObject.getCallsign().toQString(); return true; @@ -571,7 +571,7 @@ namespace BlackSimPlugin } // 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(m_nextObjID++)); if (hr != S_OK) { CLogMessage(this).error("FSX plugin error: %1") << "SimConnect_SubscribeToFacilities failed"; @@ -655,10 +655,10 @@ namespace BlackSimPlugin isOnGround = interpolatedSituation.isOnGroundGuessed(); } - position.OnGround = isOnGround ? 1 : 0; + position.OnGround = isOnGround ? 1U : 0U; HRESULT hr = S_OK; hr += SimConnect_SetDataOnSimObject(m_hSimConnect, CSimConnectDefinitions::DataRemoteAircraftPosition, - simObj.getObjectId(), 0, 0, + static_cast(simObj.getObjectId()), 0, 0, sizeof(SIMCONNECT_DATA_INITPOSITION), &position); 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); HRESULT hr = S_OK; hr += SimConnect_SetDataOnSimObject(m_hSimConnect, CSimConnectDefinitions::DataRemoteAircraftParts, - simObj.getObjectId(), 0, 0, + static_cast(simObj.getObjectId()), 0, 0, sizeof(DataDefinitionRemoteAircraftParts), &ddRemoteAircraftParts); 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); } QTime myTime = myDateTime.time(); - DWORD h = myTime.hour(); - DWORD m = myTime.minute(); + DWORD h = static_cast(myTime.hour()); + DWORD m = static_cast(myTime.minute()); int targetMins = myTime.hour() * 60 + myTime.minute(); int simMins = zuluTimeSim.valueRounded(CTimeUnit::min()); int diffMins = qAbs(targetMins - simMins); @@ -824,8 +824,7 @@ namespace BlackSimPlugin HRESULT result = SimConnect_Open(&hSimConnect, BlackMisc::CProject::systemNameAndVersionChar(), nullptr, 0, 0, 0); SimConnect_Close(hSimConnect); - if (result == S_OK) - emit simulatorStarted(); + if (result == S_OK) { emit simulatorStarted(); } }); } diff --git a/src/plugins/simulator/fsx/simulator_fsx.h b/src/plugins/simulator/fsx/simulator_fsx.h index a684b4689..5b6f09bc2 100644 --- a/src/plugins/simulator/fsx/simulator_fsx.h +++ b/src/plugins/simulator/fsx/simulator_fsx.h @@ -190,10 +190,10 @@ namespace BlackSimPlugin int m_syncDeferredCounter = 0; //!< Set when synchronized, used to wait some time int m_simconnectTimerId = -1; //!< Timer identifier int m_skipCockpitUpdateCycles = 0; //!< Skip some update cycles to allow changes in simulator cockpit to be set - int m_interpolationRequest = 0; //!< current interpolation request + int m_interpolationRequest = 0; //!< current interpolation request int m_interpolationsSkipped = 0; //!< number of skipped interpolation request 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 m_simConnectObjects; QFutureWatcher m_watcherConnect;