From 3db9dc5a2347e66755b9b13ca132cc644aa171f7 Mon Sep 17 00:00:00 2001 From: curt Date: Thu, 15 Apr 2004 22:09:46 +0000 Subject: [PATCH] Durk Talsma: Enclosed you find a tar ball of the two files I changed to get the --waypoint and --flight-plan command line option to work again. --- src/Main/fg_init.cxx | 54 +++++++++++++++++++++++++++++++++++++- src/Main/options.cxx | 62 +++++++++++++++++++++++++------------------- 2 files changed, 88 insertions(+), 28 deletions(-) diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index 093cc19ba..4c3a1f1d4 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -140,6 +140,7 @@ SG_USING_STD(string); class Sound; extern const char *default_root; +extern string_list waypoints; #ifdef FG_USE_CLOUDS_3D SkySceneLoader *sgCloud3d; @@ -900,7 +901,7 @@ static void fgSetDistOrAltFromGlideSlope() { fgSetDouble("/sim/presets/glideslope-deg", 0); fgSetBool("/sim/presets/onground", true); } -} +} // Set current_options lon/lat given an airport id and heading (degrees) @@ -999,6 +1000,50 @@ static bool fgSetPosFromFix( const string& id ) { return false; } } + +static bool parseWaypoints() + { + vector::iterator i; + for (i = waypoints.begin(); + i != waypoints.end(); + i++) + { + NewWaypoint(*i); + // string arg = *i; +// string id, alt_str; +// double alt = 0.0; + +// string::size_type pos = arg.find( "@" ); +// if ( pos != string::npos ) { +// id = arg.substr( 0, pos ); +// alt_str = arg.substr( pos + 1 ); +// cout << "id str = " << id << " alt str = " << alt_str << endl; +// alt = atof( alt_str.c_str() ); +// if ( !strcmp(fgGetString("/sim/startup/units"), "feet") ) { +// alt *= SG_FEET_TO_METER; +// } +// } else { +// id = arg; +// } + +// FGAirport a; +// if ( fgFindAirportID( id, &a ) ) { +// FGRouteMgr *rm = (FGRouteMgr *)globals->get_subsystem("route-manager"); +// SGWayPoint wp( a.longitude, a.latitude, alt, SGWayPoint::WGS84, id ); +// rm->add_waypoint( wp ); + +// //return true; +// } else { +// return false; +// } +// } +// // waypoints.begin() = waypoints.erase(waypoints.begin()); +// return true; + } + } + + + /** @@ -1520,6 +1565,7 @@ bool fgInitSubsystems() { globals->add_subsystem( "xml-autopilot", new FGXMLAutopilot ); globals->add_subsystem( "route-manager", new FGRouteMgr ); + //////////////////////////////////////////////////////////////////// // Initialize the view manager subsystem. //////////////////////////////////////////////////////////////////// @@ -1756,6 +1802,12 @@ bool fgInitSubsystems() { globals->add_subsystem("nasal", nasal); nasal->init(); + //////////////////////////////////////////////////////////////////// + // At this point we could try and parse the waypoint options + /////////////////////////////////////////////////////////////////// + parseWaypoints(); + + //////////////////////////////////////////////////////////////////////// // End of subsystem initialization. //////////////////////////////////////////////////////////////////// diff --git a/src/Main/options.cxx b/src/Main/options.cxx index 6235939e0..ebcbefb39 100644 --- a/src/Main/options.cxx +++ b/src/Main/options.cxx @@ -67,6 +67,8 @@ SG_USING_NAMESPACE(std); #define NEW_DEFAULT_MODEL_HZ 120 +string_list waypoints; + enum { FG_OPTIONS_OK = 0, @@ -534,36 +536,41 @@ add_channel( const string& type, const string& channel_str ) { return true; } +// The parse wp and parse flight-plan options don't work anymore, because +// the route manager and the airport subsystems have not yet been initialized +// at this stage. // Parse --wp=ID[@alt] static bool parse_wp( const string& arg ) { - string id, alt_str; - double alt = 0.0; - - string::size_type pos = arg.find( "@" ); - if ( pos != string::npos ) { - id = arg.substr( 0, pos ); - alt_str = arg.substr( pos + 1 ); - // cout << "id str = " << id << " alt str = " << alt_str << endl; - alt = atof( alt_str.c_str() ); - if ( !strcmp(fgGetString("/sim/startup/units"), "feet") ) { - alt *= SG_FEET_TO_METER; - } - } else { - id = arg; - } - - FGAirport a; - if ( fgFindAirportID( id, &a ) ) { - FGRouteMgr *rm = (FGRouteMgr *)globals->get_subsystem("route-manager"); - SGWayPoint wp( a.longitude, a.latitude, alt, SGWayPoint::WGS84, id ); - rm->add_waypoint( wp ); - - return true; - } else { - return false; - } + //string id, alt_str; + //double alt = 0.0; + // + //string::size_type pos = arg.find( "@" ); + //if ( pos != string::npos ) { + //id = arg.substr( 0, pos ); + //alt_str = arg.substr( pos + 1 ); + //// cout << "id str = " << id << " alt str = " << alt_str << endl; + //alt = atof( alt_str.c_str() ); + //if ( !strcmp(fgGetString("/sim/startup/units"), "feet") ) { + // alt *= SG_FEET_TO_METER; + //} + //} else { + //id = arg; + //} + // + //FGAirport a; + //if ( fgFindAirportID( id, &a ) ) { + // FGRouteMgr *rm = (FGRouteMgr *)globals->get_subsystem("route-manager"); + //SGWayPoint wp( a.longitude, a.latitude, alt, SGWayPoint::WGS84, id ); + //rm->add_waypoint( wp ); + // + //return true; + //} else { + //return false; + //} + //} + waypoints.push_back(arg); } @@ -592,7 +599,8 @@ parse_flightplan(const string& arg) if ( in.eof() ) { break; } - parse_wp(line); + //parse_wp(line); + waypoints.push_back(line); } return true;