]> git.mxchange.org Git - flightgear.git/blobdiff - src/Network/native_gui.cxx
Make the AI models a bit more intelligent. The Gear should be extended and retracted...
[flightgear.git] / src / Network / native_gui.cxx
index e2b2391cbb5fde0d1bb27a9eab66541464537ea3..bad4a0b096e094f2673d6000fe537d6f432e0de4 100644 (file)
@@ -35,6 +35,7 @@
 #include <Time/tmp.hxx>
 #include <Main/fg_props.hxx>
 #include <Main/globals.hxx>
+#include <Scenery/scenery.hxx>
 
 #include "native_gui.hxx"
 
@@ -144,13 +145,14 @@ void FGProps2NetGUI( FGNetGUI *net ) {
         net->fuel_quantity[i] = node->getDoubleValue("level-gal_us");
     }
 
-    // the following really aren't used in this context
+    // Environment
     net->cur_time = globals->get_time_params()->get_cur_time();
     net->warp = globals->get_warp();
+    net->ground_elev = globals->get_scenery()->get_cur_elev();
 
     // Approach
     net->tuned_freq = current_radiostack->get_navcom1()->get_nav_freq();
-    net->nav_radial = current_radiostack->get_navcom1()->get_nav_radial();
+    net->nav_radial = current_radiostack->get_navcom1()->get_nav_target_radial();
     net->in_range = current_radiostack->get_navcom1()->get_nav_inrange();
 
     if ( current_radiostack->get_navcom1()->get_nav_loc() ) {
@@ -165,8 +167,14 @@ void FGProps2NetGUI( FGNetGUI *net ) {
     }
 
     net->course_deviation_deg
-        = current_radiostack->get_navcom1()->get_nav_heading()
-        - current_radiostack->get_navcom1()->get_nav_radial();
+        = current_radiostack->get_navcom1()->get_nav_reciprocal_radial()
+        - current_radiostack->get_navcom1()->get_nav_target_radial();
+    if ( net->course_deviation_deg < -1000.0 
+         || net->course_deviation_deg > 1000.0 )
+    {
+        // Sanity check ...
+        net->course_deviation_deg = 0.0;
+    }
     while ( net->course_deviation_deg >  180.0 ) {
         net->course_deviation_deg -= 360.0;
     }
@@ -182,7 +190,7 @@ void FGProps2NetGUI( FGNetGUI *net ) {
     if ( current_radiostack->get_navcom1()->get_nav_loc() ) {
         // is an ILS
         net->gs_deviation_deg
-            = current_radiostack->get_navcom1()->get_nav_gs_needle_deflection()
+            = current_radiostack->get_navcom1()->get_nav_gs_deflection()
             / 5.0;
     } else {
         // is an ILS
@@ -209,6 +217,7 @@ void FGProps2NetGUI( FGNetGUI *net ) {
 
     net->cur_time = htonl( net->cur_time );
     net->warp = htonl( net->warp );
+    net->ground_elev = htonl( net->ground_elev );
 
     htonf(net->tuned_freq);
     htonf(net->nav_radial);
@@ -243,6 +252,7 @@ void FGNetGUI2Props( FGNetGUI *net ) {
 
     net->cur_time = ntohl(net->cur_time);
     net->warp = ntohl(net->warp);
+    net->ground_elev = htonl( net->ground_elev );
 
     htonf(net->tuned_freq);
     net->in_range = htonl(net->in_range);
@@ -277,6 +287,7 @@ void FGNetGUI2Props( FGNetGUI *net ) {
        }
 
         globals->set_warp( net->warp );
+        globals->get_scenery()->set_cur_elev( net->ground_elev );
 
         // Approach
         fgSetDouble( "/radios/nav[0]/frequencies/selected-mhz",