mirror of
https://git.code.sf.net/p/quake/newtree
synced 2025-05-31 09:11:06 +00:00
Userinfo culling in the server. The server now only sends userinfo stuff
that's useful to the client or the players. This should solve the problem with QW clients' tiny setinfo buffers once and for all. Note, you can still use setinfo to set your user info, but if it's not in the "need-to-know" list, the server won't send it back to you. I will probably make this optional with a server Cvar if there are problems.
This commit is contained in:
parent
49d7b35d43
commit
6f1587ff7f
3 changed files with 55 additions and 15 deletions
|
@ -39,6 +39,7 @@
|
|||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "compat.h"
|
||||
#include "console.h"
|
||||
#include "info.h"
|
||||
|
||||
|
@ -46,13 +47,48 @@
|
|||
INFO STRINGS
|
||||
*/
|
||||
|
||||
const static char *client_info_filters[] = { // Info keys needed by client
|
||||
"name",
|
||||
"topcolor",
|
||||
"bottomcolor",
|
||||
"rate",
|
||||
"msg",
|
||||
"skin",
|
||||
"team",
|
||||
"noaim",
|
||||
"pmodel",
|
||||
"emodel",
|
||||
"spectator",
|
||||
"*spectator",
|
||||
"*ver",
|
||||
NULL
|
||||
};
|
||||
|
||||
/*
|
||||
Info_FilterForKey
|
||||
|
||||
Searches for key in the "client-needed" info string list
|
||||
*/
|
||||
qboolean
|
||||
Info_FilterForKey (const char *key)
|
||||
{
|
||||
const char **s;
|
||||
|
||||
for (s = client_info_filters; *s; s++) {
|
||||
if (strequal (*s, key)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
Info_ValueForKey
|
||||
|
||||
Searches the string for the given
|
||||
key and returns the associated value, or an empty string.
|
||||
*/
|
||||
char *
|
||||
char *
|
||||
Info_ValueForKey (char *s, char *key)
|
||||
{
|
||||
char pkey[512];
|
||||
|
@ -127,7 +163,7 @@ Info_RemoveKey (char *s, char *key)
|
|||
}
|
||||
*o = 0;
|
||||
|
||||
if (!strcmp (key, pkey)) {
|
||||
if (strequal (key, pkey)) {
|
||||
strcpy (start, s); // remove this part
|
||||
return;
|
||||
}
|
||||
|
@ -168,7 +204,7 @@ Info_RemovePrefixedKeys (char *start, char prefix)
|
|||
}
|
||||
*o = 0;
|
||||
|
||||
if (pkey[0] == prefix) {
|
||||
if ((pkey[0] == prefix) || (!(Info_FilterForKey (pkey)))) {
|
||||
Info_RemoveKey (start, pkey);
|
||||
s = start;
|
||||
}
|
||||
|
@ -176,7 +212,6 @@ Info_RemovePrefixedKeys (char *start, char prefix)
|
|||
if (!*s)
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1119,12 +1119,14 @@ SV_SetInfo_f (void)
|
|||
// process any changed values
|
||||
SV_ExtractFromUserinfo (host_client);
|
||||
|
||||
i = host_client - svs.clients;
|
||||
MSG_WriteByte (&sv.reliable_datagram, svc_setinfo);
|
||||
MSG_WriteByte (&sv.reliable_datagram, i);
|
||||
MSG_WriteString (&sv.reliable_datagram, Cmd_Argv (1));
|
||||
MSG_WriteString (&sv.reliable_datagram,
|
||||
Info_ValueForKey (host_client->userinfo, Cmd_Argv (1)));
|
||||
if (Info_FilterForKey (Cmd_Argv (1))) {
|
||||
i = host_client - svs.clients;
|
||||
MSG_WriteByte (&sv.reliable_datagram, svc_setinfo);
|
||||
MSG_WriteByte (&sv.reliable_datagram, i);
|
||||
MSG_WriteString (&sv.reliable_datagram, Cmd_Argv (1));
|
||||
MSG_WriteString (&sv.reliable_datagram,
|
||||
Info_ValueForKey (host_client->userinfo, Cmd_Argv (1)));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue