From: david Date: Wed, 1 May 2002 23:13:36 +0000 (+0000) Subject: Regularized the position initialization: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=ff6943bd096b1f7ab65469bf4ea39b572398512a;p=flightgear.git Regularized the position initialization: 1. If /position/longitude-deg and /position/latitude-deg are in range, use them. 2. Otherwise, if /sim/startup/airport-id is not empty, use it. 3. Otherwise, set the lon/lat to the middle of the KSFO field. The default used to be Globe, AZ, but that doesn't make sense since we don't distribute that scenery by default any more. With this change, starting from a save file seems to work properly: fgfs myflight.sav --- diff --git a/src/Main/main.cxx b/src/Main/main.cxx index fa1088da4..d7c12fe53 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -1451,14 +1451,27 @@ int mainLoop( int argc, char **argv ) { // Set position relative to glide slope if requested fgSetPosFromGlideSlope(); - // set current_options lon/lat if an airport id is specified - // cout << "3. airport_id = " << fgGetString("/sim/startup/airport-id") << endl; - if ( fgGetString("/sim/startup/airport-id")[0] != '\0' ) { - // fgSetPosFromAirportID( fgGetString("/sim/startup/airport-id") ); + // If we have an explicit, in-range lon/lat, use it. + // If not, check for an airport-id and use that. + // If not, default to the middle of the KSFO field. + // The default values for lon/lat are deliberately out of range + // so that the airport-id can take effect; valid lon/lat will + // override airport-id, however. + double lon_deg = fgGetDouble("/position/longitude-deg"); + double lat_deg = fgGetDouble("/position/latitude-deg"); + if (lon_deg < -180 || lon_deg > 180 || lat_deg < -90 || lat_deg > 90) { + if ( fgGetString("/sim/startup/airport-id")[0] != '\0' ) { fgSetPosFromAirportIDandHdg( fgGetString("/sim/startup/airport-id"), fgGetDouble("/orientation/heading-deg") ); - // set tower position (a little off the heading for single runway airports) - fgSetTowerPosFromAirportID( fgGetString("/sim/startup/airport-id"), fgGetDouble("orientation/heading") ); + // set tower position (a little off the heading for single + // runway airports) + fgSetTowerPosFromAirportID( fgGetString("/sim/startup/airport-id"), + fgGetDouble("orientation/heading") ); + } else { + // Default to middle of KSFO field + fgSetDouble("/position/longitude-deg", -122.374843); + fgSetDouble("/position/latitude-deg", 37.619002); + } } SGTime *t = fgInitTime(); diff --git a/src/Main/options.cxx b/src/Main/options.cxx index 4f37eeb63..ac662f47a 100644 --- a/src/Main/options.cxx +++ b/src/Main/options.cxx @@ -115,9 +115,9 @@ fgSetDefaults () // Otherwise, default to Scenery being in $FG_ROOT/Scenery globals->set_fg_scenery(""); } - // Position (Globe, AZ) - fgSetDouble("/position/longitude-deg", -110.6642444); - fgSetDouble("/position/latitude-deg", 33.3528917); + // Position (deliberately out of range) + fgSetDouble("/position/longitude-deg", 9999.0); + fgSetDouble("/position/latitude-deg", 9999.0); fgSetDouble("/position/altitude-ft", -9999.0); // Orientation