From: curt Date: Sat, 17 Mar 2001 21:06:43 +0000 (+0000) Subject: Julian Foad: fixes to meters/feet confusion. (Also length of "--vNorth=" X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=4cf4edcfb40d384de6010c5588796a76a20ad57b;p=flightgear.git Julian Foad: fixes to meters/feet confusion. (Also length of "--vNorth=" is 9 not 8.) Note that the initial altitude setting was placing us way below the ground, but as it doesn't seem to have caused us problems, it's probably redundant! --- diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index 3f330270e..d2e5bb305 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -380,12 +380,15 @@ bool fgInitPosition( void ) { // if we requested on ground startups if ( fgGetBool( "/sim/startup/onground" ) ) { - fgSetDouble("/position/altitude", scenery.cur_elev + 1 ); + fgSetDouble( "/position/altitude", (scenery.cur_elev + 1) + * METERS_TO_FEET ); } // if requested altitude is below ground level - if ( scenery.cur_elev > fgGetDouble("/position/altitude") - 1) { - fgSetDouble("/position/altitude", scenery.cur_elev + 1 ); + if ( scenery.cur_elev > + fgGetDouble("/position/altitude") * METERS_TO_FEET - 1) { + fgSetDouble("/position/altitude", + (scenery.cur_elev + 1) * METERS_TO_FEET ); } FG_LOG( FG_GENERAL, FG_INFO, diff --git a/src/Main/options.cxx b/src/Main/options.cxx index 52d30fab4..636db9029 100644 --- a/src/Main/options.cxx +++ b/src/Main/options.cxx @@ -186,6 +186,8 @@ fgSetDefaults () fgSetString("/sim/networking/call-sign", "Johnny"); } + +// parse a time string ([+/-]%f[:%f[:%f]]) into hours static double parse_time(const string& time_in) { char *time_str, num[256]; @@ -265,6 +267,7 @@ parse_time(const string& time_in) { } +// parse a date string (yyyy:mm:dd:hh:mm:ss) into a time_t (seconds) static long int parse_date( const string& date) { @@ -373,7 +376,7 @@ parse_date( const string& date) } -/// parse degree in the form of [+/-]hhh:mm:ss +// parse angle in the form of [+/-]ddd:mm:ss into degrees static double parse_degree( const string& degree_str) { double result = parse_time( degree_str ); @@ -384,7 +387,7 @@ parse_degree( const string& degree_str) { } -// parse time offset command line option +// parse time offset string into seconds static int parse_time_offset( const string& time_str) { int result; @@ -454,7 +457,7 @@ parse_channel( const string& type, const string& channel_str ) { } -// Parse --wp=ID[,alt] +// Parse --wp=ID[@alt] static bool parse_wp( const string& arg ) { string id, alt_str; @@ -586,52 +589,46 @@ parse_option (const string& arg) atof(arg.substr(11)) * METER_TO_FEET); } else if ( arg.find( "--uBody=" ) == 0 ) { fgSetString("/sim/startup/speed-set", "UVW"); - // FIXME: the units are totally confused here if ( fgGetString("/sim/startup/units") == "feet" ) fgSetDouble("/velocities/uBody", atof(arg.substr(8))); else fgSetDouble("/velocities/uBody", - atof(arg.substr(8)) * FEET_TO_METER); + atof(arg.substr(8)) * METER_TO_FEET); } else if ( arg.find( "--vBody=" ) == 0 ) { fgSetString("/sim/startup/speed-set", "UVW"); - // FIXME: the units are totally confused here if ( fgGetString("/sim/startup/units") == "feet" ) fgSetDouble("/velocities/vBody", atof(arg.substr(8))); else fgSetDouble("/velocities/vBody", - atof(arg.substr(8)) * FEET_TO_METER); + atof(arg.substr(8)) * METER_TO_FEET); } else if ( arg.find( "--wBody=" ) == 0 ) { fgSetString("/sim/startup/speed-set", "UVW"); - // FIXME: the units are totally confused here if ( fgGetString("/sim/startup/units") == "feet" ) fgSetDouble("/velocities/wBody", atof(arg.substr(8))); else fgSetDouble("/velocities/wBody", - atof(arg.substr(8)) * FEET_TO_METER); + atof(arg.substr(8)) * METER_TO_FEET); } else if ( arg.find( "--vNorth=" ) == 0 ) { fgSetString("/sim/startup/speed-set", "NED"); - // FIXME: the units are totally confused here if ( fgGetString("/sim/startup/units") == "feet" ) - fgSetDouble("/velocities/speed-north", atof(arg.substr(8))); + fgSetDouble("/velocities/speed-north", atof(arg.substr(9))); else fgSetDouble("/velocities/speed-north", - atof(arg.substr(8)) * FEET_TO_METER); + atof(arg.substr(9)) * METER_TO_FEET); } else if ( arg.find( "--vEast=" ) == 0 ) { fgSetString("/sim/startup/speed-set", "NED"); - // FIXME: the units are totally confused here if ( fgGetString("/sim/startup/units") == "feet" ) fgSetDouble("/velocities/speed-east", atof(arg.substr(8))); else fgSetDouble("/velocities/speed-east", - atof(arg.substr(8)) * FEET_TO_METER); + atof(arg.substr(8)) * METER_TO_FEET); } else if ( arg.find( "--vDown=" ) == 0 ) { fgSetString("/sim/startup/speed-set", "NED"); - // FIXME: the units are totally confused here if ( fgGetString("/sim/startup/units") == "feet" ) fgSetDouble("/velocities/speed-down", atof(arg.substr(8))); else fgSetDouble("/velocities/speed-down", - atof(arg.substr(8)) * FEET_TO_METER); + atof(arg.substr(8)) * METER_TO_FEET); } else if ( arg.find( "--vc=" ) == 0) { fgSetString("/sim/startup/speed-set", "knots"); fgSetDouble("/velocities/airspeed", atof(arg.substr(5)));