[enet-cvs] CVS: enet host.c,1.10,1.11 protocol.c,1.17,1.18

Lee Salzman enet at sferik.cubik.org
Wed Oct 29 09:53:42 PST 2003


Update of /home/enet/cvsroot/enet
In directory sferik:/tmp/cvs-serv1615

Modified Files:
	host.c protocol.c 
Log Message:
connect handling fixes


Index: host.c
===================================================================
RCS file: /home/enet/cvsroot/enet/host.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- host.c	2003/03/12 00:50:59	1.10
+++ host.c	2003/10/29 17:53:38	1.11
@@ -134,7 +134,8 @@
     currentPeer -> address = * address;
     currentPeer -> channels = (ENetChannel *) enet_malloc (channelCount * sizeof (ENetChannel));
     currentPeer -> channelCount = channelCount;
-
+    currentPeer -> challenge = (enet_uint32) rand ();
+         
     for (channel = currentPeer -> channels;
          channel < & currentPeer -> channels [channelCount];
          ++ channel)

Index: protocol.c
===================================================================
RCS file: /home/enet/cvsroot/enet/protocol.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- protocol.c	2003/08/13 01:55:00	1.17
+++ protocol.c	2003/10/29 17:53:38	1.18
@@ -156,6 +156,14 @@
     {
         if (currentPeer -> state == ENET_PEER_STATE_DISCONNECTED)
           break;
+
+        if (currentPeer -> address.host == host -> receivedAdress.host &&
+            currentPeer -> address.port == host -> receivedAddress.port &&
+            currentPeer -> challenge == header -> challenge)
+        {
+            enet_peer_reset (currentPeer);
+            break;
+        }
     }
 
     if (currentPeer >= & host -> peers [host -> peerCount])
@@ -860,9 +868,6 @@
               peer -> reliableDataInTransit + outgoingCommand -> fragmentLength > peer -> windowSize)
             break;
        }
-       else
-       if (outgoingCommand -> command.header.command == ENET_PROTOCOL_COMMAND_CONNECT)
-         peer -> challenge = (enet_uint32) rand ();
        
        if (outgoingCommand -> roundTripTimeout == 0)
        {



More information about the enet-cvs mailing list