structure.
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 );
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();
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();
////////////////////////////////////////////////////////////////////////
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];
////////////////////////////////////////////////////////////////////////
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;
// 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 ) {
// 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 ) {
_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;
_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(),
}
// 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(),
}
}
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();
}
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();
}
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();
}
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();
// 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 ) {
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 );
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;
}
initial_waypoints(0),
scenery( NULL ),
tile_mgr( NULL ),
- io( new FGIO )
+ io( new FGIO ),
+ navlist( NULL ),
+ fixlist( NULL ),
+ ilslist( NULL ),
+ beacons( NULL )
{
}
class FGAircraftModel;
class FGControls;
class FGIO;
+class FGNavList;
+class FGFixList;
+class FGILSList;
+class FGMarkerBeacons;
class FGLight;
class FGModelMgr;
class FGRouteMgr;
// 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;
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 ();
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
};
-extern FGFixList *current_fixlist;
-
-
#endif // _FG_FIXLIST_HXX
#include <simgear/misc/sgstream.hxx>
#include <simgear/math/sg_geodesy.hxx>
+#include <Main/globals.hxx>
+
#include "mkrbeacons.hxx"
#include "ilslist.hxx"
// 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 );
}
}
};
-extern FGILSList *current_ilslist;
-
-
#endif // _FG_ILSLIST_HXX
// 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;
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;
};
-extern FGMarkerBeacons *current_beacons;
-
-
#endif // _FG_MKRBEACON_HXX
};
-extern FGNavList *current_navlist;
-
-
#endif // _FG_NAVLIST_HXX
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 );
}
// 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,
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;