]> git.mxchange.org Git - flightgear.git/blobdiff - src/Network/native_fdm.cxx
Update Mac configure script for new ALUT scheme; support --with-alut-framework.
[flightgear.git] / src / Network / native_fdm.cxx
index 033d72b0c93535d7e857637cb0a2465b89d6c4e6..4fa6275cedd7937179b35feaf855ae69576d0841 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 "native_fdm.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
@@ -120,7 +122,7 @@ bool FGNativeFDM::open() {
 
 
 void FGProps2NetFDM( FGNetFDM *net, bool net_byte_order ) {
-    int i;
+    unsigned int i;
 
     // Version sanity checking
     net->version = FG_NET_FDM_VERSION;
@@ -171,6 +173,7 @@ void FGProps2NetFDM( FGNetFDM *net, bool net_byte_order ) {
         }
         net->rpm[i] = node->getDoubleValue( "rpm" );
         net->fuel_flow[i] = node->getDoubleValue( "fuel-flow-gph" );
+        net->fuel_px[i] = node->getDoubleValue( "fuel-px-psi" );
         net->egt[i] = node->getDoubleValue( "egt-degf" );
         // cout << "egt = " << aero->EGT << endl;
         net->cht[i] = node->getDoubleValue( "cht-degf" );
@@ -213,13 +216,13 @@ void FGProps2NetFDM( FGNetFDM *net, bool net_byte_order ) {
     net->left_aileron = node->getDoubleValue( "left-aileron-pos-norm" );
     net->right_aileron = node->getDoubleValue( "right-aileron-pos-norm" );
     net->rudder = node->getDoubleValue( "rudder-pos-norm" );
-    net->rudder = node->getDoubleValue( "nose-wheel-pos-norm" );
+    net->nose_wheel = node->getDoubleValue( "nose-wheel-pos-norm" );
     net->speedbrake = node->getDoubleValue( "speedbrake-pos-norm" );
     net->spoilers = node->getDoubleValue( "spoilers-pos-norm" );
 
     if ( net_byte_order ) {
         // Convert the net buffer to network format
-        net->version = htons(net->version);
+        net->version = htonl(net->version);
 
         htond(net->longitude);
         htond(net->latitude);
@@ -251,8 +254,10 @@ void FGProps2NetFDM( FGNetFDM *net, bool net_byte_order ) {
         htonf(net->slip_deg);
 
         for ( i = 0; i < net->num_engines; ++i ) {
+            net->eng_state[i] = htonl(net->eng_state[i]);
             htonf(net->rpm[i]);
             htonf(net->fuel_flow[i]);
+            htonf(net->fuel_px[i]);
             htonf(net->egt[i]);
             htonf(net->cht[i]);
             htonf(net->mp_osi[i]);
@@ -260,16 +265,20 @@ void FGProps2NetFDM( FGNetFDM *net, bool net_byte_order ) {
             htonf(net->oil_temp[i]);
             htonf(net->oil_px[i]);
         }
+        net->num_engines = htonl(net->num_engines);
 
         for ( i = 0; i < net->num_tanks; ++i ) {
             htonf(net->fuel_quantity[i]);
         }
+        net->num_tanks = htonl(net->num_tanks);
 
         for ( i = 0; i < net->num_wheels; ++i ) {
+            net->wow[i] = htonl(net->wow[i]);
             htonf(net->gear_pos[i]);
             htonf(net->gear_steer[i]);
             htonf(net->gear_compression[i]);
         }
+        net->num_wheels = htonl(net->num_wheels);
 
         net->cur_time = htonl( net->cur_time );
         net->warp = htonl( net->warp );
@@ -290,11 +299,11 @@ void FGProps2NetFDM( FGNetFDM *net, bool net_byte_order ) {
 
 
 void FGNetFDM2Props( FGNetFDM *net, bool net_byte_order ) {
-    int i;
+    unsigned int i;
 
     if ( net_byte_order ) {
         // Convert to the net buffer from network format
-        net->version = ntohs(net->version);
+        net->version = ntohl(net->version);
 
         htond(net->longitude);
         htond(net->latitude);
@@ -325,9 +334,12 @@ void FGNetFDM2Props( FGNetFDM *net, bool net_byte_order ) {
         htonf(net->stall_warning);
         htonf(net->slip_deg);
 
+        net->num_engines = htonl(net->num_engines);
         for ( i = 0; i < net->num_engines; ++i ) {
+            net->eng_state[i] = htonl(net->eng_state[i]);
             htonf(net->rpm[i]);
             htonf(net->fuel_flow[i]);
+            htonf(net->fuel_px[i]);
             htonf(net->egt[i]);
             htonf(net->cht[i]);
             htonf(net->mp_osi[i]);
@@ -336,11 +348,14 @@ void FGNetFDM2Props( FGNetFDM *net, bool net_byte_order ) {
             htonf(net->oil_px[i]);
         }
 
+        net->num_tanks = htonl(net->num_tanks);
         for ( i = 0; i < net->num_tanks; ++i ) {
             htonf(net->fuel_quantity[i]);
         }
 
+        net->num_wheels = htonl(net->num_wheels);
         for ( i = 0; i < net->num_wheels; ++i ) {
+            net->wow[i] = htonl(net->wow[i]);
             htonf(net->gear_pos[i]);
             htonf(net->gear_steer[i]);
             htonf(net->gear_compression[i]);
@@ -373,8 +388,8 @@ void FGNetFDM2Props( FGNetFDM *net, bool net_byte_order ) {
        if ( net->agl > -9000 ) {
            cur_fdm_state->_set_Altitude_AGL( net->agl * SG_METER_TO_FEET );
        } else {
-           double agl_m
-             = net->altitude - globals->get_scenery()->get_cur_elev();
+           double agl_m = net->altitude
+              - cur_fdm_state->get_Runway_altitude_m();
            cur_fdm_state->_set_Altitude_AGL( agl_m * SG_METER_TO_FEET );
        }
         cur_fdm_state->_set_Euler_Angles( net->phi,
@@ -423,6 +438,7 @@ void FGNetFDM2Props( FGNetFDM *net, bool net_byte_order ) {
 
            node->setDoubleValue( "rpm", net->rpm[i] );
            node->setDoubleValue( "fuel-flow-gph", net->fuel_flow[i] );
+           node->setDoubleValue( "fuel-px-psi", net->fuel_px[i] );
            node->setDoubleValue( "egt-degf", net->egt[i] );
            node->setDoubleValue( "cht-degf", net->cht[i] );
            node->setDoubleValue( "mp-osi", net->mp_osi[i] );