class Sound;
extern const char *default_root;
-extern string_list waypoints;
+
#ifdef FG_USE_CLOUDS_3D
SkySceneLoader *sgCloud3d;
static bool parseWaypoints()
{
- vector<string>::iterator i;
- for (i = waypoints.begin();
- i != waypoints.end();
- i++)
+ string_list *waypoints = globals->get_initial_waypoints();
+ if (waypoints)
{
- 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;
+ vector<string>::iterator i;
+ for (i = waypoints->begin();
+ i != waypoints->end();
+ i++)
+ {
+ NewWaypoint(*i);
+ }
+ // Now were done using the way points we can deallocate the
+ // memory they used
+ while (waypoints->begin() != waypoints->end())
+ waypoints->pop_back();
+ delete waypoints;
+ globals->set_initial_waypoints(0);
}
}
// list of serial port-like configurations
string_list *channel_options_list;
+ // A list of initial waypoints that are read from the command line
+ // and or flight-plan file during initialization
+ string_list *initial_waypoints;
+
// FlightGear scenery manager
FGScenery *scenery;
channel_options_list = l;
}
+ inline string_list *get_initial_waypoints () {
+ return initial_waypoints;
+ }
+
+ inline void set_initial_waypoints (string_list *list) {
+ initial_waypoints = list;
+ }
+
inline FGScenery * get_scenery () const { return scenery; }
inline void set_scenery ( FGScenery *s ) { scenery = s; }
#define NEW_DEFAULT_MODEL_HZ 120
-string_list waypoints;
-
enum
{
FG_OPTIONS_OK = 0,
// 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;
- //}
- //}
- waypoints.push_back(arg);
+ string_list *waypoints = globals->get_initial_waypoints();
+ if (!waypoints)
+ waypoints = new string_list;
+ waypoints->push_back(arg);
+ globals->set_initial_waypoints(waypoints);
}
static bool
parse_flightplan(const string& arg)
{
- sg_gzifstream in(arg.c_str());
- if ( !in.is_open() ) {
- return false;
- }
- while ( true ) {
- string line;
-
+ string_list *waypoints = globals->get_initial_waypoints();
+ if (!waypoints)
+ waypoints = new string_list;
+ sg_gzifstream in(arg.c_str());
+ if ( !in.is_open() ) {
+ return false;
+ }
+ while ( true ) {
+ string line;
+
#if defined( macintosh )
- getline( in, line, '\r' );
+ getline( in, line, '\r' );
#else
- getline( in, line, '\n' );
+ getline( in, line, '\n' );
#endif
-
- // catch extraneous (DOS) line ending character
- if ( line[line.length() - 1] < 32 ) {
- line = line.substr( 0, line.length()-1 );
- }
-
- if ( in.eof() ) {
- break;
- }
- //parse_wp(line);
- waypoints.push_back(line);
+
+ // catch extraneous (DOS) line ending character
+ if ( line[line.length() - 1] < 32 ) {
+ line = line.substr( 0, line.length()-1 );
}
-
- return true;
+
+ if ( in.eof() ) {
+ break;
+ }
+ waypoints->push_back(line);
+ }
+ globals->set_initial_waypoints(waypoints);
+ return true;
}
static int