From 303e8b0f8823b7dfdb85ef4598c11a43b2081271 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Tue, 23 Apr 2019 00:52:47 +0200 Subject: [PATCH] Ref T632, in snapshot avoid to add aircraft which are no longer in range --- src/blackcore/simulator.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/blackcore/simulator.cpp b/src/blackcore/simulator.cpp index c1569fb33..d43d51ac7 100644 --- a/src/blackcore/simulator.cpp +++ b/src/blackcore/simulator.cpp @@ -679,7 +679,7 @@ namespace BlackCore void ISimulator::onRecalculatedRenderedAircraft(const CAirspaceAircraftSnapshot &snapshot) { - if (!snapshot.isValidSnapshot()) { return;} + if (!snapshot.isValidSnapshot()) { return; } // for unrestricted values all add/remove actions are directly linked // when changing back from restricted->unrestricted an one time update is required @@ -692,9 +692,12 @@ namespace BlackCore bool changed = false; if (snapshot.isRenderingEnabled()) { + // make sure not to add aircraft again which are no longer in range + const CCallsignSet callsignsInRange = this->getAircraftInRangeCallsigns(); + const CCallsignSet callsignsEnabledAndStillInRange = snapshot.getEnabledAircraftCallsignsByDistance().intersection(callsignsInRange); const CCallsignSet callsignsInSimulator(this->physicallyRenderedAircraft()); // state in simulator - const CCallsignSet callsignsToBeRemoved(callsignsInSimulator.difference(snapshot.getEnabledAircraftCallsignsByDistance())); - const CCallsignSet callsignsToBeAdded(snapshot.getEnabledAircraftCallsignsByDistance().difference(callsignsInSimulator)); + const CCallsignSet callsignsToBeRemoved(callsignsInSimulator.difference(callsignsEnabledAndStillInRange)); + const CCallsignSet callsignsToBeAdded(callsignsEnabledAndStillInRange.difference(callsignsInSimulator)); if (!callsignsToBeRemoved.isEmpty()) { const int r = this->physicallyRemoveMultipleRemoteAircraft(callsignsToBeRemoved);