]> git.mxchange.org Git - flightgear.git/commitdiff
- if no heading preset was given (>=9999), use wind-from direction
authormfranz <mfranz>
Thu, 4 Oct 2007 17:13:41 +0000 (17:13 +0000)
committermfranz <mfranz>
Thu, 4 Oct 2007 17:13:41 +0000 (17:13 +0000)
- write chosen runway to /sim/atc/runway, so that ATC can give a hint
- minor cleanup

src/Main/fg_init.cxx

index 54d9b743ec94eec0daf3e61edab58a96a536b1e6..571875f00e5b9a4fe3fb180cd4851a9c4c0ede86 100644 (file)
@@ -752,21 +752,20 @@ void fgInitTowerLocationListener() {
 static bool fgSetPosFromAirportIDandHdg( const string& id, double tgt_hdg ) {
     FGRunway r;
 
-    if ( id.length() ) {
-        // set initial position from runway and heading
+    if ( id.empty() )
+        return false;
 
-        SG_LOG( SG_GENERAL, SG_INFO,
-                "Attempting to set starting position from airport code "
-                << id << " heading " << tgt_hdg );
-               
-        if ( ! globals->get_runways()->search( id, (int)tgt_hdg, &r ) ) {
-            SG_LOG( SG_GENERAL, SG_ALERT,
-                    "Failed to find a good runway for " << id << '\n' );
-            return false;
-        }      
-    } else {
+    // set initial position from runway and heading
+    SG_LOG( SG_GENERAL, SG_INFO,
+            "Attempting to set starting position from airport code "
+            << id << " heading " << tgt_hdg );
+
+    if ( ! globals->get_runways()->search( id, (int)tgt_hdg, &r ) ) {
+        SG_LOG( SG_GENERAL, SG_ALERT,
+                "Failed to find a good runway for " << id << '\n' );
         return false;
     }
+    fgSetString("/sim/atc/runway", r._rwy_no.c_str());
 
     double lat2, lon2, az2;
     double heading = r._heading;
@@ -821,22 +820,21 @@ static bool fgSetPosFromAirportIDandHdg( const string& id, double tgt_hdg ) {
 static bool fgSetPosFromAirportIDandRwy( const string& id, const string& rwy, bool rwy_req ) {
     FGRunway r;
 
-    if ( id.length() ) {
-        // set initial position from airport and runway number
+    if ( id.empty() )
+        return false;
 
-        SG_LOG( SG_GENERAL, SG_INFO,
-                "Attempting to set starting position for "
-                << id << ":" << rwy );
+    // set initial position from airport and runway number
+    SG_LOG( SG_GENERAL, SG_INFO,
+            "Attempting to set starting position for "
+            << id << ":" << rwy );
 
-        if ( ! globals->get_runways()->search( id, rwy, &r ) ) {
-            SG_LOG( SG_GENERAL, rwy_req ? SG_ALERT : SG_INFO,
-                    "Failed to find runway " << rwy << 
-                    " at airport " << id << ". Using default runway." );
-            return false;
-        }
-    } else {
+    if ( ! globals->get_runways()->search( id, rwy, &r ) ) {
+        SG_LOG( SG_GENERAL, rwy_req ? SG_ALERT : SG_INFO,
+                "Failed to find runway " << rwy <<
+                " at airport " << id << ". Using default runway." );
         return false;
     }
+    fgSetString("/sim/atc/runway", r._rwy_no.c_str());
 
     double lat2, lon2, az2;
     double heading = r._heading;
@@ -1196,7 +1194,8 @@ bool fgInitPosition() {
     string parkpos = fgGetString("/sim/presets/parkpos");
     string fix = fgGetString("/sim/presets/fix");
 
-    fgSetDouble( "/orientation/heading-deg", hdg );
+    if (hdg > 9990.0)
+        hdg = fgGetDouble("/environment/config/boundary/entry/wind-from-heading-deg", 270);
 
     if ( !set_pos && !apt.empty() && !rwy_no.empty() ) {
         // An airport + runway is requested
@@ -1257,6 +1256,8 @@ bool fgInitPosition() {
                  fgGetDouble("/sim/presets/longitude-deg") );
     fgSetDouble( "/position/latitude-deg",
                  fgGetDouble("/sim/presets/latitude-deg") );
+    fgSetDouble( "/orientation/heading-deg",
+                 fgGetDouble("/sim/presets/heading-deg") );
 
     // determine if this should be an on-ground or in-air start
     if ((fabs(gs) > 0.01 || fabs(od) > 0.1 || alt > 0.1) && carrier.empty()) {