mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-30 20:50:42 +00:00
bot player stats seem to be working working
This commit is contained in:
parent
6b20862865
commit
6c028a57bb
5 changed files with 23 additions and 2 deletions
|
@ -150,6 +150,7 @@ typedef enum {
|
||||||
typedef struct client_s
|
typedef struct client_s
|
||||||
{
|
{
|
||||||
sv_client_state_t state;
|
sv_client_state_t state;
|
||||||
|
int ping; // fake ping for server clients
|
||||||
qboolean prespawned;
|
qboolean prespawned;
|
||||||
qboolean spawned;
|
qboolean spawned;
|
||||||
|
|
||||||
|
|
|
@ -396,6 +396,8 @@ SV_CalcPing (client_t *cl)
|
||||||
int count, i;
|
int count, i;
|
||||||
register client_frame_t *frame;
|
register client_frame_t *frame;
|
||||||
|
|
||||||
|
if (cl->state == cs_server)
|
||||||
|
return cl->ping;
|
||||||
ping = 0;
|
ping = 0;
|
||||||
count = 0;
|
count = 0;
|
||||||
for (frame = cl->frames, i = 0; i < UPDATE_BACKUP; i++, frame++) {
|
for (frame = cl->frames, i = 0; i < UPDATE_BACKUP; i++, frame++) {
|
||||||
|
|
|
@ -1768,6 +1768,7 @@ PF_SV_AllocClient (progs_t *pr)
|
||||||
//XXX netchan? Netchan_Setup (&newcl->netchan, adr, qport);
|
//XXX netchan? Netchan_Setup (&newcl->netchan, adr, qport);
|
||||||
cl->state = cs_server;
|
cl->state = cs_server;
|
||||||
cl->spectator = 0;
|
cl->spectator = 0;
|
||||||
|
cl->connection_started = realtime;
|
||||||
RETURN_EDICT (pr, cl->edict);
|
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)
|
if (entnum < 1 || entnum > MAX_CLIENTS || cl->state != cs_server)
|
||||||
PR_RunError (pr, "not a server client");
|
PR_RunError (pr, "not a server client");
|
||||||
|
|
||||||
if (cl->userinfo)
|
if (cl->userinfo)
|
||||||
Info_Destroy (cl->userinfo);
|
Info_Destroy (cl->userinfo);
|
||||||
//SV_FullClientUpdate (cl, &sv.reliable_datagram);
|
//SV_FullClientUpdate (cl, &sv.reliable_datagram);
|
||||||
|
@ -1793,11 +1795,26 @@ PF_SV_SetUserinfo (progs_t *pr)
|
||||||
int entnum = P_EDICTNUM (pr, 0);
|
int entnum = P_EDICTNUM (pr, 0);
|
||||||
client_t *cl = svs.clients + entnum - 1;
|
client_t *cl = svs.clients + entnum - 1;
|
||||||
const char *str = P_STRING (pr, 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->userinfo = Info_ParseString (str, 1023, !sv_highchars->int_val);
|
||||||
cl->sendinfo = true;
|
cl->sendinfo = true;
|
||||||
SV_ExtractFromUserinfo (cl);
|
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
|
void
|
||||||
SV_PR_Cmds_Init ()
|
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_AllocClient", PF_SV_AllocClient, -1);
|
||||||
PR_AddBuiltin (&sv_pr_state, "SV_FreeClient", PF_SV_FreeClient, -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_SetUserinfo", PF_SV_SetUserinfo, -1);
|
||||||
|
PR_AddBuiltin (&sv_pr_state, "SV_SetPing", PR_SV_SetPing, -1);
|
||||||
};
|
};
|
||||||
|
|
|
@ -710,7 +710,7 @@ SV_UpdateToReliableMessages (void)
|
||||||
|
|
||||||
// check for changes to be sent over the reliable streams to all clients
|
// 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++) {
|
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;
|
continue;
|
||||||
if (host_client->sendinfo) {
|
if (host_client->sendinfo) {
|
||||||
host_client->sendinfo = false;
|
host_client->sendinfo = false;
|
||||||
|
|
|
@ -905,7 +905,7 @@ SV_Pings_f (ucmd_t *cmd)
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
for (j = 0, client = svs.clients; j < MAX_CLIENTS; j++, client++) {
|
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;
|
continue;
|
||||||
|
|
||||||
ClientReliableWrite_Begin (host_client, svc_updateping, 4);
|
ClientReliableWrite_Begin (host_client, svc_updateping, 4);
|
||||||
|
|
Loading…
Reference in a new issue