1
0
Fork 0

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)
This commit is contained in:
Thomas Geymayer 2012-09-27 12:21:22 +02:00
parent 682d78301e
commit 5ac3de21e3
4 changed files with 18 additions and 9 deletions

View file

@ -24,7 +24,7 @@ FGAirport* CommStation::airport() const
double CommStation::freqMHz() const
{
return mFreqKhz / 100.0;
return mFreqKhz / 1000.0;
}
CommStation*

View 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);

View 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);
}

View 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;
}