]> git.mxchange.org Git - flightgear.git/commitdiff
Patch from Melchior Franz:
authordavid <david>
Sat, 30 Mar 2002 12:51:42 +0000 (12:51 +0000)
committerdavid <david>
Sat, 30 Mar 2002 12:51:42 +0000 (12:51 +0000)
My last patch fixed the initialization problem only for the main branch, but
ignored the _MWERKS_ branch.
- merged the branches, only the loop head needs different treatment;
- don't access n.type before it is initialized (valgrind complaint)
- created a constructor; the operator>> wouldn't have initialized all
  variables in case of a broken default.nav.gz entry, so we would have
  got a mixture of the broken one and the previous one; in case of
  the first entry, that would have made nice random values ... ;-)
- move the automatic FGNav variable into the loop, so that the gets
  cleanly constructed for every database entry.
- commented out the frequency min/max exploration, which isn't used at all
- updated the commented out debug output statements, which were simply
  copied over from the nav* files, but never adapted (I needed them :-)

src/Navaids/ils.hxx
src/Navaids/ilslist.cxx
src/Navaids/nav.hxx
src/Navaids/navlist.cxx

index b97b2882e9a560199274c23b017b18909efc0d75..8ec84d8c0d82bdc5217782c2c6eaf95ad5f787c2 100644 (file)
@@ -83,7 +83,7 @@ class FGILS {
 
 public:
 
-    inline FGILS(void) {}
+    inline FGILS(void);
     inline ~FGILS(void) {}
 
     inline char get_ilstype() const { return ilstype; }
@@ -124,6 +124,42 @@ public:
 };
 
 
