mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 04:25:35 +08:00
Ref T180, stop requesting data when aircraft is removed
This commit is contained in:
@@ -69,6 +69,9 @@ namespace BlackSimPlugin
|
||||
//! Set current lights when received from simulator
|
||||
void setCurrentLightsInSimulator(const BlackMisc::Aviation::CAircraftLights &lights) { m_currentLightsInSim = lights; }
|
||||
|
||||
//! Pretend to have received lights from simulator
|
||||
void fakeCurrentLightsInSimulator() { m_currentLightsInSim.setNull(false); }
|
||||
|
||||
//! Parts as sent to simulator
|
||||
const DataDefinitionRemoteAircraftPartsWithoutLights &getPartsAsSent() const { return m_partsAsSent; }
|
||||
|
||||
|
||||
@@ -895,10 +895,17 @@ namespace BlackSimPlugin
|
||||
|
||||
CSimConnectObject &simObject = m_simConnectObjects[callsign];
|
||||
if (simObject.isPendingRemoved()) { return true; }
|
||||
if (simObject.isPendingAdded())
|
||||
|
||||
// avoid further data from simulator
|
||||
this->stopRequestingDataForSimObject(simObject);
|
||||
|
||||
const bool pendingAdded = simObject.isPendingAdded();
|
||||
const bool stillWaitingForLights = !simObject.hasCurrentLightsInSimulator();
|
||||
if (pendingAdded || stillWaitingForLights)
|
||||
{
|
||||
// problem: we try to delete an aircraft just requested to be added
|
||||
// best solution so far, call remove again with a delay
|
||||
simObject.fakeCurrentLightsInSimulator(); // next time looks like we have lights
|
||||
QTimer::singleShot(2000, this, [ = ]
|
||||
{
|
||||
this->physicallyRemoveRemoteAircraft(callsign);
|
||||
@@ -1443,6 +1450,8 @@ namespace BlackSimPlugin
|
||||
bool CSimulatorFsxCommon::requestLightsForSimObject(const CSimConnectObject &simObject)
|
||||
{
|
||||
if (!simObject.hasValidRequestAndObjectId()) { return false; }
|
||||
if (simObject.isPendingRemoved()) { return false; }
|
||||
if (!m_hSimConnect) { return false; }
|
||||
|
||||
// always request, not only when something has changed
|
||||
const HRESULT result = SimConnect_RequestDataOnSimObject(
|
||||
|
||||
Reference in New Issue
Block a user