]> git.mxchange.org Git - flightgear.git/blobdiff - src/Network/native_fdm.cxx
Fix a potential timing glitch.
[flightgear.git] / src / Network / native_fdm.cxx
index 8a8d743a9dc644fd9ac45409088084f20e70026e..70c98c6bf7690764a89d608634930a2633526f54 100644 (file)
@@ -95,7 +95,12 @@ bool FGNativeFDM::open() {
 
     set_enabled( true );
 
+    // initialize time stamp to something reasonably current
+    last_time.stamp();
+
+    // Is this really needed here ????
     cur_fdm_state->_set_Sea_level_radius( SG_EQUATORIAL_RADIUS_FT );
+
     return true;
 }
 
@@ -401,10 +406,23 @@ bool FGNativeFDM::process() {
                FGNetFDM2Props( &buf );
            }
        } else {
-           while ( io->read( (char *)(& buf), length ) == length ) {
-               SG_LOG( SG_IO, SG_DEBUG, "Success reading data." );
-               FGNetFDM2Props( &buf );
+            // double dt = 1000000.0 / 30.0;
+            // SGTimeStamp current; current.stamp();
+            int result;
+            result = io->read( (char *)(& buf), length );
+            if ( result == length ) {
+                SG_LOG( SG_IO, SG_DEBUG, "  Success reading data." );
+                FGNetFDM2Props( &buf );
+            }
+           while ( result == length /* || current - last_time < dt */ ) {
+                result = io->read( (char *)(& buf), length );
+                if ( result == length ) {
+                    SG_LOG( SG_IO, SG_DEBUG, "  Success reading data." );
+                    FGNetFDM2Props( &buf );
+                }
+                // current.stamp();
            }
+            // last_time = current;
        }
     }