]> git.mxchange.org Git - flightgear.git/blobdiff - src/MultiPlayer/multiplayrxmgr.cxx
Finish what was committed in a broken state yesterday.
[flightgear.git] / src / MultiPlayer / multiplayrxmgr.cxx
index 8939d5831990f447fe976619eeb95645e7700840..474a09faf14371c7effb6f9ecbf975d05751452f 100644 (file)
 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 //
 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef FG_MPLAYER_AS
 
 /******************************************************************
 * $Id$
@@ -51,7 +56,7 @@
 ******************************************************************/
 
 #include <sys/types.h>
-#ifndef _MSC_VER
+#if !(defined(_MSC_VER) || defined(__MINGW32__))
 # include <sys/socket.h>
 # include <netinet/in.h>
 # include <arpa/inet.h>
@@ -135,7 +140,7 @@ bool FGMultiplayRxMgr::init(void) {
         mDataRxSocket = new netSocket();
         if (!mDataRxSocket->open(false)) {
             // Failed to open rx socket
-            cerr << "FGMultiplayRxMgr::Open - Failed to create data receive socket" << endl;
+            SG_LOG( SG_NETWORK, SG_ALERT, "FGMultiplayRxMgr::Open - Failed to create data receive socket" );
             bSuccess = false;
         } else {
 
@@ -145,7 +150,7 @@ bool FGMultiplayRxMgr::init(void) {
             if (mDataRxSocket->bind(m_sRxAddress.c_str(), m_iRxPort) != 0) {
                 perror("bind");
                 // Failed to bind
-                cerr << "FGMultiplayRxMgr::Open - Failed to bind receive socket" << endl;
+                SG_LOG( SG_NETWORK, SG_ALERT, "FGMultiplayRxMgr::Open - Failed to bind receive socket" );
                 bSuccess = false;
             }
 
@@ -155,7 +160,7 @@ bool FGMultiplayRxMgr::init(void) {
         m_bInitialised = bSuccess;
 
     } else {
-        cerr << "FGMultiplayRxMgr::OpenRx - Receiver open requested when receiver is already open" << endl;
+        SG_LOG( SG_NETWORK, SG_ALERT, "FGMultiplayRxMgr::OpenRx - Receiver open requested when receiver is already open" );
         bSuccess = false;
     }
 
@@ -228,7 +233,7 @@ void FGMultiplayRxMgr::ProcessData(void) {
 
             // Data received
             if (iBytes > 0) {
-                if (iBytes >= sizeof(MsgHdr)) {
+                if (iBytes >= (int)sizeof(MsgHdr)) {
 
                     // Read header
                     MsgHdr = (T_MsgHdr *)sMsg;
@@ -238,7 +243,7 @@ void FGMultiplayRxMgr::ProcessData(void) {
                     sCallsign = MsgHdr->sCallsign;
 
                     // Process the player data unless we generated it
-                    if (m_sCallsign != string(MsgHdr->sCallsign)) {
+                    if (m_sCallsign != MsgHdr->sCallsign) {
 
 
                         // Process messages
@@ -278,7 +283,7 @@ void FGMultiplayRxMgr::ProcessData(void) {
                                             if (m_Player[iPlayerCnt] == NULL) {
                                                 SG_LOG( SG_NETWORK, SG_INFO, "FGMultiplayRxMgr::ProcessRxData - Add new player. IP: " << sIpAddress << ", Call: " <<  sCallsign << ", model: " << sModelName );
                                                 m_Player[iPlayerCnt] = new MPPlayer;
-                                                m_Player[iPlayerCnt]->Open(string(sIpAddress), iPort, string(sCallsign), string(sModelName), false);
+                                                m_Player[iPlayerCnt]->Open(sIpAddress, iPort, sCallsign, sModelName, false);
                                                 m_Player[iPlayerCnt]->SetPosition(PosMsg->PlayerPos);
                                                 bActivePlayer = true;
                                             }
@@ -288,18 +293,18 @@ void FGMultiplayRxMgr::ProcessData(void) {
                                         // Check if the player was added
                                         if (!bActivePlayer) {
                                             if (iPlayerCnt == MAX_PLAYERS) {
-                                                cerr << "FGMultiplayRxMgr::MP_ProcessData - Unable to add new player (" << sCallsign << "). Too many players." << endl;
+                                                SG_LOG( SG_NETWORK, SG_ALERT, "FGMultiplayRxMgr::MP_ProcessData - Unable to add new player (" << sCallsign << "). Too many players." );
                                             }
                                         }
                                     }
 
                                 } else {
-                                    cerr << "FGMultiplayRxMgr::MP_ProcessData - Position message received with insufficient data" << endl;
+                                    SG_LOG( SG_NETWORK, SG_ALERT, "FGMultiplayRxMgr::MP_ProcessData - Position message received with insufficient data" );
                                 }
                                 break;
 
                             default:
-                                cerr << "FGMultiplayRxMgr::MP_ProcessData - Unknown message Id received: " << MsgHdr->MsgId << endl;
+                                SG_LOG( SG_NETWORK, SG_ALERT, "FGMultiplayRxMgr::MP_ProcessData - Unknown message Id received: " << MsgHdr->MsgId );
                                 break;
 
 
@@ -353,4 +358,5 @@ void FGMultiplayRxMgr::Update(void) {
 
 }
 
+#endif // FG_MPLAYER_AS