mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-03-22 18:31:27 +00:00
[qw] Add SV_ClientNumber builtin
This is a quick way to find the client number for an entity. It returns -1 if the entity is not a valid client (either outside the client block, or not currently in use by a client).
This commit is contained in:
parent
44c48feb56
commit
760256c99e
1 changed files with 16 additions and 0 deletions
|
@ -1829,6 +1829,21 @@ PF_sv_cvar (progs_t *pr)
|
|||
}
|
||||
}
|
||||
|
||||
// int () SV_ClientNumber
|
||||
// returns -1 if the entity is not a client (either not in the client range
|
||||
// or the entity is not in use by a client)
|
||||
static void
|
||||
PF_SV_ClientNumber (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) {
|
||||
entnum = 0; // nil entity
|
||||
}
|
||||
R_INT (pr) = entnum - 1;
|
||||
}
|
||||
|
||||
// entity () SV_AllocClient
|
||||
static void
|
||||
PF_SV_AllocClient (progs_t *pr)
|
||||
|
@ -2017,6 +2032,7 @@ static builtin_t builtins[] = {
|
|||
{"cfeof", PF_cfeof, QF 107},
|
||||
{"cfquota", PF_cfquota, QF 108},
|
||||
|
||||
{"SV_ClientNumber", PF_SV_ClientNumber, -1},
|
||||
{"SV_AllocClient", PF_SV_AllocClient, -1},
|
||||
{"SV_FreeClient", PF_SV_FreeClient, -1},
|
||||
{"SV_SetUserinfo", PF_SV_SetUserinfo, -1},
|
||||
|
|
Loading…
Reference in a new issue