From fef680ba11abb4d8dc88b6fb39e3bf139ac165e0 Mon Sep 17 00:00:00 2001 From: Magnus Auvinen Date: Sat, 14 Jul 2007 16:25:46 +0000 Subject: [PATCH] fixed duplicated connects problem --- src/engine/network.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/engine/network.cpp b/src/engine/network.cpp index e95022f96..2313010e8 100644 --- a/src/engine/network.cpp +++ b/src/engine/network.cpp @@ -510,18 +510,32 @@ int net_server_recv(NETSERVER *s, NETPACKET *packet) // ok packet, process it if(data.flags == NETWORK_PACKETFLAG_CONNECT) { - // client that wants to connect int found = 0; + + // check if we already got this client for(int i = 0; i < NETWORK_MAX_CLIENTS; i++) { - if(s->slots[i].conn.state == NETWORK_CONNSTATE_OFFLINE) + if(net_addr4_cmp(&s->slots[i].conn.peeraddr, &addr) == 0) { - conn_feed(&s->slots[i].conn, &data, &addr); - found = 1; + found = 1; // silent ignore.. we got this client already break; } } + // client that wants to connect + if(!found) + { + for(int i = 0; i < NETWORK_MAX_CLIENTS; i++) + { + if(s->slots[i].conn.state == NETWORK_CONNSTATE_OFFLINE) + { + conn_feed(&s->slots[i].conn, &data, &addr); + found = 1; + break; + } + } + } + if(!found) { // TODO: send error