mirror of
https://git.code.sf.net/p/quake/newtree
synced 2024-11-21 19:51:18 +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
|
@ -26,8 +26,8 @@
|
|||
$Id$
|
||||
*/
|
||||
|
||||
#ifndef _INFO_H
|
||||
#define _INFO_H
|
||||
#ifndef __info_h_
|
||||
#define __info_h_
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
|
@ -35,15 +35,18 @@
|
|||
|
||||
#include <stdlib.h> // for size_t. sys/types.h SHOULD be used, but can't :(bc)
|
||||
|
||||
#include "qtypes.h"
|
||||
|
||||
#define MAX_INFO_STRING 512
|
||||
#define MAX_SERVERINFO_STRING 512
|
||||
#define MAX_LOCALINFO_STRING 32768
|
||||
|
||||
char *Info_ValueForKey (char *s, char *key);
|
||||
qboolean Info_FilterForKey (const char *key);
|
||||
void Info_Print (char *s);
|
||||
void Info_RemoveKey (char *s, char *key);
|
||||
void Info_RemovePrefixedKeys (char *start, char prefix);
|
||||
void Info_SetValueForKey (char *s, char *key, char *value, size_t maxsize);
|
||||
void Info_SetValueForStarKey (char *s, char *key, char *value, size_t maxsize);
|
||||
void Info_Print (char *s);
|
||||
char *Info_ValueForKey (char *s, char *key);
|
||||
|
||||
#endif // _INFO_H
|
||||
#endif // __info_h_
|
||||
|
|
|
@ -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…
Reference in a new issue