+inline
+FGILS::FGILS(void)
+  : ilstype(0),
+    locfreq(0),
+    locheading(0.0),
+    loclat(0.0),
+    loclon(0.0),
+    x(0.0), y(0.0), z(0.0),
+    has_gs(false),
+    gselev(0.0),
+    gsangle(0.0),
+    gslat(0.0),
+    gslon(0.0),
+    gs_x(0.0), gs_y(0.0), gs_z(0.0),
+    has_dme(false),
+    dmelat(0.0),
+    dmelon(0.0),
+    dme_x(0.0), dme_y(0.0), dme_z(0.0),
+    omlat(0.0),
+    omlon(0.0),
+    mmlat(0.0),
+    mmlon(0.0),
+    imlat(0.0),
+    imlon(0.0),
+    trans_ident(""),
+    loc_failed(false),
+    gs_failed(false),
+    dme_failed(false)
+{
+    ilstypename[0] = '\0';
+    aptcode[0] = '\0';
+    rwyno[0] = '\0';
+    locident[0] = '\0';
+}
+
+    
 inline istream&
 operator >> ( istream& in, FGILS& i )
 {
index e7bd0994e76df82cc85f8ca1803049a46459ce62..6b7dcfc3573d9c40a7e21eafa2a95c1d46bf6b38 100644 (file)
@@ -48,7 +48,6 @@ FGILSList::~FGILSList( void ) {
 
 // load the navaids and build the map
 bool FGILSList::init( SGPath path ) {
-    FGILS ils;
 
     ilslist.erase( ilslist.begin(), ilslist.end() );
 
@@ -63,47 +62,38 @@ bool FGILSList::init( SGPath path ) {
     in >> skipeol;
     in >> skipcomment;
 
-#ifdef __MWERKS__
+    // double min = 1000000.0;
+    // double max = 0.0;
 
+#ifdef __MWERKS__
     char c = 0;
-    while ( in.get(c) && c != '\0' && ils.get_ilstype() != '[' ) {
+    while ( in.get(c) && c != '\0' ) {
         in.putback(c);
-        in >> ils;
-       if ( ils.get_ilstype() != '[' ) {
-           ilslist[ils.get_locfreq()].push_back(ils);
-       }
-        in >> skipcomment;
-    }
-
 #else
-
-    double min = 1000000.0;
-    double max = 0.0;
-
     while ( ! in.eof() ) {
-        in >> ils;
+#endif
 
+        FGILS ils;
+        in >> ils;
         if ( ils.get_ilstype() == '[' ) {
             break;
         }
 
-       /* cout << "id = " << n.get_ident() << endl;
-       cout << " type = " << n.get_type() << endl;
-       cout << " lon = " << n.get_lon() << endl;
-       cout << " lat = " << n.get_lat() << endl;
-       cout << " elev = " << n.get_elev() << endl;
-       cout << " freq = " << n.get_freq() << endl;
-       cout << " range = " << n.get_range() << endl; */
+        /* cout << "typename = " << ils.get_ilstypename() << endl;
+        cout << " aptcode = " << ils.get_aptcode() << endl;
+        cout << " twyno = " << ils.get_rwyno() << endl;
+        cout << " locfreq = " << ils.get_locfreq() << endl;
+        cout << " locident = " << ils.get_locident() << endl << endl; */
 
         ilslist[ils.get_locfreq()].push_back(ils);
         in >> skipcomment;
 
-       if ( ils.get_locfreq() < min ) {
+       /* if ( ils.get_locfreq() < min ) {
            min = ils.get_locfreq();
        }
        if ( ils.get_locfreq() > max ) {
            max = ils.get_locfreq();
-       }
+       } */
 
        // update the marker beacon list
        if ( fabs(ils.get_omlon()) > SG_EPSILON ||
@@ -126,8 +116,6 @@ bool FGILSList::init( SGPath path ) {
     // cout << "min freq = " << min << endl;
     // cout << "max freq = " << max << endl;
 
-#endif
-
     return true;
 }
 
index 8eaf3fa5f8eb72b31819547a2ff01e886a5255b7..fb963b10b6f39c40e3a981024046754be51a0c52 100644 (file)
@@ -66,7 +66,7 @@ class FGNav {
 
 public:
 
-    inline FGNav(void) {}
+    inline FGNav(void);
     inline ~FGNav(void) {}
 
     inline char get_type() const { return type; }
@@ -96,6 +96,24 @@ public:
 };
 
 
+inline
+FGNav::FGNav(void) :
+    type(0),
+    lon(0.0), lat(0.0),
+    elev(0.0),
+    x(0.0), y(0.0), z(0.0),
+    freq(0),
+    range(0),
+    has_dme(false),
+    ident(""),
+    magvar(0.0),
+    trans_ident(""),
+    nav_failed(false),
+    dme_failed(false)
+{
+}
+
+
 inline istream&
 operator >> ( istream& in, FGNav& n )
 {
index 3892dcb8da303d360b31f56c31331adf459aa62a..00566891363337b03b84f77e48703331e906165e 100644 (file)
@@ -47,7 +47,6 @@ FGNavList::~FGNavList( void ) {
 
 // load the navaids and build the map
 bool FGNavList::init( SGPath path ) {
-    FGNav n;
 
     navaids.erase( navaids.begin(), navaids.end() );
 
@@ -62,26 +61,19 @@ bool FGNavList::init( SGPath path ) {
     in >> skipeol;
     in >> skipcomment;
 
-#ifdef __MWERKS__
+    // double min = 100000;
+    // double max = 0;
 
+#ifdef __MWERKS__
     char c = 0;
-    while ( in.get(c) && c != '\0' && n.get_type() != '[' ) {
+    while ( in.get(c) && c != '\0'  ) {
         in.putback(c);
-        in >> n;
-       if ( n.get_type() != '[' ) {
-           navaids[n.get_freq()].push_back(n);
-       }
-        in >> skipcomment;
-    }
-
 #else
-
-    double min = 100000;
-    double max = 0;
-
     while ( ! in.eof() ) {
-        in >> n;
+#endif
 
+        FGNav n;
+        in >> n;
         if ( n.get_type() == '[' ) {
             break;
         }
@@ -92,26 +84,24 @@ bool FGNavList::init( SGPath path ) {
        cout << " lat = " << n.get_lat() << endl;
        cout << " elev = " << n.get_elev() << endl;
        cout << " freq = " << n.get_freq() << endl;
-       cout << " range = " << n.get_range() << endl; */
+       cout << " range = " << n.get_range() << endl << endl; */
 
         navaids[n.get_freq()].push_back(n);
         in >> skipcomment;
 
-       if ( n.get_type() != 'N' ) {
+       /* if ( n.get_type() != 'N' ) {
            if ( n.get_freq() < min ) {
                min = n.get_freq();
            }
            if ( n.get_freq() > max ) {
                max = n.get_freq();
            }
-       }
+       } */
     }
 
     // cout << "min freq = " << min << endl;
     // cout << "max freq = " << max << endl;
 
-#endif
-
     return true;
 }