]> git.mxchange.org Git - flightgear.git/blobdiff - src/Instrumentation/navradio.cxx
Fix Carriers without catapults and wires.
[flightgear.git] / src / Instrumentation / navradio.cxx
index b4455be10013b15952ecf0d3823739e4c52e19a8..bb107b47d82364cb5196d296edd093b796ac2bb3 100644 (file)
@@ -89,6 +89,7 @@ FGNavRadio::FGNavRadio(SGPropertyNode *node) :
     gps_cdi_deflection_node(NULL),
     gps_to_flag_node(NULL),
     gps_from_flag_node(NULL),
+    gps_has_gs_node(NULL),
     last_nav_id(""),
     last_nav_vor(false),
     play_count(0),
@@ -201,6 +202,7 @@ FGNavRadio::init ()
     gps_cdi_deflection_node = fgGetNode("/instrumentation/gps/cdi-deflection", true);
     gps_to_flag_node = fgGetNode("/instrumentation/gps/to-flag", true);
     gps_from_flag_node = fgGetNode("/instrumentation/gps/from-flag", true);
+    gps_has_gs_node = fgGetNode("/instrumentation/gps/has-gs", true);
     
     std::ostringstream temp;
     temp << _name << "nav-ident" << _num;
@@ -314,8 +316,17 @@ FGNavRadio::update(double dt)
     bool nav_serviceable = nav_serviceable_node->getBoolValue();
     bool cdi_serviceable = cdi_serviceable_node->getBoolValue();
     bool tofrom_serviceable = tofrom_serviceable_node->getBoolValue();
-    bool inrange = inrange_node->getBoolValue();
-    bool has_gs = has_gs_node->getBoolValue();
+    bool inrange = false;
+    bool has_gs = false;
+    if ( nav_slaved_to_gps_node->getBoolValue() ) {
+       has_gs = gps_has_gs_node->getBoolValue();
+       has_gs_node->setBoolValue( has_gs );
+       inrange = gps_to_flag_node->getBoolValue()
+           || gps_from_flag_node->getBoolValue();
+    } else {
+       has_gs = has_gs_node->getBoolValue();
+       inrange = inrange_node->getBoolValue();
+    }
     bool is_loc = loc_node->getBoolValue();
     double loc_dist = loc_dist_node->getDoubleValue();
     double effective_range_m;
@@ -449,7 +460,10 @@ FGNavRadio::update(double dt)
                    signal_quality_norm, dt );
         }
         signal_quality_norm_node->setDoubleValue( signal_quality_norm );
-        inrange = signal_quality_norm > 0.2;
+        if ( ! nav_slaved_to_gps_node->getBoolValue() ) {
+           /* not slaved to gps */
+            inrange = signal_quality_norm > 0.2;
+        }
         inrange_node->setBoolValue( inrange );
 
        if ( !is_loc ) {
@@ -607,10 +621,10 @@ FGNavRadio::update(double dt)
                 // FIXME/FINISHME, what should be set here?
             } else if ( inrange ) {
                 double x = gs_dist_node->getDoubleValue();
-                double y = (fgGetDouble("/position/altitude-ft") - nav_elev)
+                double y = (alt_node->getDoubleValue() - nav_elev)
                     * SG_FEET_TO_METER;
                 // cout << "dist = " << x << " height = " << y << endl;
-                double angle = asin( y / x ) * SGD_RADIANS_TO_DEGREES;
+                double angle = atan2( y, x ) * SGD_RADIANS_TO_DEGREES;
                 r = (target_gs - angle) * 5.0;
                 r *= signal_quality_norm;
             }