bot player stats seem to be working working

This commit is contained in:
Bill Currie 2003-03-05 03:56:50 +00:00
parent 6b20862865
commit 6c028a57bb
5 changed files with 23 additions and 2 deletions

View file

@ -150,6 +150,7 @@ typedef enum {
typedef struct client_s
{
sv_client_state_t state;
int ping; // fake ping for server clients
qboolean prespawned;
qboolean spawned;

View file

@ -396,6 +396,8 @@ SV_CalcPing (client_t *cl)
int count, i;
register client_frame_t *frame;
if (cl->state == cs_server)
return cl->ping;
ping = 0;
count = 0;
for (frame = cl->frames, i = 0; i < UPDATE_BACKUP; i++, frame++) {

View file

@ -1768,6 +1768,7 @@ PF_SV_AllocClient (progs_t *pr)
//XXX netchan? Netchan_Setup (&newcl->netchan, adr, qport);
cl->state = cs_server;
cl->spectator = 0;
cl->connection_started = realtime;
RETURN_EDICT (pr, cl->edict);
}
@ -1779,6 +1780,7 @@ PF_SV_FreeClient (progs_t *pr)
if (entnum < 1 || entnum > MAX_CLIENTS || cl->state != cs_server)
PR_RunError (pr, "not a server client");
if (cl->userinfo)
Info_Destroy (cl->userinfo);
//SV_FullClientUpdate (cl, &sv.reliable_datagram);
@ -1793,11 +1795,26 @@ PF_SV_SetUserinfo (progs_t *pr)
int entnum = P_EDICTNUM (pr, 0);
client_t *cl = svs.clients + entnum - 1;
const char *str = P_STRING (pr, 1);
if (entnum < 1 || entnum > MAX_CLIENTS || cl->state != cs_server)
PR_RunError (pr, "not a server client");
cl->userinfo = Info_ParseString (str, 1023, !sv_highchars->int_val);
cl->sendinfo = true;
SV_ExtractFromUserinfo (cl);
}
static void
PR_SV_SetPing (progs_t *pr)
{
int entnum = P_EDICTNUM (pr, 0);
client_t *cl = svs.clients + entnum - 1;
if (entnum < 1 || entnum > MAX_CLIENTS || cl->state != cs_server)
PR_RunError (pr, "not a server client");
cl->ping = P_INT (pr, 1);
}
void
SV_PR_Cmds_Init ()
{
@ -1876,4 +1893,5 @@ SV_PR_Cmds_Init ()
PR_AddBuiltin (&sv_pr_state, "SV_AllocClient", PF_SV_AllocClient, -1);
PR_AddBuiltin (&sv_pr_state, "SV_FreeClient", PF_SV_FreeClient, -1);
PR_AddBuiltin (&sv_pr_state, "SV_SetUserinfo", PF_SV_SetUserinfo, -1);
PR_AddBuiltin (&sv_pr_state, "SV_SetPing", PR_SV_SetPing, -1);
};

View file

@ -710,7 +710,7 @@ SV_UpdateToReliableMessages (void)
// check for changes to be sent over the reliable streams to all clients
for (i = 0, host_client = svs.clients; i < MAX_CLIENTS; i++, host_client++) {
if (host_client->state != cs_spawned)
if (host_client->state != cs_spawned && host_client->state != cs_server)
continue;
if (host_client->sendinfo) {
host_client->sendinfo = false;

View file

@ -905,7 +905,7 @@ SV_Pings_f (ucmd_t *cmd)
int j;
for (j = 0, client = svs.clients; j < MAX_CLIENTS; j++, client++) {
if (client->state != cs_spawned)
if (client->state != cs_spawned && client->state != cs_server)
continue;
ClientReliableWrite_Begin (host_client, svc_updateping, 4);