make Info_Set* take flags indicating wether funchars should be stripped or not

This commit is contained in:
Bill Currie 2001-07-31 18:27:49 +00:00
parent 2b19252d73
commit fb26d8b18a
15 changed files with 73 additions and 53 deletions

View file

@ -39,8 +39,8 @@
const char *Info_ValueForKey (const char *s, const char *key); const char *Info_ValueForKey (const char *s, const char *key);
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);
void Info_SetValueForKey (char *s, const char *key, const char *value, size_t maxsize); 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); void Info_SetValueForStarKey (char *s, const char *key, const char *value, size_t maxsize, int flags);
void Info_Print (const char *s); void Info_Print (const char *s);
qboolean Info_Validate (const char *s); qboolean Info_Validate (const char *s);

View file

@ -182,11 +182,11 @@ Info_RemovePrefixedKeys (char *start, char prefix)
void void
Info_SetValueForStarKey (char *s, const char *key, const char *value, size_t maxsize) Info_SetValueForStarKey (char *s, const char *key, const char *value, size_t maxsize, int flags)
{ {
char newstr[1024]; char newstr[1024];
const char *v; const char *v;
int c, is_name, is_team; int c;
if (strstr (key, "\\") || strstr (value, "\\")) { if (strstr (key, "\\") || strstr (value, "\\")) {
Con_Printf ("Can't use keys or values with a \\\n"); Con_Printf ("Can't use keys or values with a \\\n");
@ -225,17 +225,15 @@ Info_SetValueForStarKey (char *s, const char *key, const char *value, size_t max
// only copy ascii values // only copy ascii values
s += strlen (s); s += strlen (s);
v = newstr; v = newstr;
is_name = strcaseequal (key, "name");
is_team = strcaseequal (key, "team");
while (*v) { while (*v) {
c = (unsigned char) *v++; c = (unsigned char) *v++;
// client only allows highbits on name // client only allows highbits on name
if (!is_name) { if (flags & 1) {
c &= 127; c &= 127;
if (c < 32 || c > 127) if (c < 32 || c > 127)
continue; continue;
// auto lowercase team // auto lowercase team
if (is_team) if (flags & 2)
c = tolower (c); c = tolower (c);
} }
if (c > 13) if (c > 13)
@ -245,14 +243,14 @@ Info_SetValueForStarKey (char *s, const char *key, const char *value, size_t max
} }
void void
Info_SetValueForKey (char *s, const char *key, const char *value, size_t maxsize) Info_SetValueForKey (char *s, const char *key, const char *value, size_t maxsize, int flags)
{ {
if (key[0] == '*') { if (key[0] == '*') {
Con_Printf ("Can't set * keys\n"); Con_Printf ("Can't set * keys\n");
return; return;
} }
Info_SetValueForStarKey (s, key, value, maxsize); Info_SetValueForStarKey (s, key, value, maxsize, flags);
} }
void void

View file

@ -371,6 +371,8 @@ typedef enum
//============================================================================ //============================================================================
// FIXME: declare exported variables in their own relevant .h // FIXME: declare exported variables in their own relevant .h
extern struct cvar_s *sv_highchars;
extern struct cvar_s *sv_mintic, *sv_maxtic; extern struct cvar_s *sv_mintic, *sv_maxtic;
extern struct cvar_s *sv_maxspeed; extern struct cvar_s *sv_maxspeed;

View file

@ -30,17 +30,21 @@
# include "config.h" # include "config.h"
#endif #endif
#include "client.h"
#include "QF/cvar.h" #include "QF/cvar.h"
#include "QF/msg.h" #include "QF/msg.h"
#include "QF/va.h" #include "QF/va.h"
#include "client.h"
#include "compat.h"
void void
Cvar_Info (cvar_t *var) Cvar_Info (cvar_t *var)
{ {
if (var->flags & CVAR_USERINFO) { if (var->flags & CVAR_USERINFO) {
Info_SetValueForKey (cls.userinfo, var->name, var->string, Info_SetValueForKey (cls.userinfo, var->name, var->string,
MAX_INFO_STRING); MAX_INFO_STRING,
((!strequal(var->name, "name"))
|(strequal(var->name, "team") << 1)));
if (cls.state >= ca_connected) { if (cls.state >= ca_connected) {
MSG_WriteByte (&cls.netchan.message, clc_stringcmd); MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
MSG_WriteString (&cls.netchan.message, MSG_WriteString (&cls.netchan.message,

View file

@ -637,11 +637,11 @@ CL_AddQFInfoKeys (void)
#ifdef HAVE_ZLIB #ifdef HAVE_ZLIB
strncat (cap, "z", sizeof (cap) - strlen (cap) - 1); strncat (cap, "z", sizeof (cap) - strlen (cap) - 1);
#endif #endif
Info_SetValueForStarKey (cls.userinfo, "*cap", cap, MAX_INFO_STRING); Info_SetValueForStarKey (cls.userinfo, "*cap", cap, MAX_INFO_STRING, 0);
Info_SetValueForStarKey (cls.userinfo, "*qf_version", VERSION, Info_SetValueForStarKey (cls.userinfo, "*qf_version", VERSION,
MAX_INFO_STRING); MAX_INFO_STRING, 0);
Info_SetValueForStarKey (cls.userinfo, "*qsg_version", QW_QSG_VERSION, Info_SetValueForStarKey (cls.userinfo, "*qsg_version", QW_QSG_VERSION,
MAX_INFO_STRING); MAX_INFO_STRING, 0);
Con_Printf ("QuakeForge server detected\n"); Con_Printf ("QuakeForge server detected\n");
} }
@ -700,7 +700,9 @@ CL_FullInfo_f (void)
if (strcaseequal (key, pmodel_name) || strcaseequal (key, emodel_name)) if (strcaseequal (key, pmodel_name) || strcaseequal (key, emodel_name))
continue; continue;
Info_SetValueForKey (cls.userinfo, key, value, MAX_INFO_STRING); Info_SetValueForKey (cls.userinfo, key, value, MAX_INFO_STRING,
(!strequal (key, "name"))
| (strequal (key, "team") << 1));
} }
} }
@ -726,7 +728,9 @@ CL_SetInfo_f (void)
return; return;
Info_SetValueForKey (cls.userinfo, Cmd_Argv (1), Cmd_Argv (2), Info_SetValueForKey (cls.userinfo, Cmd_Argv (1), Cmd_Argv (2),
MAX_INFO_STRING); MAX_INFO_STRING,
(!strequal (Cmd_Argv (1), "name"))
| (strequal (Cmd_Argv (2), "team") << 1));
if (cls.state >= ca_connected) if (cls.state >= ca_connected)
Cmd_ForwardToServer (); Cmd_ForwardToServer ();
} }
@ -1098,16 +1102,16 @@ CL_Init (void)
cls.state = ca_disconnected; cls.state = ca_disconnected;
Info_SetValueForKey (cls.userinfo, "name", "unnamed", MAX_INFO_STRING); Info_SetValueForKey (cls.userinfo, "name", "unnamed", MAX_INFO_STRING, 0);
Info_SetValueForKey (cls.userinfo, "topcolor", "0", MAX_INFO_STRING); Info_SetValueForKey (cls.userinfo, "topcolor", "0", MAX_INFO_STRING, 0);
Info_SetValueForKey (cls.userinfo, "bottomcolor", "0", MAX_INFO_STRING); Info_SetValueForKey (cls.userinfo, "bottomcolor", "0", MAX_INFO_STRING, 0);
Info_SetValueForKey (cls.userinfo, "rate", "2500", MAX_INFO_STRING); Info_SetValueForKey (cls.userinfo, "rate", "2500", MAX_INFO_STRING, 0);
Info_SetValueForKey (cls.userinfo, "msg", "1", MAX_INFO_STRING); Info_SetValueForKey (cls.userinfo, "msg", "1", MAX_INFO_STRING, 0);
// snprintf (st, sizeof(st), "%s-%04d", QW_VERSION, build_number()); // snprintf (st, sizeof(st), "%s-%04d", QW_VERSION, build_number());
snprintf (st, sizeof (st), "%s", QW_VERSION); snprintf (st, sizeof (st), "%s", QW_VERSION);
Info_SetValueForStarKey (cls.userinfo, "*ver", st, MAX_INFO_STRING); Info_SetValueForStarKey (cls.userinfo, "*ver", st, MAX_INFO_STRING, 0);
Info_SetValueForStarKey (cls.userinfo, "stdver", QW_QSG_VERSION, Info_SetValueForStarKey (cls.userinfo, "stdver", QW_QSG_VERSION,
MAX_INFO_STRING); MAX_INFO_STRING, 0);
CL_Input_Init (); CL_Input_Init ();
CL_Ents_Init (); CL_Ents_Init ();

View file

@ -300,7 +300,7 @@ Model_NextDownload (void)
if (info_key && cl_model_crcs->int_val) { if (info_key && cl_model_crcs->int_val) {
aliashdr_t *ahdr = (aliashdr_t *) Mod_Extradata (cl.model_precache[i]); aliashdr_t *ahdr = (aliashdr_t *) Mod_Extradata (cl.model_precache[i]);
Info_SetValueForKey (cls.userinfo, info_key, va ("%d", ahdr->crc), Info_SetValueForKey (cls.userinfo, info_key, va ("%d", ahdr->crc),
MAX_INFO_STRING); MAX_INFO_STRING, 0);
MSG_WriteByte (&cls.netchan.message, clc_stringcmd); MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
SZ_Print (&cls.netchan.message, va ("setinfo %s %d", info_key, ahdr->crc)); SZ_Print (&cls.netchan.message, va ("setinfo %s %d", info_key, ahdr->crc));
} }
@ -1038,7 +1038,9 @@ CL_SetInfo (void)
Con_DPrintf ("SETINFO %s: %s=%s\n", player->name, key, value); Con_DPrintf ("SETINFO %s: %s=%s\n", player->name, key, value);
Info_SetValueForKey (player->userinfo, key, value, MAX_INFO_STRING); Info_SetValueForKey (player->userinfo, key, value, MAX_INFO_STRING,
(!strequal (key, "name"))
| (strequal (key, "team") << 1));
CL_ProcessUserInfo (slot, player); CL_ProcessUserInfo (slot, player);
} }
@ -1057,7 +1059,7 @@ CL_ServerInfo (void)
Con_DPrintf ("SERVERINFO: %s=%s\n", key, value); Con_DPrintf ("SERVERINFO: %s=%s\n", key, value);
Info_SetValueForKey (cl.serverinfo, key, value, MAX_SERVERINFO_STRING); Info_SetValueForKey (cl.serverinfo, key, value, MAX_SERVERINFO_STRING, 0);
} }

View file

@ -82,7 +82,7 @@ SV_Gamedir_f (void)
if (is_server) { if (is_server) {
Info_SetValueForStarKey (svs_info, "*gamedir", dir, Info_SetValueForStarKey (svs_info, "*gamedir", dir,
MAX_SERVERINFO_STRING); MAX_SERVERINFO_STRING, 0);
} }
} }

