Ref T273, Ref T275 FSX/P3D uses simulator common function to skip sending equal parts/situations

This commit is contained in:
Klaus Basan
2018-06-04 17:46:09 +02:00
parent f3edf14186
commit 8f336a9631
2 changed files with 12 additions and 10 deletions

View File

@@ -80,24 +80,31 @@ namespace BlackSimPlugin
void fakeCurrentLightsInSimulator() { m_currentLightsInSim.setNull(false); }
//! Parts as sent to simulator
//! \deprecated KB T273 use BlackCore::CSimulatorCommon isEqual / remember functions
const DataDefinitionRemoteAircraftPartsWithoutLights &getPartsAsSent() const { return m_partsAsSent; }
//! Parts as sent to simulator
//! \deprecated KB T273 use BlackCore::CSimulatorCommon isEqual / remember functions
void setPartsAsSent(const DataDefinitionRemoteAircraftPartsWithoutLights &parts) { m_partsAsSent = parts; }
//! Invalidate parts as sent
//! \deprecated KB T273 use BlackCore::CSimulatorCommon isEqual / remember functions
void invalidatePartsAsSent();
//! Parts as sent to simulator
//! \deprecated KB T273 use BlackCore::CSimulatorCommon isEqual / remember functions
const SIMCONNECT_DATA_INITPOSITION &getPositionAsSent() const { return m_positionAsSent; }
//! Position as sent
//! \deprecated KB T273 use BlackCore::CSimulatorCommon isEqual / remember functions
void setPositionAsSent(const SIMCONNECT_DATA_INITPOSITION &position) { m_positionAsSent = position; }
//! Same as sent
//! \deprecated KB T273 use BlackCore::CSimulatorCommon isEqual / remember functions
bool isSameAsSent(const SIMCONNECT_DATA_INITPOSITION &position) const;
//! Invalidate position as sent;
//! Invalidate position as sent
//! \deprecated KB T273 use BlackCore::CSimulatorCommon isEqual / remember functions
void invalidatePositionAsSent();
//! Lights as sent to simulator

View File

@@ -1275,15 +1275,16 @@ namespace BlackSimPlugin
if (result.getInterpolationStatus().hasValidSituation())
{
// update situation
SIMCONNECT_DATA_INITPOSITION position = this->aircraftSituationToFsxPosition(result, sendGround);
if (!simObject.isSameAsSent(position))
if (!this->isEqualLastSent(result))
{
SIMCONNECT_DATA_INITPOSITION position = this->aircraftSituationToFsxPosition(result, sendGround);
m_simConnectObjects[simObject.getCallsign()].setPositionAsSent(position);
const HRESULT hr = SimConnect_SetDataOnSimObject(m_hSimConnect, CSimConnectDefinitions::DataRemoteAircraftSetPosition,
static_cast<SIMCONNECT_OBJECT_ID>(simObject.getObjectId()), 0, 0,
sizeof(SIMCONNECT_DATA_INITPOSITION), &position);
if (hr == S_OK)
{
this->rememberLastSent(result); // remember
if (m_traceSendId) { this->traceSendId(simObject.getObjectId(), Q_FUNC_INFO); }
this->removedClampedLog(callsign);
}
@@ -1316,6 +1317,7 @@ namespace BlackSimPlugin
const CAircraftParts parts = result;
if (parts.getPartsDetails() != CAircraftParts::GuessedParts && !result.getPartsStatus().isSupportingParts()) { return false; }
if (this->isEqualLastSent(parts, simObject.getCallsign())) { return true; }
DataDefinitionRemoteAircraftPartsWithoutLights ddRemoteAircraftPartsWithoutLights(parts); // no init, all values will be set
return this->sendRemoteAircraftPartsToSimulator(simObject, ddRemoteAircraftPartsWithoutLights, parts.getAdjustedLights());
@@ -1326,13 +1328,6 @@ namespace BlackSimPlugin
Q_ASSERT(m_hSimConnect);
const DWORD objectId = simObject.getObjectId();
// same as in simulator or same as already send to simulator?
const CAircraftLights sentLights(simObject.getLightsAsSent());
if (simObject.getPartsAsSent() == ddRemoteAircraftPartsWithoutLights && sentLights == lights)
{
return true;
}
// in case we sent, we sent everything
const HRESULT hr = SimConnect_SetDataOnSimObject(m_hSimConnect, CSimConnectDefinitions::DataRemoteAircraftParts,
objectId, SIMCONNECT_DATA_SET_FLAG_DEFAULT, 0,