]> git.mxchange.org Git - flightgear.git/blobdiff - src/Network/AV400.cxx
Fix crashes (activating the route-manager) with a default GPS.
[flightgear.git] / src / Network / AV400.cxx
index eead2455bbf8b11c8f70d189aa107f41c91f11e3..bed03b48bd04dc00e20c413b486c7325e23bf353 100644 (file)
 #  include "config.h"
 #endif
 
+#include <cstring>
+
 #include <simgear/debug/logstream.hxx>
 #include <simgear/math/sg_geodesy.hxx>
 #include <simgear/io/iochannel.hxx>
 #include <simgear/timing/sg_time.hxx>
 
-#include <FDM/flight.hxx>
 #include <Main/fg_props.hxx>
 #include <Main/globals.hxx>
 
@@ -80,12 +81,12 @@ bool FGAV400::gen_message() {
     double min;
 
     // create msg_z
-    sprintf( msg_z, "z%05.0f\r\n", cur_fdm_state->get_Altitude() );
+    sprintf( msg_z, "z%05.0f\r\n", fdm.get_Altitude() );
 
     // create msg_A
     sprintf( msg_A, "A");
 
-    double latd = cur_fdm_state->get_Latitude() * SGD_RADIANS_TO_DEGREES;
+    double latd = fdm.get_Latitude() * SGD_RADIANS_TO_DEGREES;
     if ( latd < 0.0 ) {
        latd = -latd;
        dir = 'S';
@@ -97,7 +98,7 @@ bool FGAV400::gen_message() {
     sprintf( msg_A, "A%c %02d %04.0f\r\n", dir, deg, min);
 
     // create msg_B
-    double lond = cur_fdm_state->get_Longitude() * SGD_RADIANS_TO_DEGREES;
+    double lond = fdm.get_Longitude() * SGD_RADIANS_TO_DEGREES;
     if ( lond < 0.0 ) {
        lond = -lond;
        dir = 'W';
@@ -262,7 +263,7 @@ bool FGAV400::parse_message() {
                lat *= -1;
            }
 
-           cur_fdm_state->set_Latitude( lat * SGD_DEGREES_TO_RADIANS );
+           fdm.set_Latitude( lat * SGD_DEGREES_TO_RADIANS );
            SG_LOG( SG_IO, SG_INFO, "  lat = " << lat );
 
            // lon val
@@ -291,17 +292,17 @@ bool FGAV400::parse_message() {
                lon *= -1;
            }
 
-           cur_fdm_state->set_Longitude( lon * SGD_DEGREES_TO_RADIANS );
+           fdm.set_Longitude( lon * SGD_DEGREES_TO_RADIANS );
            SG_LOG( SG_IO, SG_INFO, "  lon = " << lon );
 
 #if 0
            double sl_radius, lat_geoc;
-           sgGeodToGeoc( cur_fdm_state->get_Latitude(), 
-                         cur_fdm_state->get_Altitude(), 
+           sgGeodToGeoc( fdm.get_Latitude(), 
+                         fdm.get_Altitude(), 
                          &sl_radius, &lat_geoc );
-           cur_fdm_state->set_Geocentric_Position( lat_geoc, 
-                          cur_fdm_state->get_Longitude(), 
-                          sl_radius + cur_fdm_state->get_Altitude() );
+           fdm.set_Geocentric_Position( lat_geoc, 
+                          fdm.get_Longitude(), 
+                          sl_radius + fdm.get_Altitude() );
 #endif
 
            // speed
@@ -313,8 +314,8 @@ bool FGAV400::parse_message() {
            string speed_str = msg.substr(begin, end - begin);
            begin = end + 1;
            speed = atof( speed_str.c_str() );
-           cur_fdm_state->set_V_calibrated_kts( speed );
-           // cur_fdm_state->set_V_ground_speed( speed );
+           fdm.set_V_calibrated_kts( speed );
+           // fdm.set_V_ground_speed( speed );
            SG_LOG( SG_IO, SG_INFO, "  speed = " << speed );
 
            // heading
@@ -326,8 +327,8 @@ bool FGAV400::parse_message() {
            string hdg_str = msg.substr(begin, end - begin);
            begin = end + 1;
            heading = atof( hdg_str.c_str() );
-           cur_fdm_state->set_Euler_Angles( cur_fdm_state->get_Phi(), 
-                                            cur_fdm_state->get_Theta(), 
+           fdm.set_Euler_Angles( fdm.get_Phi(), 
+                                            fdm.get_Theta(), 
                                             heading * SGD_DEGREES_TO_RADIANS );
            SG_LOG( SG_IO, SG_INFO, "  heading = " << heading );
        } else if ( sentence == "PGRMZ" ) {
@@ -354,7 +355,7 @@ bool FGAV400::parse_message() {
                altitude *= SG_METER_TO_FEET;
            }
 
-           cur_fdm_state->set_Altitude( altitude );
+           fdm.set_Altitude( altitude );
     
            SG_LOG( SG_IO, SG_INFO, " altitude  = " << altitude );