X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;ds=sidebyside;f=netconn.c;h=ba94089475c699826a5b22663817c02cdec248bb;hb=56561de0acdb9cf29d155992440ac3e0d32909dd;hp=713b46780be9409afb4285ee19f67edfbca3528b;hpb=26732adaa8ff2bdf233717a8f0c6ea64023c3da8;p=xonotic%2Fdarkplaces.git diff --git a/netconn.c b/netconn.c index 713b4678..ba940894 100755 --- a/netconn.c +++ b/netconn.c @@ -763,14 +763,15 @@ int NetConn_ReceivedMessage(netconn_t *conn, qbyte *data, int length) unsigned int count; unsigned int flags; unsigned int sequence; + int qlength; if (length >= 8) { - length = BigLong(((int *)data)[0]); - flags = length & ~NETFLAG_LENGTH_MASK; - length &= NETFLAG_LENGTH_MASK; + qlength = (unsigned int)BigLong(((int *)data)[0]); + flags = qlength & ~NETFLAG_LENGTH_MASK; + qlength &= NETFLAG_LENGTH_MASK; // control packets were already handled - if (!(flags & NETFLAG_CTL)) + if (!(flags & NETFLAG_CTL) && qlength == length) { sequence = BigLong(((int *)data)[1]); packetsReceived++; @@ -852,7 +853,7 @@ int NetConn_ReceivedMessage(netconn_t *conn, qbyte *data, int length) "Dropping the message!\n", sequence ); conn->receiveMessageLength = 0; return 1; - } + } if (flags & NETFLAG_EOM) { reliableMessagesReceived++; @@ -926,10 +927,12 @@ int NetConn_ClientParsePacket(lhnetsocket_t *mysocket, qbyte *data, int length, if (length > 10 && !memcmp(string, "challenge ", 10) && cls.connect_trying) { + char protocolnames[1400]; + Protocol_Names(protocolnames, sizeof(protocolnames)); LHNETADDRESS_ToString(peeraddress, addressstring2, sizeof(addressstring2), true); Con_Printf("\"%s\" received, sending connect request back to %s\n", string, addressstring2); M_Update_Return_Reason("Got challenge response"); - NetConn_WriteString(mysocket, va("\377\377\377\377connect\\protocol\\darkplaces 3\\challenge\\%s", string + 10), peeraddress); + NetConn_WriteString(mysocket, va("\377\377\377\377connect\\protocol\\darkplaces 3\\protocols\\%s\\challenge\\%s", protocolnames, string + 10), peeraddress); return true; } if (length == 6 && !memcmp(string, "accept", 6) && cls.connect_trying) @@ -962,9 +965,28 @@ int NetConn_ClientParsePacket(lhnetsocket_t *mysocket, qbyte *data, int length, for( n = 0; n < serverlist_cachecount; n++ ) if( !strcmp( cname, serverlist_cache[n].info.cname ) ) break; - if( n == serverlist_cachecount ) - return true; + if( n == serverlist_cachecount ) { + // LAN search doesnt require an answer from the master server so we wont + // know the ping nor will it be initialized already... + // find a slot + if( serverlist_cachecount == SERVERLIST_TOTALSIZE ) + return true; + serverquerycount++; + + 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, cname, 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; + + } info = &serverlist_cache[n].info; if ((s = SearchInfostring(string, "gamename" )) != NULL) strlcpy(info->game, s, sizeof (info->game));else info->game[0] = 0; if ((s = SearchInfostring(string, "modname" )) != NULL) strlcpy(info->mod , s, sizeof (info->mod ));else info->mod[0] = 0; @@ -1561,7 +1583,7 @@ int NetConn_ServerParsePacket(lhnetsocket_t *mysocket, qbyte *data, int length, MSG_WriteByte(&net_message, playerNumber); MSG_WriteString(&net_message, client->name); MSG_WriteLong(&net_message, client->colors); - MSG_WriteLong(&net_message, (int)client->edict->v->frags); + MSG_WriteLong(&net_message, (int)client->edict->fields.server->frags); MSG_WriteLong(&net_message, (int)(realtime - client->connecttime)); MSG_WriteString(&net_message, client->netconnection ? client->netconnection->address : "botclient"); *((int *)net_message.data) = BigLong(NETFLAG_CTL | (net_message.cursize & NETFLAG_LENGTH_MASK));