From 516ef6bc4beb1f716de86e4df526773004bea95d Mon Sep 17 00:00:00 2001
From: mfranz <mfranz>
Date: Fri, 5 Oct 2007 14:34:04 +0000
Subject: [PATCH] fix another victim of the new runway search method

---
 src/Main/fg_init.cxx | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx
index 571875f00..810bd322c 100644
--- a/src/Main/fg_init.cxx
+++ b/src/Main/fg_init.cxx
@@ -1185,7 +1185,6 @@ bool fgInitPosition() {
     string apt = fgGetString("/sim/presets/airport-id");
     string rwy_no = fgGetString("/sim/presets/runway");
     bool rwy_req = fgGetBool("/sim/presets/runway-requested");
-    double hdg = fgGetDouble("/sim/presets/heading-deg");
     string vor = fgGetString("/sim/presets/vor-id");
     double vor_freq = fgGetDouble("/sim/presets/vor-freq");
     string ndb = fgGetString("/sim/presets/ndb-id");
@@ -1193,6 +1192,8 @@ bool fgInitPosition() {
     string carrier = fgGetString("/sim/presets/carrier");
     string parkpos = fgGetString("/sim/presets/parkpos");
     string fix = fgGetString("/sim/presets/fix");
+    SGPropertyNode *hdg_preset = fgGetNode("/sim/presets/heading-deg", true);
+    double hdg = hdg_preset->getDoubleValue();
 
     if (hdg > 9990.0)
         hdg = fgGetDouble("/environment/config/boundary/entry/wind-from-heading-deg", 270);
@@ -1217,6 +1218,9 @@ bool fgInitPosition() {
         }
     }
 
+    if (hdg_preset->getDoubleValue() > 9990.0)
+        hdg_preset->setDoubleValue(hdg);
+
     if ( !set_pos && !vor.empty() ) {
         // a VOR is requested
         if ( fgSetPosFromNAV( vor, vor_freq ) ) {
@@ -1256,15 +1260,14 @@ 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") );
+    fgSetDouble( "/orientation/heading-deg", hdg_preset->getDoubleValue());
 
     // 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()) {
         fgSetBool("/sim/presets/onground", false);
     } else {
         fgSetBool("/sim/presets/onground", true);
-    }                              
+    }
 
     return true;
 }