]> git.mxchange.org Git - flightgear.git/blobdiff - src/GUI/AirportList.cxx
Don't restore initial screen geometry because there is nothing in fg_os* to resize...
[flightgear.git] / src / GUI / AirportList.cxx
index 73fbdd2aa6d858a147c323f82f71a3165ee96732..5b28e6bf29fc4fbd6213e64f197d0e95079b8e71 100644 (file)
@@ -16,13 +16,16 @@ AirportList::AirportList (int x, int y, int width, int height)
 
     _content = new char *[_nAirports+1];
     for (int i = 0; i < _nAirports; i++) {
-        const FGAirport * airport = _airports->getAirport(i);
-        snprintf(buf, 1023, "%s  %s\n",
-                 airport->id.c_str(),
-                 airport->name.c_str());
-        int str_len = strlen(buf);
-        _content[i] = new char[(str_len > 1023) ? 1024 : str_len+1];
-        strncpy(_content[i], buf, 1023);
+        const FGAirport *airport = _airports->getAirport(i);
+        snprintf(buf, 1023, "%s  (%s)",
+                 airport->getName().c_str(),
+                 airport->getId().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);
@@ -38,9 +41,13 @@ AirportList::~AirportList ()
 }
 
 char *
-AirportList::getStringValue ()
+AirportList::getListStringValue ()
 {
-    return (char *)_airports->getAirport(getIntegerValue())->id.c_str();
+    int i = getListIntegerValue();
+    if (i >= 0)
+        return (char *)_airports->getAirport(i)->getId().c_str();
+    else
+        return "";
 }
 
 // end of AirportList.cxx