1
0
Fork 0
flightgear/src/GUI/AirportList.cxx
ehofman 1c3e2d4942 Vivian Meazza:
This adds a TACAN instrument to the inventory. Range and bearing are calculated
to the TACAN or VORTAC beacon selected by means of the Channel Selector in the E
quipment/Radio pull-down menu.

A TACAN beacon has also been added to the aircraft carrier Nimitz (channel #029Y
).
2005-10-01 09:56:53 +00:00

50 lines
1.2 KiB
C++

#include <string.h> // strncpy()
#include <Main/globals.hxx>
#include <Airports/simple.hxx>
#include "AirportList.hxx"
AirportList::AirportList (int x, int y, int width, int height)
: puList(x, y, width, height)
{
char buf[1024];
_airports = globals->get_airports();
_nAirports = _airports->size();
_content = new char *[_nAirports+1];
for (int i = 0; i < _nAirports; i++) {
const FGAirport *airport = _airports->getAirport(i);
snprintf(buf, 1023, "%s %s",
airport->getId().c_str(),
airport->getName().c_str());
unsigned int buf_len = (strlen(buf) > 1023) ? 1023 : strlen(buf);
_content[i] = new char[buf_len+1];
memcpy(_content[i], buf, buf_len);
_content[i][buf_len] = '\0';
}
_content[_nAirports] = 0;
newList(_content);
}
AirportList::~AirportList ()
{
for (int i = 0; i < _nAirports; i++) {
delete _content[i];
_content[i] = 0;
}
delete [] _content;
}
char *
AirportList::getListStringValue ()
{
return (char *)_airports->getAirport(getListIntegerValue())->getId().c_str();
}
// end of AirportList.cxx