From 9feb4f39dc34f1fc2e43a1b759df69641ff0587b Mon Sep 17 00:00:00 2001 From: Roland Winklmeier Date: Sun, 25 May 2014 14:50:09 +0200 Subject: [PATCH] Do not insert simconnect objects, which are not belonging to us This issue was most probably caused by a parallel SB installation. For some strange reason, a simconnect object id was received which was not added by swift. With this commit such situations are handled correctly. --- src/plugins/simulator/fsx/simulator_fsx.cpp | 28 ++++++++++----------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/plugins/simulator/fsx/simulator_fsx.cpp b/src/plugins/simulator/fsx/simulator_fsx.cpp index 020a8cb4e..dedc771bb 100644 --- a/src/plugins/simulator/fsx/simulator_fsx.cpp +++ b/src/plugins/simulator/fsx/simulator_fsx.cpp @@ -307,6 +307,20 @@ namespace BlackSimPlugin void CSimulatorFsx::setSimconnectObjectID(DWORD requestID, DWORD objectID) { + // First check, if this request id belongs to us + auto it = m_simConnectObjects.begin(); + for (; it != m_simConnectObjects.end(); ++it) + { + if ((*it).getRequestId() == static_cast(requestID)) + { + break; + } + } + + if ( it == m_simConnectObjects.end() ) + return; + + (*it).setObjectId(objectID); SimConnect_AIReleaseControl(m_hSimConnect, objectID, requestID); SimConnect_TransmitClientEvent(m_hSimConnect, objectID, EVENT_FREEZELAT, 1, SIMCONNECT_GROUP_PRIORITY_HIGHEST, SIMCONNECT_EVENT_FLAG_GROUPID_IS_PRIORITY); @@ -319,20 +333,6 @@ namespace BlackSimPlugin gearHandle.gearHandlePosition = 1; SimConnect_SetDataOnSimObject(m_hSimConnect, CSimConnectDataDefinition::DataDefinitionGearHandlePosition, objectID, SIMCONNECT_DATA_SET_FLAG_DEFAULT, 0, sizeof(gearHandle), &gearHandle); - - CSimConnectObject simObject; - auto it = m_simConnectObjects.begin(); - for (; it != m_simConnectObjects.end(); ++it) - { - if ((*it).getRequestId() == static_cast(requestID)) - { - (*it).setObjectId(objectID); - break; - } - } - if (it != m_simConnectObjects.end()) - m_simConnectObjects.insert(simObject.getCallsign(), simObject); - } void CSimulatorFsx::timerEvent(QTimerEvent * /* event */)