mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
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:
parent
8c026417d8
commit
74e9f89e8c
8 changed files with 63 additions and 18 deletions
|
@ -36,12 +36,13 @@
|
||||||
#define MAX_SERVERINFO_STRING 512
|
#define MAX_SERVERINFO_STRING 512
|
||||||
#define MAX_LOCALINFO_STRING 32768
|
#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_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_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_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);
|
qboolean Info_Validate (const char *s);
|
||||||
|
|
||||||
#endif // _INFO_H
|
#endif // _INFO_H
|
||||||
|
|
|
@ -41,7 +41,6 @@
|
||||||
|
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
#include "QF/crc.h"
|
#include "QF/crc.h"
|
||||||
#include "QF/info.h"
|
|
||||||
#include "QF/model.h"
|
#include "QF/model.h"
|
||||||
#include "QF/msg.h"
|
#include "QF/msg.h"
|
||||||
#include "QF/qendian.h"
|
#include "QF/qendian.h"
|
||||||
|
|
|
@ -44,6 +44,24 @@
|
||||||
|
|
||||||
#include "compat.h"
|
#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
|
Info_ValueForKey
|
||||||
|
@ -138,7 +156,7 @@ Info_RemoveKey (char *s, const char *key)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Info_RemovePrefixedKeys (char *start, char prefix)
|
Info_RemovePrefixedKeys (char *start, char prefix, const char **filter_list)
|
||||||
{
|
{
|
||||||
char *s;
|
char *s;
|
||||||
char pkey[512];
|
char pkey[512];
|
||||||
|
@ -167,7 +185,8 @@ Info_RemovePrefixedKeys (char *start, char prefix)
|
||||||
}
|
}
|
||||||
*o = 0;
|
*o = 0;
|
||||||
|
|
||||||
if (pkey[0] == prefix) {
|
if (pkey[0] == prefix
|
||||||
|
|| (filter_list && !Info_FilterForKey (pkey, filter_list))) {
|
||||||
Info_RemoveKey (start, pkey);
|
Info_RemoveKey (start, pkey);
|
||||||
s = start;
|
s = start;
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,6 @@
|
||||||
#include "QF/console.h"
|
#include "QF/console.h"
|
||||||
#include "QF/cvar.h"
|
#include "QF/cvar.h"
|
||||||
#include "QF/hash.h"
|
#include "QF/hash.h"
|
||||||
#include "QF/info.h"
|
|
||||||
#include "QF/qargs.h"
|
#include "QF/qargs.h"
|
||||||
#include "QF/qendian.h"
|
#include "QF/qendian.h"
|
||||||
#include "QF/qtypes.h"
|
#include "QF/qtypes.h"
|
||||||
|
|
|
@ -413,6 +413,8 @@ extern double realtime;
|
||||||
|
|
||||||
extern struct progs_s sv_pr_state;
|
extern struct progs_s sv_pr_state;
|
||||||
|
|
||||||
|
extern const char *client_info_filters[];
|
||||||
|
|
||||||
//===========================================================
|
//===========================================================
|
||||||
// FIXME: declare exported functions in their own relevant .h
|
// FIXME: declare exported functions in their own relevant .h
|
||||||
|
|
||||||
|
|
|
@ -155,6 +155,24 @@ void SV_AcceptClient (netadr_t adr, int userid, char *userinfo);
|
||||||
void Master_Shutdown (void);
|
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
|
qboolean
|
||||||
ServerPaused (void)
|
ServerPaused (void)
|
||||||
{
|
{
|
||||||
|
@ -349,7 +367,7 @@ SV_FullClientUpdate (client_t *client, sizebuf_t *buf)
|
||||||
MSG_WriteFloat (buf, realtime - client->connection_started);
|
MSG_WriteFloat (buf, realtime - client->connection_started);
|
||||||
|
|
||||||
strncpy (info, client->userinfo, sizeof (info));
|
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, svc_updateuserinfo);
|
||||||
MSG_WriteByte (buf, i);
|
MSG_WriteByte (buf, i);
|
||||||
|
|
|
@ -1353,11 +1353,15 @@ PF_setinfokey (progs_t *pr)
|
||||||
Info_SetValueForKey (svs.clients[e1 - 1].userinfo, key, value,
|
Info_SetValueForKey (svs.clients[e1 - 1].userinfo, key, value,
|
||||||
MAX_INFO_STRING, !sv_highchars->int_val);
|
MAX_INFO_STRING, !sv_highchars->int_val);
|
||||||
SV_ExtractFromUserinfo (&svs.clients[e1 - 1]);
|
SV_ExtractFromUserinfo (&svs.clients[e1 - 1]);
|
||||||
MSG_WriteByte (&sv.reliable_datagram, svc_setinfo);
|
|
||||||
MSG_WriteByte (&sv.reliable_datagram, e1 - 1);
|
if (Info_FilterForKey (Cmd_Argv (1), client_info_filters)) {
|
||||||
MSG_WriteString (&sv.reliable_datagram, key);
|
MSG_WriteByte (&sv.reliable_datagram, svc_setinfo);
|
||||||
MSG_WriteString (&sv.reliable_datagram,
|
MSG_WriteByte (&sv.reliable_datagram, e1 - 1);
|
||||||
Info_ValueForKey (svs.clients[e1 - 1].userinfo, key));
|
MSG_WriteString (&sv.reliable_datagram, key);
|
||||||
|
MSG_WriteString (&sv.reliable_datagram,
|
||||||
|
Info_ValueForKey (svs.clients[e1 - 1].userinfo,
|
||||||
|
key));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1148,11 +1148,14 @@ SV_SetInfo_f (void)
|
||||||
// process any changed values
|
// process any changed values
|
||||||
SV_ExtractFromUserinfo (host_client);
|
SV_ExtractFromUserinfo (host_client);
|
||||||
|
|
||||||
MSG_WriteByte (&sv.reliable_datagram, svc_setinfo);
|
if (Info_FilterForKey (Cmd_Argv (1), client_info_filters)) {
|
||||||
MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
|
MSG_WriteByte (&sv.reliable_datagram, svc_setinfo);
|
||||||
MSG_WriteString (&sv.reliable_datagram, Cmd_Argv (1));
|
MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
|
||||||
MSG_WriteString (&sv.reliable_datagram,
|
MSG_WriteString (&sv.reliable_datagram, Cmd_Argv (1));
|
||||||
Info_ValueForKey (host_client->userinfo, Cmd_Argv (1)));
|
MSG_WriteString (&sv.reliable_datagram,
|
||||||
|
Info_ValueForKey (host_client->userinfo,
|
||||||
|
Cmd_Argv (1)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue