]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
moved rate and connecttime from netconn structure to client structure in preparation...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 12 Nov 2004 21:48:07 +0000 (21:48 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 12 Nov 2004 21:48:07 +0000 (21:48 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@4737 d7cf8633-e32d-0410-b094-e92efae38249

host_cmd.c
netconn.c
netconn.h
server.h
sv_main.c

index 7324da76e48c35d1023a43da58d45ac74eda6573..a6b67ca6306583fe8ac1b23fa0b3bc10e1ee4edf 100644 (file)
@@ -84,7 +84,7 @@ void Host_Status_f (void)
        {
                if (!client->active)
                        continue;
-               seconds = (int)(realtime - client->netconnection->connecttime);
+               seconds = (int)(realtime - client->connecttime);
                minutes = seconds / 60;
                if (minutes)
                {
@@ -1014,7 +1014,7 @@ void Host_Rate_f(void)
                return;
        }
 
-       host_client->netconnection->rate = rate;
+       host_client->rate = rate;
 }
 
 /*
@@ -1201,7 +1201,7 @@ void Host_Spawn_f (void)
                pr_global_struct->self = EDICT_TO_PROG(sv_player);
                PR_ExecuteProgram (pr_global_struct->ClientConnect, "QC function ClientConnect is missing");
 
-               if ((Sys_DoubleTime() - host_client->netconnection->connecttime) <= sv.time)
+               if ((Sys_DoubleTime() - host_client->connecttime) <= sv.time)
                        Sys_Printf("%s entered the game\n", host_client->name);
 
                PR_ExecuteProgram (pr_global_struct->PutClientInServer, "QC function PutClientInServer is missing");
index 9ab6cd5ea1541345d67938cd5b1ac486577fd6f6..49ca4dca3ba1e2acd62819c4597a65b28798c3c1 100755 (executable)
--- a/netconn.c
+++ b/netconn.c
@@ -420,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
@@ -1074,7 +1068,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
@@ -1201,7 +1195,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
@@ -1315,7 +1309,7 @@ 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_WriteLong(&net_message, (int)(realtime - client->connecttime));
                                                        MSG_WriteString(&net_message, client->netconnection->address);
                                                        *((int *)net_message.data) = BigLong(NETFLAG_CTL | (net_message.cursize & NETFLAG_LENGTH_MASK));
                                                        NetConn_Write(mysocket, net_message.data, net_message.cursize, peeraddress);
@@ -1386,7 +1380,7 @@ 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;
index cf7c5b74a9a50050ec00dbbb066fffef4fe7239a..a1082fd2ab3273be6abc99fbd0f7b7413f17884e 100755 (executable)
--- a/netconn.h
+++ b/netconn.h
@@ -117,9 +117,6 @@ typedef struct netconn_s
        lhnetsocket_t *mysocket;
        lhnetaddress_t peeraddress;
        
-       // requested rate in bytes per second
-       int rate;
-
        // this is mostly identical to qsocket_t from quake
 
        // if this time is reached, kick off peer
index 15f519325d181c8320e8a29cd9ab5e52664121ca..7b45edfad819aa2c05a8cae03aed51ddb5825cb7 100644 (file)
--- a/server.h
+++ b/server.h
@@ -117,6 +117,12 @@ typedef struct client_s
        // remove this client immediately
        qboolean deadsocket;
 
+       // requested rate in bytes per second
+       int rate;
+
+       // realtime this client connected
+       double connecttime;
+
        // reliable messages must be sent periodically
        double last_message;
 
index e884eaec71af154292cc324d2e6f036759a60cf5..4dcf5de78900b558c4091dcc20121f73728705d9 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -362,7 +362,7 @@ void SV_ConnectClient (int clientnum, netconn_t *netconnection)
        client->active = true;
        client->netconnection = netconnection;
 
-       Con_DPrintf("Client %s connected\n", client->netconnection->address);
+       Con_DPrintf("Client %s connected\n", client->netconnection ? client->netconnection->address : "botclient");
 
        strcpy(client->name, "unconnected");
        strcpy(client->old_name, "unconnected");
@@ -371,6 +371,12 @@ void SV_ConnectClient (int clientnum, netconn_t *netconnection)
        client->message.data = client->msgbuf;
        client->message.maxsize = sizeof(client->msgbuf);
        client->message.allowoverflow = true;           // we can catch it
+       // updated by receiving "rate" command from client
+       client->rate = NET_MINRATE;
+       // no limits for local player
+       if (client->netconnection && LHNETADDRESS_GetAddressType(&client->netconnection->peeraddress) == LHNETADDRESSTYPE_LOOP)
+               client->rate = 1000000000;
+       client->connecttime = realtime;
 
        if (sv.loadgame)
                memcpy (client->spawn_parms, spawn_parms, sizeof(spawn_parms));
@@ -1061,8 +1067,8 @@ qboolean SV_SendClientDatagram (client_t *client)
                if (sv_maxrate.integer != maxrate)
                        Cvar_SetValueQuick(&sv_maxrate, maxrate);
 
-               rate = bound(NET_MINRATE, client->netconnection->rate, maxrate);
-               rate = (int)(client->netconnection->rate * sys_ticrate.value);
+               rate = bound(NET_MINRATE, client->rate, maxrate);
+               rate = (int)(client->rate * sys_ticrate.value);
                maxsize = bound(100, rate, 1400);
                maxsize2 = 1400;
        }