]> git.mxchange.org Git - flightgear.git/blobdiff - utils/GPSsmooth/gps_main.cxx
Merge branch 'next' into durk-atc
[flightgear.git] / utils / GPSsmooth / gps_main.cxx
index 5be5d384f84f032c526b828ee37908cc97451ada..5dfc76c6729a242fb23ba392a0b29b7c0d3d4bf3 100644 (file)
@@ -2,13 +2,19 @@
 #  include <config.h>
 #endif
 
+#ifdef HAVE_WINDOWS_H
+#  include <windows.h>
+#else
+#  include <netinet/in.h>       // htonl() ntohl()
+#endif
+
 #include <iostream>
 #include <string>
 
-#include <plib/net.h>
 #include <plib/sg.h>
 
 #include <simgear/io/lowlevel.hxx> // endian tests
+#include <simgear/io/raw_socket.hxx>
 #include <simgear/timing/timestamp.hxx>
 
 #include <Network/net_ctrls.hxx>
@@ -23,7 +29,7 @@ using std::string;
 
 
 // Network channels
-static netSocket fdm_sock, ctrls_sock;
+static simgear::Socket fdm_sock, ctrls_sock;
 
 // gps data
 GPSTrack track;
@@ -276,7 +282,7 @@ static void gps2fg( const GPSPoint p, FGNetFDM *fdm, FGNetCtrls *ctrls )
 
 static void send_data( const GPSPoint p ) {
     int len;
-    int ctrlsize = sizeof( FGNetCtrls );
+//    int ctrlsize = sizeof( FGNetCtrls );
     int fdmsize = sizeof( FGNetFDM );
 
     // cout << "Running main loop" << endl;
@@ -369,7 +375,7 @@ int main( int argc, char **argv ) {
 
     // Setup up outgoing network connections
 
-    netInit( &argc,argv ); // We must call this before any other net stuff
+    simgear::Socket::initSockets(); // We must call this before any other net stuff
 
     if ( ! fdm_sock.open( false ) ) {  // open a UDP socket
         cout << "error opening fdm output socket" << endl;
@@ -465,13 +471,13 @@ int main( int argc, char **argv ) {
 
         current_time_stamp.stamp();
         /* Convert to ms */
-        double elapsed_us = current_time_stamp - last_time_stamp;
+        double elapsed_us = (current_time_stamp - last_time_stamp).toUSecs();
         if ( elapsed_us < (frame_us - 2000) ) {
             double requested_us = (frame_us - elapsed_us) - 2000 ;
             ulMilliSecondSleep ( (int)(requested_us / 1000.0) ) ;
         }
         current_time_stamp.stamp();
-        while ( current_time_stamp - last_time_stamp < frame_us ) {
+        while ( (current_time_stamp - last_time_stamp).toUSecs() < frame_us ) {
             current_time_stamp.stamp();
         }