Browse Source

send the new sequence after every update

Sven Czarnian 3 years ago
parent
commit
f053ead918
1 changed files with 14 additions and 16 deletions
  1. 14 16
      src/PlugIn.cpp

+ 14 - 16
src/PlugIn.cpp

@@ -680,25 +680,23 @@ void PlugIn::OnTimer(int counter) {
     for (auto& airport : this->m_updateQueue) {
         aman::AircraftUpdate update;
         update.set_airport(airport.first);
-        bool inserted = false;
-
-        for (auto target = this->RadarTargetSelectFirst(); true == target.IsValid(); target = this->RadarTargetSelectNext(target)) {
-            auto it = std::find(airport.second.begin(), airport.second.end(), target.GetCallsign());
-            if (airport.second.end() != it) {
-                auto report = update.add_reports();
-                this->generateAircraftReportMessage(target, report);
-                inserted = true;
+
+        if (0 != airport.second.size()) {
+            for (auto target = this->RadarTargetSelectFirst(); true == target.IsValid(); target = this->RadarTargetSelectNext(target)) {
+                auto it = std::find(airport.second.begin(), airport.second.end(), target.GetCallsign());
+                if (airport.second.end() != it) {
+                    auto report = update.add_reports();
+                    this->generateAircraftReportMessage(target, report);
+                }
             }
         }
 
-        if (true == inserted) {
-            /* send the report and request the current sequence */
-            auto sequence = Backend::instance().update(update);
-            if (nullptr == sequence)
-                this->DisplayUserMessage(PLUGIN_NAME, "ERROR", "Unable to send a new aircraft report update", true, true, true, true, true);
-            else
-                this->updateSequence(sequence);
-        }
+        /* send the report and request the current sequence */
+        auto sequence = Backend::instance().update(update);
+        if (nullptr == sequence)
+            this->DisplayUserMessage(PLUGIN_NAME, "ERROR", "Unable to send a new aircraft report update", true, true, true, true, true);
+        else
+            this->updateSequence(sequence);
 
         airport.second.clear();
     }