diff --git a/src/plugins/simulator/fsxcommon/simconnectobject.cpp b/src/plugins/simulator/fsxcommon/simconnectobject.cpp index d89c3dd5d..8def43f62 100644 --- a/src/plugins/simulator/fsxcommon/simconnectobject.cpp +++ b/src/plugins/simulator/fsxcommon/simconnectobject.cpp @@ -115,12 +115,31 @@ namespace BlackSimPlugin void CSimConnectObject::setConfirmedAdded(bool confirm) { m_confirmedAdded = confirm; + m_removedWhileAdding = false; + m_addedWhileRemoving = false; m_aircraft.setRendered(true); } + void CSimConnectObject::setAddedWhileRemoved(bool addedWileRemoved) + { + m_addedWhileRemoving = addedWileRemoved; + } + + void CSimConnectObject::setRemovedWhileAdding(bool removedWhileAdding) + { + m_removedWhileAdding = removedWhileAdding; + } + + bool CSimConnectObject::isReadyToSend() const + { + return !this->isPending() && !m_addedWhileRemoving && !m_removedWhileAdding; + } + void CSimConnectObject::setPendingRemoved(bool pending) { m_pendingRemoved = pending; + m_removedWhileAdding = false; + m_addedWhileRemoving = false; m_aircraft.setRendered(false); } @@ -138,6 +157,8 @@ namespace BlackSimPlugin { m_pendingRemoved = false; m_confirmedAdded = false; + m_removedWhileAdding = false; + m_addedWhileRemoving = false; m_camera = false; m_currentLightsInSim = CAircraftLights(); m_lightsAsSent = CAircraftLights(); @@ -180,8 +201,8 @@ namespace BlackSimPlugin QString CSimConnectObject::toQString() const { - static const QString s("CS: '%1' obj: %2 req: %3 conf.added: %4 pend.rem.: %5"); - return s.arg(this->getCallsign().asString()).arg(m_objectId).arg(m_requestId).arg(boolToYesNo(m_confirmedAdded), boolToYesNo(m_pendingRemoved)); + static const QString s("CS: '%1' obj: %2 req: %3 conf.added: %4 pend.rem.: %5 rwa: %6 awr: %7"); + return s.arg(this->getCallsign().asString()).arg(m_objectId).arg(m_requestId).arg(boolToYesNo(m_confirmedAdded), boolToYesNo(m_pendingRemoved), boolToYesNo(m_removedWhileAdding), boolToYesNo(m_addedWhileRemoving)); } CSimConnectObject::SimObjectType CSimConnectObject::requestIdToType(DWORD requestId) diff --git a/src/plugins/simulator/fsxcommon/simconnectobject.h b/src/plugins/simulator/fsxcommon/simconnectobject.h index 633f8de18..8438e7efe 100644 --- a/src/plugins/simulator/fsxcommon/simconnectobject.h +++ b/src/plugins/simulator/fsxcommon/simconnectobject.h @@ -131,11 +131,17 @@ namespace BlackSimPlugin //! Marked as confirmed, means the simulator has "confirmed" the objectId as added and not instantly removed the object void setConfirmedAdded(bool confirm); + //! Special states + //! @{ + void setAddedWhileRemoved(bool addedWileRemoved); + void setRemovedWhileAdding(bool removedWhileAdding); + //! @} + //! Removing is pending 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(); } + bool isReadyToSend() const; //! Marked as pending for removal void setPendingRemoved(bool pending); @@ -210,7 +216,9 @@ namespace BlackSimPlugin bool m_confirmedAdded = false; bool m_pendingRemoved = false; bool m_camera = false; - int m_lightsRequestedAt = -1; + bool m_removedWhileAdding = false; + bool m_addedWhileRemoving = false; + int m_lightsRequestedAt = -1; GUID m_cameraGuid; SIMCONNECT_DATA_XYZ m_cameraPosition; SIMCONNECT_DATA_PBH m_cameraRotation; diff --git a/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp b/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp index e06122b7f..96fde07c3 100644 --- a/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp +++ b/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp @@ -1272,9 +1272,11 @@ namespace BlackSimPlugin { // problem: we try to delete an aircraft just requested to be added // best solution so far, call remove again with a delay - CLogMessage(this).warning("Object: %1 requested to be removed, but pedning added (%2) / or pending lights(%3). CS '%3' will be removed again.") - << simObject.toQString() << boolToYesNo(pendingAdded) << boolToYesNo(stillWaitingForLights) << callsign.asString(); + CLogMessage(this).warning("Object: '%1' requested to be removed, but pedning added (%2) / or pending lights(%3). CS '%4' will be removed again.") + << simObject.toQString() << boolToYesNo(pendingAdded) + << boolToYesNo(stillWaitingForLights) << callsign.asString(); simObject.fakeCurrentLightsInSimulator(); // next time looks like we have lights + simObject.setRemovedWhileAdding(true); QPointer myself(this); QTimer::singleShot(2000, this, [ = ] { @@ -2064,7 +2066,7 @@ namespace BlackSimPlugin CCallsignSet CSimulatorFsxCommon::physicallyRemoveAircraftNotInProvider() { - const CCallsignSet callsignsToBeRemoved(getCallsignsMissingInProvider()); + const CCallsignSet callsignsToBeRemoved(this->getCallsignsMissingInProvider()); if (callsignsToBeRemoved.isEmpty()) { return callsignsToBeRemoved; } for (const CCallsign &callsign : callsignsToBeRemoved) {