mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-06 02:16:04 +08:00
Ref T307, using "isReadyToSend" to detect if we can send AI object updates
This commit is contained in:
@@ -134,6 +134,9 @@ namespace BlackSimPlugin
|
|||||||
//! Removing is pending
|
//! Removing is pending
|
||||||
bool isPendingRemoved() const { return m_pendingRemoved; }
|
bool isPendingRemoved() const { return m_pendingRemoved; }
|
||||||
|
|
||||||
|
//! Object which can be used for sending, not pending and valid ids
|
||||||
|
bool isReadyToSend() const { return !this->isPending() && this->hasValidRequestAndObjectId(); }
|
||||||
|
|
||||||
//! Marked as pending for removal
|
//! Marked as pending for removal
|
||||||
void setPendingRemoved(bool pending);
|
void setPendingRemoved(bool pending);
|
||||||
|
|
||||||
|
|||||||
@@ -902,6 +902,7 @@ namespace BlackSimPlugin
|
|||||||
if (this->isShuttingDownOrDisconnected()) { return false; }
|
if (this->isShuttingDownOrDisconnected()) { return false; }
|
||||||
const CSimConnectObject simObject = m_simConnectObjects.getSimObjectForObjectId(objectID);
|
const CSimConnectObject simObject = m_simConnectObjects.getSimObjectForObjectId(objectID);
|
||||||
if (!simObject.hasValidRequestAndObjectId()) { return false; } // object id from somewhere else
|
if (!simObject.hasValidRequestAndObjectId()) { return false; } // object id from somewhere else
|
||||||
|
|
||||||
const CCallsign callsign(simObject.getCallsign());
|
const CCallsign callsign(simObject.getCallsign());
|
||||||
Q_ASSERT_X(!callsign.isEmpty(), Q_FUNC_INFO, "Missing callsign for removed object");
|
Q_ASSERT_X(!callsign.isEmpty(), Q_FUNC_INFO, "Missing callsign for removed object");
|
||||||
|
|
||||||
@@ -1464,8 +1465,7 @@ namespace BlackSimPlugin
|
|||||||
for (const CSimConnectObject &simObject : simObjects)
|
for (const CSimConnectObject &simObject : simObjects)
|
||||||
{
|
{
|
||||||
// happening if aircraft is not yet added to simulator or to be deleted
|
// happening if aircraft is not yet added to simulator or to be deleted
|
||||||
if (simObject.isPendingAdded()) { continue; }
|
if (!simObject.isReadyToSend()) { continue; }
|
||||||
if (simObject.isPendingRemoved()) { continue; }
|
|
||||||
if (!simObject.hasCurrentLightsInSimulator()) { continue; } // wait until we have light state
|
if (!simObject.hasCurrentLightsInSimulator()) { continue; } // wait until we have light state
|
||||||
|
|
||||||
const CCallsign callsign(simObject.getCallsign());
|
const CCallsign callsign(simObject.getCallsign());
|
||||||
@@ -1562,6 +1562,9 @@ namespace BlackSimPlugin
|
|||||||
bool CSimulatorFsxCommon::sendRemoteAircraftPartsToSimulator(const CSimConnectObject &simObject, DataDefinitionRemoteAircraftPartsWithoutLights &ddRemoteAircraftPartsWithoutLights, const CAircraftLights &lights)
|
bool CSimulatorFsxCommon::sendRemoteAircraftPartsToSimulator(const CSimConnectObject &simObject, DataDefinitionRemoteAircraftPartsWithoutLights &ddRemoteAircraftPartsWithoutLights, const CAircraftLights &lights)
|
||||||
{
|
{
|
||||||
Q_ASSERT(m_hSimConnect);
|
Q_ASSERT(m_hSimConnect);
|
||||||
|
|
||||||
|
if (!simObject.isReadyToSend()) { return false; }
|
||||||
|
|
||||||
const DWORD objectId = simObject.getObjectId();
|
const DWORD objectId = simObject.getObjectId();
|
||||||
const bool traceId = this->isTracingSendId();
|
const bool traceId = this->isTracingSendId();
|
||||||
|
|
||||||
@@ -1594,7 +1597,8 @@ namespace BlackSimPlugin
|
|||||||
|
|
||||||
void CSimulatorFsxCommon::sendToggledLightsToSimulator(const CSimConnectObject &simObj, const CAircraftLights &lightsWanted, bool force)
|
void CSimulatorFsxCommon::sendToggledLightsToSimulator(const CSimConnectObject &simObj, const CAircraftLights &lightsWanted, bool force)
|
||||||
{
|
{
|
||||||
if (!simObj.hasValidRequestAndObjectId()) { return; } // stale
|
if (!simObj.isReadyToSend()) { return; } // stale
|
||||||
|
|
||||||
const CAircraftLights lightsIsState = simObj.getCurrentLightsInSimulator();
|
const CAircraftLights lightsIsState = simObj.getCurrentLightsInSimulator();
|
||||||
if (lightsWanted == lightsIsState) { return; }
|
if (lightsWanted == lightsIsState) { return; }
|
||||||
if (!force && lightsWanted == simObj.getLightsAsSent()) { return; }
|
if (!force && lightsWanted == simObj.getLightsAsSent()) { return; }
|
||||||
@@ -1661,7 +1665,7 @@ namespace BlackSimPlugin
|
|||||||
if (!myself) { return; }
|
if (!myself) { return; }
|
||||||
if (!m_simConnectObjects.contains(callsign)) { return; }
|
if (!m_simConnectObjects.contains(callsign)) { return; }
|
||||||
const CSimConnectObject currentSimObject = m_simConnectObjects[callsign];
|
const CSimConnectObject currentSimObject = m_simConnectObjects[callsign];
|
||||||
if (!currentSimObject.hasValidRequestAndObjectId()) { return; } // stale
|
if (!currentSimObject.isReadyToSend()) { return; } // stale
|
||||||
if (lightsWanted != currentSimObject.getLightsAsSent()) { return; } // changed in between, so another call sendToggledLightsToSimulator is pending
|
if (lightsWanted != currentSimObject.getLightsAsSent()) { return; } // changed in between, so another call sendToggledLightsToSimulator is pending
|
||||||
if (this->showDebugLogMessage()) { this->debugLogMessage(Q_FUNC_INFO, QString("Resending light state for '%1', model '%2'").arg(callsign.asString(), simObj.getAircraftModelString())); }
|
if (this->showDebugLogMessage()) { this->debugLogMessage(Q_FUNC_INFO, QString("Resending light state for '%1', model '%2'").arg(callsign.asString(), simObj.getAircraftModelString())); }
|
||||||
this->sendToggledLightsToSimulator(currentSimObject, lightsWanted, true);
|
this->sendToggledLightsToSimulator(currentSimObject, lightsWanted, true);
|
||||||
|
|||||||
Reference in New Issue
Block a user