{
if (!client->active)
continue;
- seconds = (int)(realtime - client->netconnection->connecttime);
+ seconds = (int)(realtime - client->connecttime);
minutes = seconds / 60;
if (minutes)
{
return;
}
- host_client->netconnection->rate = rate;
+ host_client->rate = rate;
}
/*
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");
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
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
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
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);
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;
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
// 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;
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");
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));
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;
}