]> git.mxchange.org Git - flightgear.git/commitdiff
Fix some CommStation bugs
authorThomas Geymayer <tomgey@gmail.com>
Thu, 27 Sep 2012 10:21:22 +0000 (12:21 +0200)
committerThomas Geymayer <tomgey@gmail.com>
Thu, 27 Sep 2012 10:21:22 +0000 (12:21 +0200)
 - kHz/mHz conversion needs factor 1000 not 100
 - Correctly read name for CommStations from NavCache
 - Fix parsing CommStation names from apt.dat (Name
   can contain spaces)

src/ATC/CommStation.cxx
src/ATC/atcdialog.cxx
src/Airports/apt_loader.cxx
src/Navaids/NavDataCache.cxx

index c50849cb20e30c41629b30c267eb12dbbe4ce86f..b5280f38b94713c2614b191ec0641d95da275adf 100644 (file)
@@ -24,7 +24,7 @@ FGAirport* CommStation::airport() const
 
 double CommStation::freqMHz() const
 {
-    return mFreqKhz / 100.0;
+    return mFreqKhz / 1000.0;
 }
 
 CommStation*
index ba7bc1791382e535b480b2356194de6065fc33d3..98a8e70cbe1bcf38c73dbb60c63798a80026b061 100644 (file)
@@ -145,17 +145,16 @@ void FGATCDialogNew::frequencyDisplay(const std::string& ident)
                return;
   }
   
-  int n = 0;
   for (unsigned int c=0; c < comms.size(); ++c) {
     flightgear::CommStation* comm = comms[c];
     
     // add frequency line (modified copy of <group-template>)
-               SGPropertyNode *entry = freq_group->getNode("group", n, true);
+               SGPropertyNode *entry = freq_group->getNode("group", c, true);
                copyProperties(freq_group->getNode("group-template", true), entry);
                entry->removeChildren("enabled", true);
     
     entry->setStringValue("text[0]/label", comm->ident());
-    
+
                char buf[8];
                snprintf(buf, 8, "%.2f", comm->freqMHz());
                if(buf[5] == '3') buf[5] = '2';
@@ -163,7 +162,6 @@ void FGATCDialogNew::frequencyDisplay(const std::string& ident)
                buf[7] = '\0';
     
                entry->setStringValue("text[1]/label", buf);
-    ++n;
   }
   
        _gui->showDialog(dialog_name);
index 6f7ab9eece2637faecc456369b88a355688058d2..a3aa490d3c4815485a68aff6e09f6d21f72c91bf 100644 (file)
@@ -493,8 +493,13 @@ private:
         switch (lineId) {
             case 50:
                 ty = FGPositioned::FREQ_AWOS;
-                if (token[2] == "ATIS") {
+                for( size_t i = 2; i < token.size(); ++i )
+                {
+                  if( token[i] == "ATIS" )
+                  {
                     ty = FGPositioned::FREQ_ATIS;
+                    break;
+                  }
                 }
                 break;
 
@@ -505,10 +510,16 @@ private:
             case 55:
             case 56:    ty = FGPositioned::FREQ_APP_DEP; break;
             default:
-                throw sg_range_exception("unupported apt.dat comm station type");
+                throw sg_range_exception("unsupported apt.dat comm station type");
         }
 
-      cache->insertCommStation(ty, token[2], pos, freqKhz, rangeNm, currentAirportID);
+      // Name can contain white spaces. All tokens after the second token are
+      // part of the name.
+      std::string name = token[2];
+      for( size_t i = 3; i < token.size(); ++i )
+        name += ' ' + token[i];
+
+      cache->insertCommStation(ty, name, pos, freqKhz, rangeNm, currentAirportID);
     }
     else SG_LOG( SG_GENERAL, SG_DEBUG, "Found unnamed comm. Skipping: " << lineId);
   }
index 061a3ae9dbcc72e5290d17eda422ae2020ecde2b..5974aae584a5f3aaa72705510e64250564914da3 100644 (file)
@@ -646,7 +646,7 @@ public:
     int range = sqlite3_column_int(loadCommStation, 0);
     int freqKhz = sqlite3_column_int(loadCommStation, 1);
     
-    CommStation* c = new CommStation(rowId, id, ty, pos, freqKhz, range);
+    CommStation* c = new CommStation(rowId, name, ty, pos, freqKhz, range);
     c->setAirport(airport);
     return c;
   }