]> git.mxchange.org Git - flightgear.git/blobdiff - src/MultiPlayer/multiplayrxmgr.cxx
Moved random ground cover object management code (userdata.[ch]xx) over
[flightgear.git] / src / MultiPlayer / multiplayrxmgr.cxx
index 61ca69514c5da91c911deed778b52d6030d028e1..33f5f1aa655b8d5bee3c1ce4c9564cd7e660dfd1 100644 (file)
 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 //
 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef FG_MPLAYER_AS
 
 /******************************************************************
 * $Id$
 ******************************************************************/
 
 #include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
+#if !(defined(_MSC_VER) || defined(__MINGW32__))
+# include <sys/socket.h>
+# include <netinet/in.h>
+# include <arpa/inet.h>
+#endif
 #include <plib/netSocket.h>
 #include <stdlib.h>
 
@@ -133,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 {
 
@@ -143,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;
             }
 
@@ -153,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;
     }
 
@@ -286,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;
 
 
@@ -330,16 +337,18 @@ void FGMultiplayRxMgr::ProcessData(void) {
 ******************************************************************/
 void FGMultiplayRxMgr::Update(void) {
 
-    int iPlayerDataState;
+    MPPlayer::TPlayerDataState ePlayerDataState;
     int iPlayerId;
 
     for (iPlayerId = 0; iPlayerId < MAX_PLAYERS; iPlayerId++) {
         if (m_Player[iPlayerId] != NULL) {
-            iPlayerDataState = m_Player[iPlayerId]->Draw();
+            ePlayerDataState = m_Player[iPlayerId]->Draw();
 
             // If the player has not received an update for some
             // time then assume that the player has quit.
-            if (iPlayerDataState == PLAYER_DATA_EXPIRED) {
+            if (ePlayerDataState == MPPlayer::PLAYER_DATA_EXPIRED) {
+                SG_LOG( SG_NETWORK, SG_BULK, "FGMultiplayRxMgr::Update - Deleting player from game. Callsign: "
+                        << m_Player[iPlayerId]->Callsign() );
                 delete m_Player[iPlayerId];
                 m_Player[iPlayerId] = NULL;
             }
@@ -349,4 +358,5 @@ void FGMultiplayRxMgr::Update(void) {
 
 }
 
+#endif // FG_MPLAYER_AS