]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - netconn.c
changed sv.time to realtime in name change time limit code
[xonotic/darkplaces.git] / netconn.c
index 1ade12c331a31c390ae00667a88d7bbada744888..c0c4c1e8db1f63e613e47e967c29deeef072f54f 100755 (executable)
--- a/netconn.c
+++ b/netconn.c
@@ -38,8 +38,7 @@ static cvar_t sv_masters [] =
        {CVAR_SAVE, "sv_master4", "", "user-chosen master server 4"},
        {0, "sv_masterextra1", "ghdigital.com", "default master server 1 (admin: LordHavoc)"}, // admin: LordHavoc
        {0, "sv_masterextra2", "dpmaster.deathmask.net", "default master server 2 (admin: Willis)"}, // admin: Willis
-       {0, "sv_masterextra3", "12.166.196.192", "default master server 3 (admin: Venim)"}, // admin: Venim
-       {0, "sv_masterextra4", "excalibur.nvg.ntnu.no", "default master server 4 (admin: tChr)"}, // admin: tChr
+       {0, "sv_masterextra3", "excalibur.nvg.ntnu.no", "default master server 3 (admin: tChr)"}, // admin: tChr
        {0, NULL, NULL, NULL}
 };
 
@@ -405,8 +404,7 @@ static void _ServerList_Test(void)
 
 void ServerList_QueryList(qboolean querydp, qboolean queryqw)
 {
-       //masterquerytime = realtime;
-       masterquerytime = Sys_DoubleTime();
+       masterquerytime = realtime;
        masterquerycount = 0;
        masterreplycount = 0;
        serverquerycount = 0;
@@ -1092,6 +1090,9 @@ void NetConn_ConnectionEstablished(lhnetsocket_t *mysocket, lhnetaddress_t *peer
        cls.state = ca_connected;
        cls.signon = 0;                         // need all the signon messages before playing
        cls.protocol = initialprotocol;
+       // reset move sequence numbering on this new connection
+       cls.movesequence = 0;
+       cls.servermovesequence = 0;
        if (cls.protocol == PROTOCOL_QUAKEWORLD)
                Cmd_ForwardStringToServer("new");
        if (cls.protocol == PROTOCOL_QUAKE)
@@ -1136,8 +1137,7 @@ static int NetConn_ClientParsePacket_ServerList_ProcessReply(const char *address
                // store the data the engine cares about (address and ping)
                strlcpy(serverlist_cache[serverlist_cachecount].info.cname, addressstring, sizeof(serverlist_cache[serverlist_cachecount].info.cname));
                serverlist_cache[serverlist_cachecount].info.ping = 100000;
-               //serverlist_cache[serverlist_cachecount].querytime = realtime;
-               serverlist_cache[serverlist_cachecount].querytime = Sys_DoubleTime();
+               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", addressstring);
@@ -1146,7 +1146,7 @@ static int NetConn_ClientParsePacket_ServerList_ProcessReply(const char *address
        // if this is the first reply from this server, count it as having replied
        if (serverlist_cache[n].info.ping == 100000)
                serverreplycount++;
-       pingtime = (int)((Sys_DoubleTime() - serverlist_cache[n].querytime) * 1000.0 + 0.5);
+       pingtime = (int)((realtime - serverlist_cache[n].querytime) * 1000.0 + 0.5);
        pingtime = bound(0, pingtime, 9999);
        // update the ping
        serverlist_cache[n].info.ping = min(serverlist_cache[n].info.ping, pingtime);
@@ -1452,9 +1452,12 @@ static int NetConn_ClientParsePacket(lhnetsocket_t *mysocket, unsigned char *dat
                int n;
                serverlist_info_t *info;
 
-               c = data[4];
-               data += 5;
-               length -= 5;
+               data += 4;
+               length -= 4;
+               SZ_Clear(&net_message);
+               SZ_Write(&net_message, data, length);
+               MSG_BeginReading();
+               c = MSG_ReadByte();
                switch (c)
                {
                case CCREP_ACCEPT:
@@ -1464,13 +1467,7 @@ static int NetConn_ClientParsePacket(lhnetsocket_t *mysocket, unsigned char *dat
                        {
                                lhnetaddress_t clientportaddress;
                                clientportaddress = *peeraddress;
-                               if (length >= 4)
-                               {
-                                       unsigned int port = (data[0] << 0) | (data[1] << 8) | (data[2] << 16) | (data[3] << 24);
-                                       data += 4;
-                                       length -= 4;
-                                       LHNETADDRESS_SetPort(&clientportaddress, port);
-                               }
+                               LHNETADDRESS_SetPort(&clientportaddress, MSG_ReadLong());
                                // update the server IP in the userinfo (QW servers expect this, and it is used by the reconnect command)
                                InfoString_SetValue(cls.userinfo, sizeof(cls.userinfo), "*ip", addressstring2);
                                M_Update_Return_Reason("Accepted");
@@ -1481,7 +1478,7 @@ static int NetConn_ClientParsePacket(lhnetsocket_t *mysocket, unsigned char *dat
                        if (developer.integer >= 10)
                                Con_Printf("Datagram_ParseConnectionless: received CCREP_REJECT from %s.\n", addressstring2);
                        cls.connect_trying = false;
-                       M_Update_Return_Reason((char *)data);
+                       M_Update_Return_Reason((char *)MSG_ReadString());
                        break;
                case CCREP_SERVER_INFO:
                        if (developer.integer >= 10)
@@ -1519,6 +1516,7 @@ static int NetConn_ClientParsePacket(lhnetsocket_t *mysocket, unsigned char *dat
                default:
                        break;
                }
+               SZ_Clear(&net_message);
                // we may not have liked the packet, but it was a valid control
                // packet, so we're done processing this packet now
                return true;
@@ -1590,8 +1588,7 @@ void NetConn_QueryQueueFrame(void)
                                        NetConn_WriteString(cl_sockets[socket], "\377\377\377\377getinfo", &address);
                        }
 
-                       //entry->querytime = realtime;
-                       entry->querytime = Sys_DoubleTime();
+                       entry->querytime = realtime;
                        entry->querycounter++;
 
                        // if not in the slist menu we should print the server to console
@@ -2048,20 +2045,26 @@ static int NetConn_ServerParsePacket(lhnetsocket_t *mysocket, unsigned char *dat
        //  Quake packet flood Denial Of Service attacks)
        if (length >= 5 && (i = BigLong(*((int *)data))) && (i & (~NETFLAG_LENGTH_MASK)) == (int)NETFLAG_CTL && (i & NETFLAG_LENGTH_MASK) == length && (sv.protocol == PROTOCOL_QUAKE || sv.protocol == PROTOCOL_QUAKEDP || sv.protocol == PROTOCOL_NEHAHRAMOVIE || sv.protocol == PROTOCOL_DARKPLACES1 || sv.protocol == PROTOCOL_DARKPLACES2 || sv.protocol == PROTOCOL_DARKPLACES3))
        {
-               int c = data[4];
-               data += 5;
-               length -= 5;
+               int c;
+               int protocolnumber;
+               const char *protocolname;
+               data += 4;
+               length -= 4;
+               SZ_Clear(&net_message);
+               SZ_Write(&net_message, data, length);
+               MSG_BeginReading();
+               c = MSG_ReadByte();
                switch (c)
                {
                case CCREQ_CONNECT:
                        if (developer.integer >= 10)
                                Con_Printf("Datagram_ParseConnectionless: received CCREQ_CONNECT from %s.\n", addressstring2);
-                       if (length < (int)strlen("QUAKE") + 1 + 1)
-                               break;
                        if(sv_public.integer <= -2)
                                break;
 
-                       if (memcmp(data, "QUAKE", strlen("QUAKE") + 1) != 0 || (int)data[strlen("QUAKE") + 1] != NET_PROTOCOL_VERSION)
+                       protocolname = MSG_ReadString();
+                       protocolnumber = MSG_ReadByte();
+                       if (strcmp(protocolname, "QUAKE") || protocolnumber != NET_PROTOCOL_VERSION)
                        {
                                if (developer.integer >= 10)
                                        Con_Printf("Datagram_ParseConnectionless: sending CCREP_REJECT \"Incompatible version.\" to %s.\n", addressstring2);
@@ -2209,7 +2212,7 @@ static int NetConn_ServerParsePacket(lhnetsocket_t *mysocket, unsigned char *dat
                                        MSG_WriteByte(&net_message, playerNumber);
                                        MSG_WriteString(&net_message, client->name);
                                        MSG_WriteLong(&net_message, client->colors);
-                                       MSG_WriteLong(&net_message, (int)client->edict->fields.server->frags);
+                                       MSG_WriteLong(&net_message, client->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));
@@ -2250,6 +2253,7 @@ static int NetConn_ServerParsePacket(lhnetsocket_t *mysocket, unsigned char *dat
                default:
                        break;
                }
+               SZ_Clear(&net_message);
                // we may not have liked the packet, but it was a valid control
                // packet, so we're done processing this packet now
                return true;
@@ -2287,6 +2291,11 @@ void NetConn_ServerFrame(void)
        }
 }
 
+void NetConn_SleepMicroseconds(int microseconds)
+{
+       LHNET_SleepUntilPacket_Microseconds(microseconds);
+}
+
 void NetConn_QueryMasters(qboolean querydp, qboolean queryqw)
 {
        int i;