]> git.mxchange.org Git - flightgear.git/blobdiff - src/Network/AV400Sim.cxx
Fix crashes (activating the route-manager) with a default GPS.
[flightgear.git] / src / Network / AV400Sim.cxx
index 54d3713ad7ce9ad6bfb51bef3847ebe6d7aaeb3f..894dcbef8e1cd1a9401547fd3b42a53069207ebe 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 <FDM/flightProperties.hxx>
 #include <Main/fg_props.hxx>
 #include <Main/globals.hxx>
 
 #include "AV400Sim.hxx"
 
 FGAV400Sim::FGAV400Sim() {
+  fdm = new FlightProperties;
 }
 
 FGAV400Sim::~FGAV400Sim() {
+  delete fdm;
 }
 
 
@@ -60,7 +64,7 @@ bool FGAV400Sim::gen_message() {
     double min;
 
     // create msg_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';
@@ -72,7 +76,7 @@ bool FGAV400Sim::gen_message() {
     sprintf( msg_a, "a%c %03d %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';
@@ -84,7 +88,7 @@ bool FGAV400Sim::gen_message() {
     sprintf( msg_b, "b%c %03d %04.0f\r\n", dir, deg, min);
 
     // create msg_c
-    double alt = cur_fdm_state->get_Altitude();
+    double alt = fdm->get_Altitude();
     if ( alt > 99999.0 ) { alt = 99999.0; }
     sprintf( msg_c, "c%05.0f\r\n", alt );
 
@@ -206,7 +210,7 @@ bool FGAV400Sim::parse_message() {
            }
            fgSetDouble("/instrumentation/gps/cdi-deflection",
                        (double)pos / 8.0);
-           fgSetBool("/instrumentation/nav[0]/has-gs", false);
+           fgSetBool("/instrumentation/gps/has-gs", false);
        }
     } else if ( ident == "k" ) {
        string ind = msg.substr(1,1);