]> git.mxchange.org Git - flightgear.git/commitdiff
Small patch that prevents displaying a "local echo" of one's own aircraft
authordurk <durk>
Sat, 19 Apr 2008 10:42:06 +0000 (10:42 +0000)
committerdurk <durk>
Sat, 19 Apr 2008 10:42:06 +0000 (10:42 +0000)
under some circumstances. The history of this patch is somewhat unclear,
but was brought to my attention by Martin Spott, while preparing for the
Lelystad FSWeekend show. See also my posting on FlightGear devel, on
November 22, 2007 "(Multiplayer Local Echo Patch)", but wasn't committed
then because I/we assumed that had been superseded by other code
modifications. The local echo problem still persists, however, albeit
under specific circumstances. The current patch reportedly prevents this
from happening.

src/MultiPlayer/multiplaymgr.cxx

index a31325a55ca4e452e45c6c7dc2159c60836b6131..7a0e71847af5c970bf3892aafdf97190c841e0ca 100644 (file)
@@ -233,21 +233,29 @@ FGMultiplayMgr::init (void)
   //  Set members from property values
   //////////////////////////////////////////////////
   short rxPort = fgGetInt("/sim/multiplay/rxport");
-  if (rxPort <= 0)
-    rxPort = 5000;
-  mCallsign = fgGetString("/sim/multiplay/callsign");
-  if (mCallsign.empty())
-    // FIXME: use getpwuid
-    mCallsign = "JohnDoe"; 
   string rxAddress = fgGetString("/sim/multiplay/rxhost");
-  if (rxAddress.empty())
-    rxAddress = "127.0.0.1";
   short txPort = fgGetInt("/sim/multiplay/txport");
   string txAddress = fgGetString("/sim/multiplay/txhost");
+  mCallsign = fgGetString("/sim/multiplay/callsign");
   if (txPort > 0 && !txAddress.empty()) {
-    mHaveServer = true;
     mServer.set(txAddress.c_str(), txPort);
+    if (strncmp (mServer.getHost(), "0.0.0.0", 8) == 0) {
+      mHaveServer = false;
+      SG_LOG(SG_NETWORK, SG_ALERT,
+        "FGMultiplayMgr - could not resolve '"
+        << txAddress << "', Multiplayermode disabled");
+    } else {
+      mHaveServer = true;
+    }
+    rxPort = txPort;
+  }
+  if (rxPort <= 0) {
+    SG_LOG(SG_NETWORK, SG_ALERT,
+      "FGMultiplayMgr - No receiver port, Multiplayermode disabled");
+    return (false);
   }
+  if (mCallsign.empty())
+    mCallsign = "JohnDoe"; // FIXME: use getpwuid
   SG_LOG(SG_NETWORK,SG_INFO,"FGMultiplayMgr::init-txaddress= "<<txAddress);
   SG_LOG(SG_NETWORK,SG_INFO,"FGMultiplayMgr::init-txport= "<<txPort );
   SG_LOG(SG_NETWORK,SG_INFO,"FGMultiplayMgr::init-rxaddress="<<rxAddress );
@@ -301,13 +309,10 @@ FGMultiplayMgr::Close (void)
 void
 FGMultiplayMgr::SendMyPosition(const FGExternalMotionData& motionInfo)
 {
-  if ((! mInitialised) || (! mHaveServer)) {
-    if (! mInitialised)
-      SG_LOG( SG_NETWORK, SG_ALERT,
-              "FGMultiplayMgr::SendMyPosition - not initialised" );
-    if (! mHaveServer)
-      SG_LOG( SG_NETWORK, SG_ALERT,
-              "FGMultiplayMgr::SendMyPosition - no server" );
+  if ((! mInitialised) || (! mHaveServer))
+        return;
+  if (! mHaveServer) {
+    SG_LOG( SG_NETWORK, SG_ALERT, "FGMultiplayMgr::SendMyPosition - no server");
     return;
   }
 
@@ -762,8 +767,8 @@ FGMultiplayMgr::ProcessChatMsg(const char *Msg, netAddress& SenderAddress)
   MsgBuf[MsgHdr->MsgLen - sizeof(T_MsgHdr) - 1] = '\0';
   
   T_ChatMsg* ChatMsg = (T_ChatMsg *)(Msg + sizeof(T_MsgHdr));
-  SG_LOG ( SG_NETWORK, SG_ALERT, "Chat [" << MsgHdr->Callsign << "]"
-           << " " << MsgBuf << endl);
+  SG_LOG (SG_NETWORK, SG_ALERT, "Chat [" << MsgHdr->Callsign << "]"
+           << " " << MsgBuf);
 
   delete [] MsgBuf;
 } // FGMultiplayMgr::ProcessChatMsg ()