Hello ,

I resubmit my patch .

This reason of this patch is to have a better behavior of flightgear when you 
fly 
in multi screen configuration with multi-player mode .

When you setup  a multi-monitor configuration you have  multi instances
of flightgear ( see http://www.inkdrop.net/dave/multimon.pdf ) .

On the second screen the slave instance , i don't see multiplayer .
    A small solution to solve the problem was to resend the packet coming from
    the multiplayer server to the other instance of flightgear .

Who can push this patch in the cvs ?  

-- 
     ____________________________________________________________
    / Erwan MAS                                                 /\
   | mailto:[EMAIL PROTECTED]                                   |_/
___|________________________________________________________   |
\___________________________________________________________\__/
Index: src/Main/options.cxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/Main/options.cxx,v
retrieving revision 1.115
diff -u -r1.115 options.cxx
--- src/Main/options.cxx        14 Aug 2008 18:13:41 -0000      1.115
+++ src/Main/options.cxx        12 Oct 2008 15:02:30 -0000
@@ -232,8 +232,10 @@
     fgSetString("/sim/multiplay/callsign", "callsign");
     fgSetString("/sim/multiplay/rxhost", "0");
     fgSetString("/sim/multiplay/txhost", "0");
+    fgSetString("/sim/multiplay/repeathost", "0");
     fgSetInt("/sim/multiplay/rxport", 0);
     fgSetInt("/sim/multiplay/txport", 0);
+    fgSetInt("/sim/multiplay/repeatport", 0);
 }
 
 static bool
Index: src/MultiPlayer/multiplaymgr.cxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/MultiPlayer/multiplaymgr.cxx,v
retrieving revision 1.25
diff -u -r1.25 multiplaymgr.cxx
--- src/MultiPlayer/multiplaymgr.cxx    9 Oct 2008 16:13:50 -0000       1.25
+++ src/MultiPlayer/multiplaymgr.cxx    12 Oct 2008 15:02:30 -0000
@@ -205,6 +205,7 @@
   mSocket        = 0;
   mInitialised   = false;
   mHaveServer    = false;
+  repeatHaveServer = false ;
 } // FGMultiplayMgr::FGMultiplayMgr()
 //////////////////////////////////////////////////////////////////////
 
@@ -260,6 +261,12 @@
       "FGMultiplayMgr - No receiver port, Multiplayermode disabled");
     return (false);
   }
+  short repeatPort = fgGetInt("/sim/multiplay/repeatport");
+  string repeatAddress = fgGetString("/sim/multiplay/repeathost");
+  if (repeatPort > 0 && !repeatAddress.empty()) {
+    repeatHaveServer = true;
+    repeatServer.set(repeatAddress.c_str(), repeatPort);
+  }
   if (mCallsign.empty())
     mCallsign = "JohnDoe"; // FIXME: use getpwuid
   SG_LOG(SG_NETWORK,SG_INFO,"FGMultiplayMgr::init-txaddress= "<<txAddress);
@@ -267,6 +274,8 @@
   SG_LOG(SG_NETWORK,SG_INFO,"FGMultiplayMgr::init-rxaddress="<<rxAddress );
   SG_LOG(SG_NETWORK,SG_INFO,"FGMultiplayMgr::init-rxport= "<<rxPort);
   SG_LOG(SG_NETWORK,SG_INFO,"FGMultiplayMgr::init-callsign= "<<mCallsign);
+  SG_LOG(SG_NETWORK,SG_INFO,"FGMultiplayMgr::init-repeataddress= 
"<<repeatAddress);
+  SG_LOG(SG_NETWORK,SG_INFO,"FGMultiplayMgr::init-repeatport= "<<repeatPort );
   Close(); // Should Init be called twice, close Socket first
            // A memory leak was reported here by valgrind
   mSocket = new netSocket();
@@ -526,6 +535,7 @@
   int bytes;
   do {
     char Msg[MAX_PACKET_SIZE];
+    char MsgOriginal[MAX_PACKET_SIZE];
     //////////////////////////////////////////////////
     //  Although the recv call asks for 
     //  MAX_PACKET_SIZE of data, the number of bytes
@@ -550,6 +560,9 @@
     //////////////////////////////////////////////////
     //  Read header
     //////////////////////////////////////////////////
+    if (repeatHaveServer ) {
+      memcpy(MsgOriginal,Msg,MAX_PACKET_SIZE) ;
+    }
     T_MsgHdr* MsgHdr = (T_MsgHdr *)Msg;
     MsgHdr->Magic       = XDR_decode_uint32 (MsgHdr->Magic);
     MsgHdr->Version     = XDR_decode_uint32 (MsgHdr->Version);
@@ -576,9 +589,15 @@
     //////////////////////////////////////////////////
     switch (MsgHdr->MsgId) {
     case CHAT_MSG_ID:
+      if ( repeatHaveServer ) {
+       mSocket->sendto(MsgOriginal, bytes, 0, &repeatServer);
+      }
       ProcessChatMsg(Msg, SenderAddress);
       break;
     case POS_DATA_ID:
+      if ( repeatHaveServer ) {
+       mSocket->sendto(MsgOriginal, bytes, 0, &repeatServer);
+      }
       ProcessPosMsg(Msg, SenderAddress, bytes, stamp);
       break;
     case UNUSABLE_POS_DATA_ID:
Index: src/MultiPlayer/multiplaymgr.hxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/MultiPlayer/multiplaymgr.hxx,v
retrieving revision 1.8
diff -u -r1.8 multiplaymgr.hxx
--- src/MultiPlayer/multiplaymgr.hxx    27 Jul 2008 16:25:15 -0000      1.8
+++ src/MultiPlayer/multiplaymgr.hxx    12 Oct 2008 15:02:30 -0000
@@ -88,7 +88,9 @@
 
   netSocket* mSocket;
   netAddress mServer;
+  netAddress repeatServer;
   bool mHaveServer;
+  bool repeatHaveServer ;
   bool mInitialised;
   string mCallsign;
 };
Index: src/Network/multiplay.cxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/Network/multiplay.cxx,v
retrieving revision 1.17
diff -u -r1.17 multiplay.cxx
--- src/Network/multiplay.cxx   27 Jul 2008 16:25:16 -0000      1.17
+++ src/Network/multiplay.cxx   12 Oct 2008 15:02:30 -0000
@@ -59,6 +59,11 @@
 
   set_hz(rate);
 
+  if (dir == "repeat" ) {
+        set_direction("out");
+       fgSetInt("/sim/multiplay/repeatport", port);
+       fgSetString("/sim/multiplay/repeathost", host.c_str());
+  } else {
   set_direction(dir);
 
   if (get_direction() == SG_IO_IN) {
@@ -72,6 +77,7 @@
     fgSetString("/sim/multiplay/txhost", host.c_str());
 
   }
+  }
 
 }
 
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to