]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - netconn.c
remove unused variable
[xonotic/darkplaces.git] / netconn.c
index 09e7d059f41b4ecaad51d6268706c65addd82cea..b1f699218f61aa013472e7108138d4533c463fac 100755 (executable)
--- a/netconn.c
+++ b/netconn.c
@@ -44,6 +44,7 @@ static cvar_t sv_masters [] =
 static double nextheartbeattime = 0;
 
 sizebuf_t net_message;
+static qbyte net_message_buf[NET_MAXMESSAGE];
 
 cvar_t net_messagetimeout = {0, "net_messagetimeout","300"};
 cvar_t net_messagerejointimeout = {0, "net_messagerejointimeout","10"};
@@ -193,7 +194,7 @@ static qboolean _ServerList_CompareInt( int A, serverlist_maskop_t op, int B )
 }
 
 static qboolean _ServerList_CompareStr( const char *A, serverlist_maskop_t op, const char *B )
-{ 
+{
        // Same here, also using an intermediate & final return would be more appropriate
        // A info B mask
        switch( op ) {
@@ -879,7 +880,6 @@ void NetConn_ConnectionEstablished(lhnetsocket_t *mysocket, lhnetaddress_t *peer
        cls.demonum = -1;                       // not in the demo loop now
        cls.state = ca_connected;
        cls.signon = 0;                         // need all the signon messages before playing
-       CL_ClearState();
 }
 
 int NetConn_IsLocalGame(void)
@@ -1016,8 +1016,6 @@ int NetConn_ClientParsePacket(lhnetsocket_t *mysocket, qbyte *data, int length,
                        {
                                int n;
 
-                               serverquerycount++;
-
                                dpsnprintf (ipstring, sizeof (ipstring), "%u.%u.%u.%u:%u", data[1], data[2], data[3], data[4], (data[5] << 8) | data[6]);
                                if (developer.integer)
                                        Con_Printf("Requesting info from server %s\n", ipstring);
@@ -1025,25 +1023,27 @@ int NetConn_ClientParsePacket(lhnetsocket_t *mysocket, qbyte *data, int length,
                                if( serverlist_cachecount == SERVERLIST_TOTALSIZE )
                                        break;
                                // also ignore it if we have already queried it (other master server response)
-                               for( n = 0 ; n < serverlist_cachecount ; n++ ) 
+                               for( n = 0 ; n < serverlist_cachecount ; n++ )
                                        if( !strcmp( ipstring, serverlist_cache[ n ].info.cname ) )
                                                break;
-                               if( n < serverlist_cachecount )
-                                       break;
+                               if( n >= serverlist_cachecount )
+                               {
+                                       serverquerycount++;
 
-                               LHNETADDRESS_FromString(&svaddress, ipstring, 0);
-                               NetConn_WriteString(mysocket, "\377\377\377\377getinfo", &svaddress);
+                                       LHNETADDRESS_FromString(&svaddress, ipstring, 0);
+                                       NetConn_WriteString(mysocket, "\377\377\377\377getinfo", &svaddress);
 
-                               memset(&serverlist_cache[serverlist_cachecount], 0, sizeof(serverlist_cache[serverlist_cachecount]));
-                               // store the data the engine cares about (address and ping)
-                               strlcpy (serverlist_cache[serverlist_cachecount].info.cname, ipstring, sizeof (serverlist_cache[serverlist_cachecount].info.cname));
-                               serverlist_cache[serverlist_cachecount].info.ping = 100000;
-                               serverlist_cache[serverlist_cachecount].querytime = realtime;
-                               // if not in the slist menu we should print the server to console
-                               if (serverlist_consoleoutput)
-                                       Con_Printf("querying %s\n", ipstring);
+                                       memset(&serverlist_cache[serverlist_cachecount], 0, sizeof(serverlist_cache[serverlist_cachecount]));
+                                       // store the data the engine cares about (address and ping)
+                                       strlcpy (serverlist_cache[serverlist_cachecount].info.cname, ipstring, sizeof (serverlist_cache[serverlist_cachecount].info.cname));
+                                       serverlist_cache[serverlist_cachecount].info.ping = 100000;
+                                       serverlist_cache[serverlist_cachecount].querytime = realtime;
+                                       // if not in the slist menu we should print the server to console
+                                       if (serverlist_consoleoutput)
+                                               Con_Printf("querying %s\n", ipstring);
 
-                               ++serverlist_cachecount;
+                                       ++serverlist_cachecount;
+                               }
 
                                // move on to next address in packet
                                data += 7;
@@ -1794,7 +1794,7 @@ void NetConn_Init(void)
 {
        int i;
        lhnetaddress_t tempaddress;
-       netconn_mempool = Mem_AllocPool("Networking", 0, NULL);
+       netconn_mempool = Mem_AllocPool("network connections", 0, NULL);
        Cmd_AddCommand("net_stats", Net_Stats_f);
        Cmd_AddCommand("net_slist", Net_Slist_f);
        Cmd_AddCommand("heartbeat", Net_Heartbeat_f);
@@ -1838,7 +1838,9 @@ void NetConn_Init(void)
        }
        cl_numsockets = 0;
        sv_numsockets = 0;
-       SZ_Alloc(&net_message, NET_MAXMESSAGE, "net_message");
+       net_message.data = net_message_buf;
+       net_message.maxsize = sizeof(net_message_buf);
+       net_message.cursize = 0;
        LHNET_Init();
 }