diff --git a/src/Autopilot/auto_gui.cxx b/src/Autopilot/auto_gui.cxx index aa2c224e5..7b4ef55df 100644 --- a/src/Autopilot/auto_gui.cxx +++ b/src/Autopilot/auto_gui.cxx @@ -677,7 +677,7 @@ int NewWaypoint( string Tgt_Alt ) return 1; - } else if ( current_fixlist->query( TgtAptId, &f ) ) { + } else if ( globals->get_fixlist()->query( TgtAptId, &f ) ) { SG_LOG( SG_GENERAL, SG_INFO, "Adding waypoint (fix) = " << TgtAptId ); diff --git a/src/Cockpit/dme.cxx b/src/Cockpit/dme.cxx index 4c965e709..9371c0cc5 100644 --- a/src/Cockpit/dme.cxx +++ b/src/Cockpit/dme.cxx @@ -221,7 +221,7 @@ void FGDME::search() FGILS *ils; FGNav *nav; - if ( (ils = current_ilslist->findByFreq( freq, lon, lat, elev )) != NULL ) { + if ( (ils = globals->get_ilslist()->findByFreq( freq, lon, lat, elev )) != NULL ) { if ( ils->get_has_dme() ) { valid = true; lon = ils->get_loclon(); @@ -233,7 +233,7 @@ void FGDME::search() y = ils->get_dme_y(); z = ils->get_dme_z(); } - } else if ( (nav = current_navlist->findByFreq(freq, lon, lat, elev)) != NULL ) { + } else if ( (nav = globals->get_navlist()->findByFreq(freq, lon, lat, elev)) != NULL ) { if (nav->get_has_dme()) { valid = true; lon = nav->get_lon(); diff --git a/src/Cockpit/kr_87.cxx b/src/Cockpit/kr_87.cxx index 81c0224c0..3df7832b3 100644 --- a/src/Cockpit/kr_87.cxx +++ b/src/Cockpit/kr_87.cxx @@ -488,7 +488,7 @@ void FGKR_87::search() { //////////////////////////////////////////////////////////////////////// FGNav *nav - = current_navlist->findByFreq(freq, acft_lon, acft_lat, acft_elev); + = globals->get_navlist()->findByFreq(freq, acft_lon, acft_lat, acft_elev); if ( nav != NULL ) { char sfreq[128]; diff --git a/src/Cockpit/marker_beacon.cxx b/src/Cockpit/marker_beacon.cxx index efe73b664..eaaf8a302 100644 --- a/src/Cockpit/marker_beacon.cxx +++ b/src/Cockpit/marker_beacon.cxx @@ -174,8 +174,8 @@ void FGMarkerBeacon::search() //////////////////////////////////////////////////////////////////////// FGMkrBeacon::fgMkrBeacType beacon_type - = current_beacons->query( lon * SGD_RADIANS_TO_DEGREES, - lat * SGD_RADIANS_TO_DEGREES, elev ); + = globals->get_beacons()->query( lon * SGD_RADIANS_TO_DEGREES, + lat * SGD_RADIANS_TO_DEGREES, elev ); outer_marker = middle_marker = inner_marker = false; diff --git a/src/Cockpit/navcom.cxx b/src/Cockpit/navcom.cxx index 929f81191..025a9e32d 100644 --- a/src/Cockpit/navcom.cxx +++ b/src/Cockpit/navcom.cxx @@ -604,7 +604,7 @@ void FGNavCom::search() // Nav. //////////////////////////////////////////////////////////////////////// - if ( (ils = current_ilslist->findByFreq(nav_freq, lon, lat, elev)) != NULL ) { + if ( (ils = globals->get_ilslist()->findByFreq(nav_freq, lon, lat, elev)) != NULL ) { nav_id = ils->get_locident(); nav_valid = true; if ( last_nav_id != nav_id || last_nav_vor ) { @@ -678,7 +678,7 @@ void FGNavCom::search() // cout << "Found an ils station in range" << endl; // cout << " id = " << ils->get_locident() << endl; } - } else if ( (nav = current_navlist->findByFreq(nav_freq, lon, lat, elev)) != NULL ) { + } else if ( (nav = globals->get_navlist()->findByFreq(nav_freq, lon, lat, elev)) != NULL ) { nav_id = nav->get_ident(); nav_valid = (nav->get_type() == 'V'); if ( last_nav_id != nav_id || !last_nav_vor ) { diff --git a/src/Instrumentation/adf.cxx b/src/Instrumentation/adf.cxx index b9af249a7..c1865da34 100644 --- a/src/Instrumentation/adf.cxx +++ b/src/Instrumentation/adf.cxx @@ -163,9 +163,9 @@ ADF::search (double frequency_khz, double longitude_rad, _time_before_search_sec = 1.0; // try the ILS list first - FGNav * nav = - current_navlist->findByFreq(frequency_khz, longitude_rad, - latitude_rad, altitude_m); + FGNav *nav = + globals->get_navlist()->findByFreq(frequency_khz, longitude_rad, + latitude_rad, altitude_m); if (nav !=0) { _transmitter_valid = true; diff --git a/src/Instrumentation/dme.cxx b/src/Instrumentation/dme.cxx index d474e976d..907640a8e 100644 --- a/src/Instrumentation/dme.cxx +++ b/src/Instrumentation/dme.cxx @@ -149,10 +149,10 @@ DME::search (double frequency_mhz, double longitude_rad, _time_before_search_sec = 1.0; // try the ILS list first - FGILS * ils = current_ilslist->findByFreq(frequency_mhz, - longitude_rad, - latitude_rad, - altitude_m); + FGILS *ils = globals->get_ilslist()->findByFreq(frequency_mhz, + longitude_rad, + latitude_rad, + altitude_m); if (ils !=0 && ils->get_has_dme()) { _transmitter_valid = true; _transmitter = Point3D(ils->get_dme_x(), @@ -164,10 +164,10 @@ DME::search (double frequency_mhz, double longitude_rad, } // try the VORs next - FGNav * nav = current_navlist->findByFreq(frequency_mhz, - longitude_rad, - latitude_rad, - altitude_m); + FGNav *nav = globals->get_navlist()->findByFreq(frequency_mhz, + longitude_rad, + latitude_rad, + altitude_m); if (nav != 0 && nav->get_has_dme()) { _transmitter_valid = true; _transmitter = Point3D(nav->get_x(), diff --git a/src/Instrumentation/gps.cxx b/src/Instrumentation/gps.cxx index ad88da212..1fae6b5d0 100644 --- a/src/Instrumentation/gps.cxx +++ b/src/Instrumentation/gps.cxx @@ -326,10 +326,12 @@ GPS::update (double delta_time_sec) } } else if (waypont_type == "nav") { - FGNav * n; - if ( (n = current_navlist->findByIdent(wp0_ID.c_str(), - longitude_deg, - latitude_deg)) != NULL) { + FGNav *n; + if ( (n = globals->get_navlist()->findByIdent(wp0_ID.c_str(), + longitude_deg, + latitude_deg)) + != NULL) + { //cout << "Nav found" << endl; wp0_longitude_deg = n->get_lon(); wp0_latitude_deg = n->get_lat(); @@ -338,7 +340,7 @@ GPS::update (double delta_time_sec) } else if (waypont_type == "fix") { FGFix f; - if ( current_fixlist->query(wp0_ID, &f) ) { + if ( globals->get_fixlist()->query(wp0_ID, &f) ) { //cout << "Fix found" << endl; wp0_longitude_deg = f.get_lon(); wp0_latitude_deg = f.get_lat(); @@ -365,9 +367,11 @@ GPS::update (double delta_time_sec) } else if (waypont_type == "nav") { FGNav * n; - if ( (n = current_navlist->findByIdent(wp1_ID.c_str(), - longitude_deg, - latitude_deg)) != NULL) { + if ( (n = globals->get_navlist()->findByIdent(wp1_ID.c_str(), + longitude_deg, + latitude_deg)) + != NULL) + { //cout << "Nav found" << endl; wp1_longitude_deg = n->get_lon(); wp1_latitude_deg = n->get_lat(); @@ -376,7 +380,7 @@ GPS::update (double delta_time_sec) } else if (waypont_type == "fix") { FGFix f; - if ( current_fixlist->query(wp1_ID, &f) ) { + if ( globals->get_fixlist()->query(wp1_ID, &f) ) { //cout << "Fix found" << endl; wp1_longitude_deg = f.get_lon(); wp1_latitude_deg = f.get_lat(); diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index 33a85f244..9ae3e3299 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -906,7 +906,7 @@ static void fgSetDistOrAltFromGlideSlope() { // Set current_options lon/lat given an airport id and heading (degrees) static bool fgSetPosFromNAV( const string& id, const double& freq ) { - FGNav *nav = current_navlist->findByIdentAndFreq( id.c_str(), freq ); + FGNav *nav = globals->get_navlist()->findByIdentAndFreq( id.c_str(), freq ); // set initial position from runway and heading if ( nav != NULL ) { @@ -958,7 +958,7 @@ static bool fgSetPosFromFix( const string& id ) { FGFix fix; // set initial position from runway and heading - if ( current_fixlist->query( id.c_str(), &fix ) ) { + if ( globals->get_fixlist()->query( id.c_str(), &fix ) ) { SG_LOG( SG_GENERAL, SG_INFO, "Attempting to set starting position for " << id ); @@ -1049,24 +1049,28 @@ fgInitNav () SG_LOG(SG_GENERAL, SG_INFO, "Loading Navaids"); SG_LOG(SG_GENERAL, SG_INFO, " VOR/NDB"); - current_navlist = new FGNavList; + FGNavList *navlist = new FGNavList; SGPath p_nav( globals->get_fg_root() ); p_nav.append( "Navaids/default.nav" ); - current_navlist->init( p_nav ); + navlist->init( p_nav ); + globals->set_navlist( navlist ); SG_LOG(SG_GENERAL, SG_INFO, " ILS and Marker Beacons"); - current_beacons = new FGMarkerBeacons; - current_beacons->init(); - current_ilslist = new FGILSList; + FGMarkerBeacons *beacons = new FGMarkerBeacons; + beacons->init(); + globals->set_beacons( beacons ); + FGILSList *ilslist = new FGILSList; SGPath p_ils( globals->get_fg_root() ); p_ils.append( "Navaids/default.ils" ); - current_ilslist->init( p_ils ); + ilslist->init( p_ils ); + globals->set_ilslist( ilslist ); SG_LOG(SG_GENERAL, SG_INFO, " Fixes"); - current_fixlist = new FGFixList; + FGFixList *fixlist = new FGFixList; SGPath p_fix( globals->get_fg_root() ); p_fix.append( "Navaids/fix.dat" ); - current_fixlist->init( p_fix ); + fixlist->init( p_fix ); + globals->set_fixlist( fixlist ); return true; } diff --git a/src/Main/globals.cxx b/src/Main/globals.cxx index d65861eee..d000cc954 100644 --- a/src/Main/globals.cxx +++ b/src/Main/globals.cxx @@ -75,7 +75,11 @@ FGGlobals::FGGlobals() : initial_waypoints(0), scenery( NULL ), tile_mgr( NULL ), - io( new FGIO ) + io( new FGIO ), + navlist( NULL ), + fixlist( NULL ), + ilslist( NULL ), + beacons( NULL ) { } diff --git a/src/Main/globals.hxx b/src/Main/globals.hxx index 071c97c24..07ccbc4eb 100644 --- a/src/Main/globals.hxx +++ b/src/Main/globals.hxx @@ -70,6 +70,10 @@ class FGATCDisplay; class FGAircraftModel; class FGControls; class FGIO; +class FGNavList; +class FGFixList; +class FGILSList; +class FGMarkerBeacons; class FGLight; class FGModelMgr; class FGRouteMgr; @@ -191,6 +195,12 @@ private: // Input/Ouput subsystem FGIO *io; + // Navigational Aids + FGNavList *navlist; + FGFixList *fixlist; + FGILSList *ilslist; + FGMarkerBeacons *beacons; + #ifdef FG_MPLAYER_AS //Mulitplayer managers FGMultiplayTxMgr *multiplayer_tx_mgr; @@ -347,7 +357,20 @@ public: inline FGIO* get_io() const { return io; } - /** + inline FGNavList *get_navlist() const { return navlist; } + inline void set_navlist( FGNavList *n ) { navlist = n; } + + inline FGFixList *get_fixlist() const { return fixlist; } + inline void set_fixlist( FGFixList *f ) { fixlist = f; } + + inline FGILSList *get_ilslist() const { return ilslist; } + inline void set_ilslist( FGILSList *i ) { ilslist = i; } + + inline FGMarkerBeacons *get_beacons() const { return beacons; } + inline void set_beacons( FGMarkerBeacons *b ) { beacons = b; } + + + /** * Save the current state as the initial state. */ void saveInitialState (); diff --git a/src/Navaids/Makefile.am b/src/Navaids/Makefile.am index 786f1b6b0..bf38322ed 100644 --- a/src/Navaids/Makefile.am +++ b/src/Navaids/Makefile.am @@ -1,17 +1,18 @@ noinst_LIBRARIES = libNavaids.a -noinst_PROGRAMS = testnavs +# noinst_PROGRAMS = testnavs libNavaids_a_SOURCES = \ fix.hxx fixlist.hxx fixlist.cxx \ ils.hxx ilslist.hxx ilslist.cxx \ mkrbeacons.hxx mkrbeacons.cxx \ - nav.hxx navlist.hxx navlist.cxx + nav.hxx navlist.hxx navlist.cxx \ + navrecord.hxx -testnavs_SOURCES = testnavs.cxx -testnavs_LDADD = \ - libNavaids.a \ - -lsgtiming -lsgmath -lsgmisc -lsgdebug -lsgmagvar -lsgxml \ - $(base_LIBS) -lz +# testnavs_SOURCES = testnavs.cxx +# testnavs_LDADD = \ +# libNavaids.a \ +# -lsgtiming -lsgmath -lsgmisc -lsgdebug -lsgmagvar -lsgxml \ +# $(base_LIBS) -lz INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src diff --git a/src/Navaids/fixlist.hxx b/src/Navaids/fixlist.hxx index c23d4b759..26483a13d 100644 --- a/src/Navaids/fixlist.hxx +++ b/src/Navaids/fixlist.hxx @@ -67,7 +67,4 @@ public: }; -extern FGFixList *current_fixlist; - - #endif // _FG_FIXLIST_HXX diff --git a/src/Navaids/ilslist.cxx b/src/Navaids/ilslist.cxx index 0c278989b..8cbf6fe2d 100644 --- a/src/Navaids/ilslist.cxx +++ b/src/Navaids/ilslist.cxx @@ -29,6 +29,8 @@ #include #include +#include
+ #include "mkrbeacons.hxx" #include "ilslist.hxx" @@ -98,18 +100,21 @@ bool FGILSList::init( SGPath path ) { // update the marker beacon list if ( fabs(ils->get_omlon()) > SG_EPSILON || fabs(ils->get_omlat()) > SG_EPSILON ) { - current_beacons->add( ils->get_omlon(), ils->get_omlat(), - ils->get_gselev(), FGMkrBeacon::OUTER ); + globals->get_beacons()->add( ils->get_omlon(), ils->get_omlat(), + ils->get_gselev(), + FGMkrBeacon::OUTER ); } if ( fabs(ils->get_mmlon()) > SG_EPSILON || fabs(ils->get_mmlat()) > SG_EPSILON ) { - current_beacons->add( ils->get_mmlon(), ils->get_mmlat(), - ils->get_gselev(), FGMkrBeacon::MIDDLE ); + globals->get_beacons()->add( ils->get_mmlon(), ils->get_mmlat(), + ils->get_gselev(), + FGMkrBeacon::MIDDLE ); } if ( fabs(ils->get_imlon()) > SG_EPSILON || fabs(ils->get_imlat()) > SG_EPSILON ) { - current_beacons->add( ils->get_imlon(), ils->get_imlat(), - ils->get_gselev(), FGMkrBeacon::INNER ); + globals->get_beacons()->add( ils->get_imlon(), ils->get_imlat(), + ils->get_gselev(), + FGMkrBeacon::INNER ); } } diff --git a/src/Navaids/ilslist.hxx b/src/Navaids/ilslist.hxx index 1538b14d8..da5a6f025 100644 --- a/src/Navaids/ilslist.hxx +++ b/src/Navaids/ilslist.hxx @@ -72,7 +72,4 @@ public: }; -extern FGILSList *current_ilslist; - - #endif // _FG_ILSLIST_HXX diff --git a/src/Navaids/mkrbeacons.cxx b/src/Navaids/mkrbeacons.cxx index 57f2fcd6e..be1cbed74 100644 --- a/src/Navaids/mkrbeacons.cxx +++ b/src/Navaids/mkrbeacons.cxx @@ -134,7 +134,8 @@ bool FGMarkerBeacons::add( double lon, double lat, double elev, // returns marker beacon type if we are over a marker beacon, NOBEACON // otherwise FGMkrBeacon::fgMkrBeacType FGMarkerBeacons::query( double lon, double lat, - double elev ) { + double elev ) +{ double diff; int lonidx = (int)lon; @@ -160,7 +161,8 @@ FGMkrBeacon::fgMkrBeacType FGMarkerBeacons::query( double lon, double lat, beacon_list_iterator current = beacons.begin(); beacon_list_iterator last = beacons.end(); - Point3D aircraft = sgGeodToCart(Point3D(lon*SGD_DEGREES_TO_RADIANS, lat*SGD_DEGREES_TO_RADIANS, 0)); + Point3D aircraft = sgGeodToCart( Point3D(lon*SGD_DEGREES_TO_RADIANS, + lat*SGD_DEGREES_TO_RADIANS, 0) ); double min_dist = 999999999.0; diff --git a/src/Navaids/mkrbeacons.hxx b/src/Navaids/mkrbeacons.hxx index 619f88cea..75944d839 100644 --- a/src/Navaids/mkrbeacons.hxx +++ b/src/Navaids/mkrbeacons.hxx @@ -110,7 +110,4 @@ public: }; -extern FGMarkerBeacons *current_beacons; - - #endif // _FG_MKRBEACON_HXX diff --git a/src/Navaids/navlist.hxx b/src/Navaids/navlist.hxx index 31e997276..de0bfa7f4 100644 --- a/src/Navaids/navlist.hxx +++ b/src/Navaids/navlist.hxx @@ -82,7 +82,4 @@ public: }; -extern FGNavList *current_navlist; - - #endif // _FG_NAVLIST_HXX diff --git a/src/Navaids/testnavs.cxx b/src/Navaids/testnavs.cxx index 6afc18933..0f1f33619 100644 --- a/src/Navaids/testnavs.cxx +++ b/src/Navaids/testnavs.cxx @@ -11,7 +11,7 @@ const string FG_DATA_DIR("/usr/local/lib/FlightGear"); int main() { double heading, dist; - current_navlist = new FGNavList; + FGNavList *current_navlist = new FGNavList; SGPath p_nav( FG_DATA_DIR + "/Navaids/default.nav" ); current_navlist->init( p_nav ); @@ -42,10 +42,10 @@ int main() { } // we have to init the marker beacon storage before we parse the ILS file - current_beacons = new FGMarkerBeacons; + FGMarkerBeacons *current_beacons = new FGMarkerBeacons; current_beacons->init(); - current_ilslist = new FGILSList; + FGILSList *current_ilslist = new FGILSList; SGPath p_ils( FG_DATA_DIR + "/Navaids/default.ils" ); current_ilslist->init( p_ils ); FGILS *i = current_ilslist->findByFreq( -93.1 * SG_DEGREES_TO_RADIANS, @@ -59,7 +59,7 @@ int main() { cout << "not picking up ils. :-(" << endl; } - current_fixlist = new FGFixList; + FGFixList *current_fixlist = new FGFixList; SGPath p_fix( FG_DATA_DIR + "/Navaids/default.fix" ); current_fixlist->init( p_fix ); FGFix fix;