mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 04:25:35 +08:00
Ref T317, detect the special states
* pending added, but removed * pending removed, but added again
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user