View file

@ -103,7 +103,7 @@ Skin_Find (player_info_t *sc)
strcpy (name, "base"); strcpy (name, "base");
if (!allskins[0] && (!s || !strcaseequal (name, s))) if (!allskins[0] && (!s || !strcaseequal (name, s)))
Info_SetValueForKey (sc->userinfo, "skin", name, MAX_INFO_STRING); Info_SetValueForKey (sc->userinfo, "skin", name, MAX_INFO_STRING, 1);
COM_StripExtension (name, name); COM_StripExtension (name, name);

View file

@ -695,7 +695,7 @@ SV_Serverinfo_f (void)
return; return;
} }
Info_SetValueForKey (svs.info, Cmd_Argv (1), Cmd_Argv (2), Info_SetValueForKey (svs.info, Cmd_Argv (1), Cmd_Argv (2),
MAX_SERVERINFO_STRING); MAX_SERVERINFO_STRING, !sv_highchars->int_val);
// if this is a cvar, change it too // if this is a cvar, change it too
var = Cvar_FindVar (Cmd_Argv (1)); var = Cvar_FindVar (Cmd_Argv (1));
@ -733,7 +733,7 @@ SV_Localinfo_f (void)
return; return;
} }
Info_SetValueForKey (localinfo, Cmd_Argv (1), Cmd_Argv (2), Info_SetValueForKey (localinfo, Cmd_Argv (1), Cmd_Argv (2),
MAX_LOCALINFO_STRING); MAX_LOCALINFO_STRING, !sv_highchars->int_val);
} }
@ -785,7 +785,8 @@ SV_Gamedir (void)
return; return;
} }
Info_SetValueForStarKey (svs.info, "*gamedir", dir, MAX_SERVERINFO_STRING); Info_SetValueForStarKey (svs.info, "*gamedir", dir, MAX_SERVERINFO_STRING,
!sv_highchars->int_val);
} }
/* /*
@ -944,7 +945,7 @@ SV_InitOperatorCommands (void)
if (COM_CheckParm ("-cheats")) { if (COM_CheckParm ("-cheats")) {
sv_allow_cheats = true; sv_allow_cheats = true;
Info_SetValueForStarKey (svs.info, "*cheats", "ON", Info_SetValueForStarKey (svs.info, "*cheats", "ON",
MAX_SERVERINFO_STRING); MAX_SERVERINFO_STRING, !sv_highchars->int_val);
} }
Cmd_AddCommand ("logfile", SV_Logfile_f, "Toggles logging of console text to qconsole.log"); Cmd_AddCommand ("logfile", SV_Logfile_f, "Toggles logging of console text to qconsole.log");

View file

@ -35,8 +35,6 @@
void SV_SendServerInfoChange (const char *key, const char *value); void SV_SendServerInfoChange (const char *key, const char *value);
extern cvar_t *sv_highchars;
/* /*
Cvar_Info Cvar_Info
@ -62,10 +60,12 @@ Cvar_Info (cvar_t *var)
} }
*p = 0; *p = 0;
Info_SetValueForKey (svs.info, var->name, info, Info_SetValueForKey (svs.info, var->name, info,
MAX_SERVERINFO_STRING); MAX_SERVERINFO_STRING,
(sv_highchars && !sv_highchars->int_val));
} else } else
Info_SetValueForKey (svs.info, var->name, var->string, Info_SetValueForKey (svs.info, var->name, var->string,
MAX_SERVERINFO_STRING); MAX_SERVERINFO_STRING,
(sv_highchars && !sv_highchars->int_val));
SV_SendServerInfoChange (var->name, var->string); SV_SendServerInfoChange (var->name, var->string);
// SV_BroadcastCommand ("fullserverinfo \"%s\"\n", svs.info); // SV_BroadcastCommand ("fullserverinfo \"%s\"\n", svs.info);

View file

@ -37,10 +37,12 @@
#endif #endif
#include "QF/crc.h" #include "QF/crc.h"
#include "compat.h" #include "QF/cvar.h"
#include "QF/msg.h" #include "QF/msg.h"
#include "QF/va.h" #include "QF/va.h"
#include "QF/vfs.h" #include "QF/vfs.h"
#include "compat.h"
#include "server.h" #include "server.h"
#include "sv_progs.h" #include "sv_progs.h"
#include "world.h" #include "world.h"
@ -341,7 +343,7 @@ SV_SpawnServer (const char *server)
// which determines how big each edict is // which determines how big each edict is
SV_LoadProgs (); SV_LoadProgs ();
Info_SetValueForStarKey (svs.info, "*progs", va ("%i", sv_pr_state.crc), Info_SetValueForStarKey (svs.info, "*progs", va ("%i", sv_pr_state.crc),
MAX_SERVERINFO_STRING); MAX_SERVERINFO_STRING, !sv_highchars->int_val);
// allocate edicts // allocate edicts
sv.edicts = PR_InitEdicts (&sv_pr_state, MAX_EDICTS); sv.edicts = PR_InitEdicts (&sv_pr_state, MAX_EDICTS);
@ -436,6 +438,7 @@ SV_SpawnServer (const char *server)
SV_CreateBaseline (); SV_CreateBaseline ();
sv.signon_buffer_size[sv.num_signon_buffers - 1] = sv.signon.cursize; sv.signon_buffer_size[sv.num_signon_buffers - 1] = sv.signon.cursize;
Info_SetValueForKey (svs.info, "map", sv.name, MAX_SERVERINFO_STRING); Info_SetValueForKey (svs.info, "map", sv.name, MAX_SERVERINFO_STRING,
!sv_highchars->int_val);
Con_DPrintf ("Server spawned.\n"); Con_DPrintf ("Server spawned.\n");
} }

View file

@ -734,7 +734,8 @@ SVC_DirectConnect (void)
return; return;
} }
Info_RemoveKey (userinfo, "spectator"); // remove passwd Info_RemoveKey (userinfo, "spectator"); // remove passwd
Info_SetValueForStarKey (userinfo, "*spectator", "1", MAX_INFO_STRING); Info_SetValueForStarKey (userinfo, "*spectator", "1", MAX_INFO_STRING,
!sv_highchars->int_val);
spectator = true; spectator = true;
} else { } else {
s = Info_ValueForKey (userinfo, "password"); s = Info_ValueForKey (userinfo, "password");
@ -1468,10 +1469,11 @@ SV_CheckVars (void)
SV_Printf ("Updated needpass.\n"); SV_Printf ("Updated needpass.\n");
if (!v) if (!v)
Info_SetValueForKey (svs.info, "needpass", "", MAX_SERVERINFO_STRING); Info_SetValueForKey (svs.info, "needpass", "", MAX_SERVERINFO_STRING,
!sv_highchars->int_val);
else else
Info_SetValueForKey (svs.info, "needpass", va ("%i", v), Info_SetValueForKey (svs.info, "needpass", va ("%i", v),
MAX_SERVERINFO_STRING); MAX_SERVERINFO_STRING, !sv_highchars->int_val);
} }
/* /*
@ -1727,13 +1729,13 @@ SV_InitLocal (void)
snprintf (localmodels[i], sizeof (localmodels[i]), "*%i", i); snprintf (localmodels[i], sizeof (localmodels[i]), "*%i", i);
Info_SetValueForStarKey (svs.info, "*version", QW_VERSION, Info_SetValueForStarKey (svs.info, "*version", QW_VERSION,
MAX_SERVERINFO_STRING); MAX_SERVERINFO_STRING, !sv_highchars->int_val);
// Brand server as QF, with appropriate QSG standards version --KB // Brand server as QF, with appropriate QSG standards version --KB
Info_SetValueForStarKey (svs.info, "*qf_version", VERSION, Info_SetValueForStarKey (svs.info, "*qf_version", VERSION,
MAX_SERVERINFO_STRING); MAX_SERVERINFO_STRING, !sv_highchars->int_val);
Info_SetValueForStarKey (svs.info, "*qsg_version", QW_QSG_VERSION, Info_SetValueForStarKey (svs.info, "*qsg_version", QW_QSG_VERSION,
MAX_SERVERINFO_STRING); MAX_SERVERINFO_STRING, !sv_highchars->int_val);
CF_Init (); CF_Init ();
@ -1857,12 +1859,14 @@ SV_ExtractFromUserinfo (client_t *cl)
p[1] = 0; p[1] = 0;
if (strcmp (val, newname)) { if (strcmp (val, newname)) {
Info_SetValueForKey (cl->userinfo, "name", newname, MAX_INFO_STRING); Info_SetValueForKey (cl->userinfo, "name", newname, MAX_INFO_STRING,
!sv_highchars->int_val);
val = Info_ValueForKey (cl->userinfo, "name"); val = Info_ValueForKey (cl->userinfo, "name");
} }
if (!val[0] || strcaseequal (val, "console")) { if (!val[0] || strcaseequal (val, "console")) {
Info_SetValueForKey (cl->userinfo, "name", "unnamed", MAX_INFO_STRING); Info_SetValueForKey (cl->userinfo, "name", "unnamed", MAX_INFO_STRING,
!sv_highchars->int_val);
val = Info_ValueForKey (cl->userinfo, "name"); val = Info_ValueForKey (cl->userinfo, "name");
} }
// check to see if another user by the same name exists // check to see if another user by the same name exists
@ -1883,7 +1887,7 @@ SV_ExtractFromUserinfo (client_t *cl)
snprintf (newname, sizeof (newname), "(%d)%-.40s", dupc++, val); snprintf (newname, sizeof (newname), "(%d)%-.40s", dupc++, val);
Info_SetValueForKey (cl->userinfo, "name", newname, Info_SetValueForKey (cl->userinfo, "name", newname,
MAX_INFO_STRING); MAX_INFO_STRING, !sv_highchars->int_val);
val = Info_ValueForKey (cl->userinfo, "name"); val = Info_ValueForKey (cl->userinfo, "name");
// If the new name was not set (due to the info string // If the new name was not set (due to the info string

View file

@ -1792,10 +1792,11 @@ PF_setinfokey (progs_t *pr)
const char *value = G_STRING (pr, OFS_PARM2); const char *value = G_STRING (pr, OFS_PARM2);
if (e1 == 0) { if (e1 == 0) {
Info_SetValueForKey (localinfo, key, value, MAX_LOCALINFO_STRING); Info_SetValueForKey (localinfo, key, value, MAX_LOCALINFO_STRING,
!sv_highchars->int_val);
} else if (e1 <= MAX_CLIENTS) { } else if (e1 <= MAX_CLIENTS) {
Info_SetValueForKey (svs.clients[e1 - 1].userinfo, key, value, Info_SetValueForKey (svs.clients[e1 - 1].userinfo, key, value,
MAX_INFO_STRING); 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, svc_setinfo);
MSG_WriteByte (&sv.reliable_datagram, e1 - 1); MSG_WriteByte (&sv.reliable_datagram, e1 - 1);

View file

@ -132,7 +132,8 @@ parse_field (progs_t *pr, const char *key, const char *value)
if (strcaseequal (key, "skyname") // QuakeForge if (strcaseequal (key, "skyname") // QuakeForge
|| strcaseequal (key, "sky") // Q2/DarkPlaces || strcaseequal (key, "sky") // Q2/DarkPlaces
|| strcaseequal (key, "qlsky")) { // QuakeLives || strcaseequal (key, "qlsky")) { // QuakeLives
Info_SetValueForKey (svs.info, "skybox", "1", MAX_SERVERINFO_STRING); Info_SetValueForKey (svs.info, "skybox", "1", MAX_SERVERINFO_STRING,
!sv_highchars->int_val);
Cvar_Set (r_skyname, value); Cvar_Set (r_skyname, value);
return 1; return 1;
} }

View file

@ -1116,7 +1116,7 @@ SV_SetInfo_f (void)
strcpy (oldval, Info_ValueForKey (host_client->userinfo, Cmd_Argv (1))); strcpy (oldval, Info_ValueForKey (host_client->userinfo, Cmd_Argv (1)));
Info_SetValueForKey (host_client->userinfo, Cmd_Argv (1), Cmd_Argv (2), Info_SetValueForKey (host_client->userinfo, Cmd_Argv (1), Cmd_Argv (2),
MAX_INFO_STRING); MAX_INFO_STRING, !sv_highchars->int_val);
if (strequal if (strequal
(Info_ValueForKey (host_client->userinfo, Cmd_Argv (1)), oldval)) (Info_ValueForKey (host_client->userinfo, Cmd_Argv (1)), oldval))
return; // key hasn't changed return; // key hasn't changed