]> git.mxchange.org Git - flightgear.git/blobdiff - src/Airports/simple.cxx
Fix include order for FreeBSD. Actually this is the published order for
[flightgear.git] / src / Airports / simple.cxx
index 27d9c9baf720e60a13661006fc88cd8a966cf422..3f02a796ddac5e5cc4025544878815750f2c124b 100644 (file)
@@ -40,9 +40,7 @@
 #include <simgear/compiler.h>
 
 #include <simgear/debug/logstream.hxx>
-#include <simgear/misc/fgstream.hxx>
-
-#include <Main/options.hxx>
+#include <simgear/misc/sgstream.hxx>
 
 #include STL_STRING
 #include STL_FUNCTIONAL
 
 #include "simple.hxx"
 
-FG_USING_NAMESPACE(std);
+SG_USING_NAMESPACE(std);
 
 FGAirports::FGAirports( const string& file ) {
     // open the specified database readonly
     storage = new c4_Storage( file.c_str(), false );
 
     if ( !storage->Strategy().IsValid() ) {
-       FG_LOG( FG_GENERAL, FG_ALERT, "Cannot open file: " << file );
+       SG_LOG( SG_GENERAL, SG_ALERT, "Cannot open file: " << file );
        exit(-1);
     }
 
@@ -104,7 +102,7 @@ FGAirports::search( const string& id ) const
 
 // Destructor
 FGAirports::~FGAirports( void ) {
-    // gdbm_close( dbf );
+    delete storage;
 }
 
 
@@ -119,16 +117,17 @@ int FGAirportsUtil::load( const string& file ) {
 
     airports.erase( airports.begin(), airports.end() );
 
-    fg_gzifstream in( file );
+    sg_gzifstream in( file );
     if ( !in.is_open() ) {
-       FG_LOG( FG_GENERAL, FG_ALERT, "Cannot open file: " << file );
+       SG_LOG( SG_GENERAL, SG_ALERT, "Cannot open file: " << file );
        exit(-1);
+    } else {
+       SG_LOG( SG_GENERAL, SG_ALERT, "opened: " << file );
     }
 
     // skip first line of file
-    char tmp[256];
-    in.getline( tmp, 256 );
-
+    char tmp[2048];
+    in.getline( tmp, 2048 );
 
     // read in each line of the file
 
@@ -139,6 +138,7 @@ int FGAirportsUtil::load( const string& file ) {
     while ( in.get(c) && c != '\0' ) {
        if ( c == 'A' ) {
            in >> a;
+            SG_LOG( SG_GENERAL, SG_INFO, a.id );
            in >> skipeol;
            airports.insert(a);
        } else if ( c == 'R' ) {
@@ -152,15 +152,15 @@ int FGAirportsUtil::load( const string& file ) {
 #else
 
     in >> ::skipws;
+    string token;
     while ( ! in.eof() ) {
-       char c = 0;
-       in.get(c);
-       if ( c == 'A' ) {
+       in >> token;
+       if ( token == "A" ) {
            in >> a;
-           cout << "in <- " << a.id << endl;
+            SG_LOG( SG_GENERAL, SG_INFO, "in <- " << a.id );
            in >> skipeol;
            airports.insert(a);
-       } else if ( c == 'R' ) {
+       } else if ( token == "R" ) {
            in >> skipeol;
        } else {
            in >> skipeol;