]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - netconn.c
Several changes to the SFX lock code in the sound engine, mainly to make sure SFXs...
[xonotic/darkplaces.git] / netconn.c
index 2c7f0cae03e872acb0a90df28fb49e6c6fa16599..e3fe3123a17369ce93d596ff566e8c3e24db504d 100755 (executable)
--- a/netconn.c
+++ b/netconn.c
@@ -28,14 +28,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 cvar_t sv_public = {0, "sv_public", "0"};
 static cvar_t sv_heartbeatperiod = {CVAR_SAVE, "sv_heartbeatperiod", "180"};
 
+// FIXME: resolve DNS on masters whenever their value changes and cache it (to avoid major delays in active servers when they heartbeat)
 static cvar_t sv_masters [] =
 {
        {CVAR_SAVE, "sv_master1", ""},
        {CVAR_SAVE, "sv_master2", ""},
        {CVAR_SAVE, "sv_master3", ""},
        {CVAR_SAVE, "sv_master4", ""},
-       {0, "sv_masterextra1", "ghdigital.com"},
-       {0, "sv_masterextra2", "dpmaster.deathmask.net"},
+       {0, "sv_masterextra1", "69.59.212.88"}, // ghdigital.com
+       {0, "sv_masterextra2", "66.169.205.13"}, // dpmaster.deathmask.net
        {0, NULL, NULL}
 };
 
@@ -419,13 +420,7 @@ netconn_t *NetConn_Open(lhnetsocket_t *mysocket, lhnetaddress_t *peeraddress)
        conn = Mem_Alloc(netconn_mempool, sizeof(*conn));
        conn->mysocket = mysocket;
        conn->peeraddress = *peeraddress;
-       // updated by receiving "rate" command from client
-       conn->rate = NET_MINRATE;
-       // no limits for local player
-       if (LHNETADDRESS_GetAddressType(peeraddress) == LHNETADDRESSTYPE_LOOP)
-               conn->rate = 1000000000;
        conn->canSend = true;
-       conn->connecttime = realtime;
        conn->lastMessageTime = realtime;
        // LordHavoc: (inspired by ProQuake) use a short connect timeout to
        // reduce effectiveness of connection request floods
@@ -994,7 +989,6 @@ static void NetConn_BuildChallengeString(char *buffer, int bufferlength)
        buffer[i] = 0;
 }
 
-extern void SV_ConnectClient(int clientnum, netconn_t *netconnection);
 int NetConn_ServerParsePacket(lhnetsocket_t *mysocket, qbyte *data, int length, lhnetaddress_t *peeraddress)
 {
        int i, n, ret, clientnum, responselength, best;
@@ -1073,7 +1067,7 @@ int NetConn_ServerParsePacket(lhnetsocket_t *mysocket, qbyte *data, int length,
                                                        if (clientnum < svs.maxclients)
                                                        {
                                                                // duplicate connection request
-                                                               if (realtime - client->netconnection->connecttime < 2.0)
+                                                               if (realtime - client->connecttime < 2.0)
                                                                {
                                                                        // client is still trying to connect,
                                                                        // so we send a duplicate reply
@@ -1200,7 +1194,7 @@ int NetConn_ServerParsePacket(lhnetsocket_t *mysocket, qbyte *data, int length,
                                                        if (clientnum < svs.maxclients)
                                                        {
                                                                // duplicate connection request
-                                                               if (realtime - client->netconnection->connecttime < 2.0)
+                                                               if (realtime - client->connecttime < 2.0)
                                                                {
                                                                        // client is still trying to connect,
                                                                        // so we send a duplicate reply
@@ -1314,8 +1308,8 @@ int NetConn_ServerParsePacket(lhnetsocket_t *mysocket, qbyte *data, int length,
                                                        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)(realtime - client->netconnection->connecttime));
-                                                       MSG_WriteString(&net_message, client->netconnection->address);
+                                                       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));
                                                        NetConn_Write(mysocket, net_message.data, net_message.cursize, peeraddress);
                                                        SZ_Clear(&net_message);
@@ -1363,7 +1357,6 @@ int NetConn_ServerParsePacket(lhnetsocket_t *mysocket, qbyte *data, int length,
                {
                        if (host_client->netconnection && host_client->netconnection->mysocket == mysocket && !LHNETADDRESS_Compare(&host_client->netconnection->peeraddress, peeraddress))
                        {
-                               sv_player = host_client->edict;
                                if ((ret = NetConn_ReceivedMessage(host_client->netconnection, data, length)) == 2)
                                        SV_ReadClientMessage();
                                return ret;
@@ -1385,10 +1378,9 @@ void NetConn_ServerFrame(void)
        for (i = 0, host_client = svs.clients;i < svs.maxclients;i++, host_client++)
        {
                // never timeout loopback connections
-               if (host_client->netconnection && realtime > host_client->netconnection->timeout && LHNETADDRESS_GetAddressType(LHNET_AddressFromSocket(host_client->netconnection->mysocket)) != LHNETADDRESSTYPE_LOOP)
+               if (host_client->netconnection && realtime > host_client->netconnection->timeout && LHNETADDRESS_GetAddressType(&host_client->netconnection->peeraddress) != LHNETADDRESSTYPE_LOOP)
                {
                        Con_Printf("Client \"%s\" connection timed out\n", host_client->name);
-                       sv_player = host_client->edict;
                        SV_DropClient(false);
                }
        }