forward port the client info string filtering from 0.3 and remove info.h from

a couple of c files that no longer need it.
This commit is contained in:
Bill Currie 2001-09-11 03:10:29 +00:00
parent 8c026417d8
commit 74e9f89e8c
8 changed files with 63 additions and 18 deletions

View File

@ -36,12 +36,13 @@
#define MAX_SERVERINFO_STRING 512
#define MAX_LOCALINFO_STRING 32768
const char *Info_ValueForKey (const char *s, const char *key);
qboolean Info_FilterForKey (const char *key, const char **filter_list);
void Info_Print (const char *s);
void Info_RemoveKey (char *s, const char *key);
void Info_RemovePrefixedKeys (char *start, char prefix);
void Info_RemovePrefixedKeys (char *start, char prefix, const char **filter_list);
void Info_SetValueForKey (char *s, const char *key, const char *value, size_t maxsize, int flags);
void Info_SetValueForStarKey (char *s, const char *key, const char *value, size_t maxsize, int flags);
void Info_Print (const char *s);
const char *Info_ValueForKey (const char *s, const char *key);
qboolean Info_Validate (const char *s);
#endif // _INFO_H

View File

@ -41,7 +41,6 @@
#include "compat.h"
#include "QF/crc.h"
#include "QF/info.h"
#include "QF/model.h"
#include "QF/msg.h"
#include "QF/qendian.h"

View File

@ -44,6 +44,24 @@
#include "compat.h"
/*
Info_FilterForKey
Searches for key in the "client-needed" info string list
*/
qboolean
Info_FilterForKey (const char *key, const char **filter_list)
{
const char **s;
for (s = filter_list; *s; s++) {
if (strequal (*s, key)) {
return true;
}
}
return false;
}
/*
Info_ValueForKey
@ -138,7 +156,7 @@ Info_RemoveKey (char *s, const char *key)
}
void
Info_RemovePrefixedKeys (char *start, char prefix)
Info_RemovePrefixedKeys (char *start, char prefix, const char **filter_list)
{
char *s;
char pkey[512];
@ -167,7 +185,8 @@ Info_RemovePrefixedKeys (char *start, char prefix)
}
*o = 0;
if (pkey[0] == prefix) {
if (pkey[0] == prefix
|| (filter_list && !Info_FilterForKey (pkey, filter_list))) {
Info_RemoveKey (start, pkey);
s = start;
}

View File

@ -65,7 +65,6 @@
#include "QF/console.h"
#include "QF/cvar.h"
#include "QF/hash.h"
#include "QF/info.h"
#include "QF/qargs.h"
#include "QF/qendian.h"
#include "QF/qtypes.h"

View File

@ -413,6 +413,8 @@ extern double realtime;
extern struct progs_s sv_pr_state;
extern const char *client_info_filters[];
//===========================================================
// FIXME: declare exported functions in their own relevant .h

View File

@ -155,6 +155,24 @@ void SV_AcceptClient (netadr_t adr, int userid, char *userinfo);
void Master_Shutdown (void);
const char *client_info_filters[] = { // Info keys needed by client
"name",
"topcolor",
"bottomcolor",
"rate",
"msg",
"skin",
"team",
"noaim",
"pmodel",
"emodel",
"spectator",
"*spectator",
"*ver",
NULL
};
qboolean
ServerPaused (void)
{
@ -349,7 +367,7 @@ SV_FullClientUpdate (client_t *client, sizebuf_t *buf)
MSG_WriteFloat (buf, realtime - client->connection_started);
strncpy (info, client->userinfo, sizeof (info));
Info_RemovePrefixedKeys (info, '_'); // server passwords, etc
Info_RemovePrefixedKeys (info, '_', client_info_filters); // server passwords, etc
MSG_WriteByte (buf, svc_updateuserinfo);
MSG_WriteByte (buf, i);

View File

@ -1353,11 +1353,15 @@ PF_setinfokey (progs_t *pr)
Info_SetValueForKey (svs.clients[e1 - 1].userinfo, key, value,
MAX_INFO_STRING, !sv_highchars->int_val);
SV_ExtractFromUserinfo (&svs.clients[e1 - 1]);
MSG_WriteByte (&sv.reliable_datagram, svc_setinfo);
MSG_WriteByte (&sv.reliable_datagram, e1 - 1);
MSG_WriteString (&sv.reliable_datagram, key);
MSG_WriteString (&sv.reliable_datagram,
Info_ValueForKey (svs.clients[e1 - 1].userinfo, key));
if (Info_FilterForKey (Cmd_Argv (1), client_info_filters)) {
MSG_WriteByte (&sv.reliable_datagram, svc_setinfo);
MSG_WriteByte (&sv.reliable_datagram, e1 - 1);
MSG_WriteString (&sv.reliable_datagram, key);
MSG_WriteString (&sv.reliable_datagram,
Info_ValueForKey (svs.clients[e1 - 1].userinfo,
key));
}
}
}

View File

@ -1148,11 +1148,14 @@ SV_SetInfo_f (void)
// process any changed values
SV_ExtractFromUserinfo (host_client);
MSG_WriteByte (&sv.reliable_datagram, svc_setinfo);
MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
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), client_info_filters)) {
MSG_WriteByte (&sv.reliable_datagram, svc_setinfo);
MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
MSG_WriteString (&sv.reliable_datagram, Cmd_Argv (1));
MSG_WriteString (&sv.reliable_datagram,
Info_ValueForKey (host_client->userinfo,
Cmd_Argv (1)));
}
}
/*