]> git.mxchange.org Git - flightgear.git/commitdiff
Regularized the position initialization:
authordavid <david>
Wed, 1 May 2002 23:13:36 +0000 (23:13 +0000)
committerdavid <david>
Wed, 1 May 2002 23:13:36 +0000 (23:13 +0000)
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

src/Main/main.cxx
src/Main/options.cxx

index fa1088da421f3b7d6a7ab720bf2beb50872d0922..d7c12fe53521d159fe9f90752f99c95ee636811c 100644 (file)
@@ -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();
index 4f37eeb630da43b1347ae7926ffa9322a4ac68b0..ac662f47afcfc3064f4bfc21ab9481aadd940031 100644 (file)
@@ -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