Browse Source

ignore the sweatbox and playbacks to use only real VATSIM data

Sven Czarnian 3 years ago
parent
commit
e4ea8f46c8
2 changed files with 41 additions and 3 deletions
  1. 39 3
      src/PlugIn.cpp
  2. 2 0
      src/PlugIn.h

+ 39 - 3
src/PlugIn.cpp

@@ -56,7 +56,9 @@ PlugIn::PlugIn() :
         m_inboundsQueueLock(),
         m_inbounds(),
         m_forcedToBackendCallsigns(),
-        m_compatible(false) {
+        m_compatible(false),
+        m_sweatboxValid(false),
+        m_playbackValid(false) {
     GOOGLE_PROTOBUF_VERIFY_VERSION;
 
     this->RegisterTagItemType("Delta time", static_cast<int>(PlugIn::TagItemElement::DeltaTime));
@@ -376,6 +378,7 @@ void PlugIn::generateAircraftReportMessage(EuroScopePlugIn::CRadarTarget& radarT
 
 bool PlugIn::OnCompileCommand(const char* cmdline) {
     std::string message(cmdline);
+    bool retval = false;
 
 #pragma warning(disable: 4244)
     std::transform(message.begin(), message.end(), message.begin(), ::toupper);
@@ -383,11 +386,37 @@ bool PlugIn::OnCompileCommand(const char* cmdline) {
 
     /* no AMAN command */
     if (0 != message.find(".AMAN"))
-        return false;
+        return retval;
 
     if (std::string::npos != message.find("RELOAD")) {
         this->validateBackendData();
-        return true;
+        this->m_sweatboxValid = false;
+        this->m_playbackValid = false;
+        retval = true;
+    }
+    else if (std::string::npos != message.find("SWEATBOX")) {
+        this->m_sweatboxValid = !this->m_sweatboxValid;
+        if (true == this->m_sweatboxValid)
+            this->m_playbackValid = false;
+        retval = true;
+    }
+    else if (std::string::npos != message.find("PLAYBACK")) {
+        this->m_playbackValid = !this->m_playbackValid;
+        if (true == this->m_playbackValid)
+            this->m_sweatboxValid = false;
+        retval = true;
+    }
+
+    if (true == retval) {
+        if (true == this->m_sweatboxValid)
+            this->DisplayUserMessage(PLUGIN_NAME, "INFO", "Sweatbox data is used in AMAN", true, true, false, false, false);
+        else
+            this->DisplayUserMessage(PLUGIN_NAME, "INFO", "Sweatbox is ignored in AMAN", true, true, false, false, false);
+
+        if (true == this->m_playbackValid)
+            this->DisplayUserMessage(PLUGIN_NAME, "INFO", "Playback data is used in AMAN", true, true, false, false, false);
+        else
+            this->DisplayUserMessage(PLUGIN_NAME, "INFO", "Playback is ignored in AMAN", true, true, false, false, false);
     }
 
     return false;
@@ -524,6 +553,13 @@ void PlugIn::OnRadarTargetPositionUpdate(EuroScopePlugIn::CRadarTarget radarTarg
     if (false == this->m_compatible || false == Backend::instance().initialized() || false == radarTarget.IsValid())
         return;
 
+    /* validate the correct connection */
+    bool validConnection = EuroScopePlugIn::CONNECTION_TYPE_DIRECT == this->GetConnectionType();
+    validConnection |= true == this->m_sweatboxValid && EuroScopePlugIn::CONNECTION_TYPE_SIMULATOR_CLIENT == this->GetConnectionType();
+    validConnection |= true == this->m_playbackValid && EuroScopePlugIn::CONNECTION_TYPE_PLAYBACK == this->GetConnectionType();
+    if (false == validConnection)
+        return;
+
     this->addUpdateQueue(radarTarget);
     this->updateInbound(radarTarget);
 }

+ 2 - 0
src/PlugIn.h

@@ -60,6 +60,8 @@ namespace aman {
         std::map<std::string, Inbound>                m_inbounds;
         std::list<std::string>                        m_forcedToBackendCallsigns;
         bool                                          m_compatible;
+        bool                                          m_sweatboxValid;
+        bool                                          m_playbackValid;
 
     public:
         /**