Ref T317, detect the special states

* pending added, but removed
* pending removed, but added again
This commit is contained in:
Klaus Basan
2018-08-31 02:01:53 +02:00
parent 88aee2db1a
commit a10e31e36e
3 changed files with 38 additions and 7 deletions

View File

@@ -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)

View File

@@ -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;

View File

@@ -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<CSimulatorFsxCommon> 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)
{