From 5ac3de21e3e41b9e1723e705978b01ea36d406f6 Mon Sep 17 00:00:00 2001 From: Thomas Geymayer Date: Thu, 27 Sep 2012 12:21:22 +0200 Subject: [PATCH] Fix some CommStation bugs - 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 | 2 +- src/ATC/atcdialog.cxx | 6 ++---- src/Airports/apt_loader.cxx | 17 ++++++++++++++--- src/Navaids/NavDataCache.cxx | 2 +- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/ATC/CommStation.cxx b/src/ATC/CommStation.cxx index c50849cb2..b5280f38b 100644 --- a/src/ATC/CommStation.cxx +++ b/src/ATC/CommStation.cxx @@ -24,7 +24,7 @@ FGAirport* CommStation::airport() const double CommStation::freqMHz() const { - return mFreqKhz / 100.0; + return mFreqKhz / 1000.0; } CommStation* diff --git a/src/ATC/atcdialog.cxx b/src/ATC/atcdialog.cxx index ba7bc1791..98a8e70cb 100644 --- a/src/ATC/atcdialog.cxx +++ b/src/ATC/atcdialog.cxx @@ -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 ) - 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); diff --git a/src/Airports/apt_loader.cxx b/src/Airports/apt_loader.cxx index 6f7ab9eec..a3aa490d3 100644 --- a/src/Airports/apt_loader.cxx +++ b/src/Airports/apt_loader.cxx @@ -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); } diff --git a/src/Navaids/NavDataCache.cxx b/src/Navaids/NavDataCache.cxx index 061a3ae9d..5974aae58 100644 --- a/src/Navaids/NavDataCache.cxx +++ b/src/Navaids/NavDataCache.cxx @@ -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; } -- 2.39.5