]> git.mxchange.org Git - flightgear.git/blobdiff - src/Network/native_gui.cxx
(Re)allow duplicate names for A/P stages
[flightgear.git] / src / Network / native_gui.cxx
index b9d3ce4896f7a8895d6c150b89043d69406ba2a9..6ddb8349612fbd0d6929a2fa5cd85bbc05781e73 100644 (file)
@@ -16,7 +16,7 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 //
 // $Id$
 
 #include <simgear/io/iochannel.hxx>
 #include <simgear/timing/sg_time.hxx>
 
-#include <FDM/flight.hxx>
 #include <Time/tmp.hxx>
 #include <Main/fg_props.hxx>
 #include <Main/globals.hxx>
 #include <Scenery/scenery.hxx>
+#include <FDM/flightProperties.hxx>
 
 #include "native_gui.hxx"
 
 // FreeBSD works better with this included last ... (?)
-#if defined(WIN32) && !defined(__CYGWIN__)
+#if defined( _MSC_VER )
 #  include <windows.h>
+#elif defined( __MINGW32__ )
+#  include <winsock2.h>
 #else
 #  include <netinet/in.h>      // htonl() ntohl()
 #endif
@@ -114,7 +116,7 @@ bool FGNativeGUI::open() {
 
     set_enabled( true );
 
-    cur_fdm_state->_set_Sea_level_radius( SG_EQUATORIAL_RADIUS_FT );
+    fgSetDouble("/position/sea-level-radius-ft", SG_EQUATORIAL_RADIUS_FT);
     return true;
 }
 
@@ -138,20 +140,22 @@ void FGProps2NetGUI( FGNetGUI *net ) {
        = fgGetNode("/instrumentation/nav/gs-needle-deflection", true);
     unsigned int i;
 
+    static FlightProperties* fdm_state = new FlightProperties;
+
     // Version sanity checking
     net->version = FG_NET_GUI_VERSION;
 
     // Aero parameters
-    net->longitude = cur_fdm_state->get_Longitude();
-    net->latitude = cur_fdm_state->get_Latitude();
-    net->altitude = cur_fdm_state->get_Altitude() * SG_FEET_TO_METER;
-    net->phi = cur_fdm_state->get_Phi();
-    net->theta = cur_fdm_state->get_Theta();
-    net->psi = cur_fdm_state->get_Psi();
+    net->longitude = fdm_state->get_Longitude();
+    net->latitude = fdm_state->get_Latitude();
+    net->altitude = fdm_state->get_Altitude() * SG_FEET_TO_METER;
+    net->phi = fdm_state->get_Phi();
+    net->theta = fdm_state->get_Theta();
+    net->psi = fdm_state->get_Psi();
 
     // Velocities
-    net->vcas = cur_fdm_state->get_V_calibrated_kts();
-    net->climb_rate = cur_fdm_state->get_Climb_Rate();
+    net->vcas = fdm_state->get_V_calibrated_kts();
+    net->climb_rate = fdm_state->get_Climb_Rate();
 
     // Consumables
     net->num_tanks = FGNetGUI::FG_MAX_TANKS;
@@ -163,7 +167,7 @@ void FGProps2NetGUI( FGNetGUI *net ) {
     // 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();
+    net->ground_elev = fdm_state->get_Runway_altitude_m();
 
     // Approach
     net->tuned_freq = nav_freq->getDoubleValue();
@@ -279,19 +283,22 @@ void FGNetGUI2Props( FGNetGUI *net ) {
 #endif
 
     if ( net->version == FG_NET_GUI_VERSION ) {
+        FlightProperties fdm_state;
+        
         // cout << "pos = " << net->longitude << " " << net->latitude << endl;
-        // cout << "sea level rad = " << cur_fdm_state->get_Sea_level_radius()
+        // cout << "sea level rad = " << fdm_state->get_Sea_level_radius()
        //      << endl;
-        cur_fdm_state->_updateGeodeticPosition( net->latitude,
-                                                net->longitude,
-                                                net->altitude
-                                                  * SG_METER_TO_FEET );
-        cur_fdm_state->_set_Euler_Angles( net->phi,
+  
+        fdm_state.set_Latitude(net->latitude);
+        fdm_state.set_Longitude(net->longitude);
+        fdm_state.set_Altitude(net->altitude * SG_METER_TO_FEET);
+
+        fdm_state.set_Euler_Angles( net->phi,
                                           net->theta,
                                           net->psi );
 
-        cur_fdm_state->_set_V_calibrated_kts( net->vcas );
-        cur_fdm_state->_set_Climb_Rate( net->climb_rate );
+        fdm_state.set_V_calibrated_kts( net->vcas );
+        fdm_state.set_Climb_Rate( net->climb_rate );
 
        for (i = 0; i < net->num_tanks; ++i ) {
            SGPropertyNode * node
@@ -304,13 +311,12 @@ void FGNetGUI2Props( FGNetGUI *net ) {
        }
 
         globals->set_warp( net->warp );
-        globals->get_scenery()->set_cur_elev( net->ground_elev );
 
         // Approach
         fgSetDouble( "/instrumentation/nav[0]/frequencies/selected-mhz",
                      net->tuned_freq );
         fgSetBool( "/instrumentation/nav[0]/in-range", net->in_range );
-        fgSetDouble( "/instrumentation/dme/distance-nm", net->dist_nm );
+        fgSetDouble( "/instrumentation/dme/indicated-distance-nm", net->dist_nm );
         fgSetDouble( "/instrumentation/nav[0]/heading-needle-deflection",
                      net->course_deviation_deg );
         fgSetDouble( "/instrumentation/nav[0]/gs-needle-deflection",
@@ -332,7 +338,7 @@ bool FGNativeGUI::process() {
     int length = sizeof(buf);
 
     if ( get_direction() == SG_IO_OUT ) {
-       // cout << "size of cur_fdm_state = " << length << endl;
+       // cout << "size of fdm_state = " << length << endl;
        FGProps2NetGUI( &buf );
        if ( ! io->write( (char *)(& buf), length ) ) {
            SG_LOG( SG_IO, SG_ALERT, "Error writing data." );