1
0
Fork 0

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.
This commit is contained in:
curt 2004-04-15 22:09:46 +00:00
parent a9188cc5e3
commit 3db9dc5a23
2 changed files with 88 additions and 28 deletions

View file

@ -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<string>::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.
////////////////////////////////////////////////////////////////////

View file

@ -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;