diff --git a/include/QF/info.h b/include/QF/info.h index 297589c22..956d0d359 100644 --- a/include/QF/info.h +++ b/include/QF/info.h @@ -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 diff --git a/libs/models/alias/model_alias.c b/libs/models/alias/model_alias.c index 97b22eb29..36f078a88 100644 --- a/libs/models/alias/model_alias.c +++ b/libs/models/alias/model_alias.c @@ -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" diff --git a/libs/util/info.c b/libs/util/info.c index 7eccca04a..34a476881 100644 --- a/libs/util/info.c +++ b/libs/util/info.c @@ -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; } diff --git a/libs/util/quakefs.c b/libs/util/quakefs.c index 37b232409..94d087ee2 100644 --- a/libs/util/quakefs.c +++ b/libs/util/quakefs.c @@ -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" diff --git a/qw/include/server.h b/qw/include/server.h index 91a70781f..c61d55def 100644 --- a/qw/include/server.h +++ b/qw/include/server.h @@ -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 diff --git a/qw/source/sv_main.c b/qw/source/sv_main.c index 2f7da1105..ad5e1fea3 100644 --- a/qw/source/sv_main.c +++ b/qw/source/sv_main.c @@ -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); diff --git a/qw/source/sv_pr_cmds.c b/qw/source/sv_pr_cmds.c index 019861b67..85f35c4d8 100644 --- a/qw/source/sv_pr_cmds.c +++ b/qw/source/sv_pr_cmds.c @@ -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)); + } } } diff --git a/qw/source/sv_user.c b/qw/source/sv_user.c index 8d972bad1..2de84a79d 100644 --- a/qw/source/sv_user.c +++ b/qw/source/sv_user.c @@ -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))); + } } /*