]> git.mxchange.org Git - flightgear.git/blobdiff - src/Network/native_gui.cxx
Moved some of the low level scene graph construction code over to simgear.
[flightgear.git] / src / Network / native_gui.cxx
index 9471cc588d2dbf89102635329ad3760d84070851..e2b2391cbb5fde0d1bb27a9eab66541464537ea3 100644 (file)
@@ -46,6 +46,9 @@
 #endif
 
 
+// #define FG_USE_NETWORK_BYTE_ORDER
+#if defined( FG_USE_NETWORK_BYTE_ORDER )
+
 // The function htond is defined this way due to the way some
 // processors and OSes treat floating point values.  Some will raise
 // an exception whenever a "bad" floating point value is loaded into a
@@ -84,6 +87,7 @@ static void htonf (float &x)
         return;
     }
 }
+#endif
 
 
 FGNativeGUI::FGNativeGUI() {
@@ -145,7 +149,21 @@ void FGProps2NetGUI( FGNetGUI *net ) {
     net->warp = globals->get_warp();
 
     // Approach
-    net->dist_nm = current_radiostack->get_dme()->get_dist();
+    net->tuned_freq = current_radiostack->get_navcom1()->get_nav_freq();
+    net->nav_radial = current_radiostack->get_navcom1()->get_nav_radial();
+    net->in_range = current_radiostack->get_navcom1()->get_nav_inrange();
+
+    if ( current_radiostack->get_navcom1()->get_nav_loc() ) {
+        // is an ILS
+        net->dist_nm
+            = current_radiostack->get_navcom1()->get_nav_gs_dist_signed()
+              * SG_METER_TO_NM;
+    } else {
+        // is a VOR
+        net->dist_nm = current_radiostack->get_navcom1()->get_nav_loc_dist()
+            * SG_METER_TO_NM;
+    }
+
     net->course_deviation_deg
         = current_radiostack->get_navcom1()->get_nav_heading()
         - current_radiostack->get_navcom1()->get_nav_radial();
@@ -160,10 +178,18 @@ void FGProps2NetGUI( FGNetGUI *net ) {
             = ( net->course_deviation_deg<0.0
                 ? -net->course_deviation_deg - 180.0
                 : -net->course_deviation_deg + 180.0 );
-    net->gs_deviation_deg
-        = current_radiostack->get_navcom1()->get_nav_gs_needle_deflection()
-        / 5.0;
 
+    if ( current_radiostack->get_navcom1()->get_nav_loc() ) {
+        // is an ILS
+        net->gs_deviation_deg
+            = current_radiostack->get_navcom1()->get_nav_gs_needle_deflection()
+            / 5.0;
+    } else {
+        // is an ILS
+        net->gs_deviation_deg = -9999.0;
+    }
+
+#if defined( FG_USE_NETWORK_BYTE_ORDER )
     // Convert the net buffer to network format
     net->version = htonl(net->version);
 
@@ -184,15 +210,20 @@ void FGProps2NetGUI( FGNetGUI *net ) {
     net->cur_time = htonl( net->cur_time );
     net->warp = htonl( net->warp );
 
+    htonf(net->tuned_freq);
+    htonf(net->nav_radial);
+    net->in_range = htonl(net->in_range);
     htonf(net->dist_nm);
     htonf(net->course_deviation_deg);
     htonf(net->gs_deviation_deg);
+#endif
 }
 
 
 void FGNetGUI2Props( FGNetGUI *net ) {
     int i;
 
+#if defined( FG_USE_NETWORK_BYTE_ORDER )
     // Convert to the net buffer from network format
     net->version = ntohl(net->version);
 
@@ -213,9 +244,12 @@ void FGNetGUI2Props( FGNetGUI *net ) {
     net->cur_time = ntohl(net->cur_time);
     net->warp = ntohl(net->warp);
 
+    htonf(net->tuned_freq);
+    net->in_range = htonl(net->in_range);
     htonf(net->dist_nm);
     htonf(net->course_deviation_deg);
     htonf(net->gs_deviation_deg);
+#endif
 
     if ( net->version == FG_NET_GUI_VERSION ) {
         // cout << "pos = " << net->longitude << " " << net->latitude << endl;
@@ -245,6 +279,9 @@ void FGNetGUI2Props( FGNetGUI *net ) {
         globals->set_warp( net->warp );
 
         // Approach
+        fgSetDouble( "/radios/nav[0]/frequencies/selected-mhz",
+                     net->tuned_freq );
+        fgSetBool( "/radios/nav[0]/in-range", net->in_range );
         fgSetDouble( "/radios/dme/distance-nm", net->dist_nm );
         fgSetDouble( "/radios/nav[0]/heading-needle-deflection",
                      net->course_deviation_deg );