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);
void Info_RemoveKey (char *s, const char *key);
void Info_RemovePrefixedKeys (char *start, char prefix);
void Info_SetValueForKey (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);
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);
qboolean Info_Validate (const char *s);

View file

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

View file

@ -371,6 +371,8 @@ typedef enum
//============================================================================
// 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_maxspeed;

View file

@ -30,17 +30,21 @@
# include "config.h"
#endif
#include "client.h"
#include "QF/cvar.h"
#include "QF/msg.h"
#include "QF/va.h"
#include "client.h"
#include "compat.h"
void
Cvar_Info (cvar_t *var)
{
if (var->flags & CVAR_USERINFO) {
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) {
MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
MSG_WriteString (&cls.netchan.message,

View file

@ -637,11 +637,11 @@ CL_AddQFInfoKeys (void)
#ifdef HAVE_ZLIB
strncat (cap, "z", sizeof (cap) - strlen (cap) - 1);
#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,
MAX_INFO_STRING);
MAX_INFO_STRING, 0);
Info_SetValueForStarKey (cls.userinfo, "*qsg_version", QW_QSG_VERSION,
MAX_INFO_STRING);
MAX_INFO_STRING, 0);
Con_Printf ("QuakeForge server detected\n");
}
@ -700,7 +700,9 @@ CL_FullInfo_f (void)
if (strcaseequal (key, pmodel_name) || strcaseequal (key, emodel_name))
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;
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)
Cmd_ForwardToServer ();
}
@ -1098,16 +1102,16 @@ CL_Init (void)
cls.state = ca_disconnected;
Info_SetValueForKey (cls.userinfo, "name", "unnamed", MAX_INFO_STRING);
Info_SetValueForKey (cls.userinfo, "topcolor", "0", MAX_INFO_STRING);
Info_SetValueForKey (cls.userinfo, "bottomcolor", "0", MAX_INFO_STRING);
Info_SetValueForKey (cls.userinfo, "rate", "2500", MAX_INFO_STRING);
Info_SetValueForKey (cls.userinfo, "msg", "1", MAX_INFO_STRING);
Info_SetValueForKey (cls.userinfo, "name", "unnamed", MAX_INFO_STRING, 0);
Info_SetValueForKey (cls.userinfo, "topcolor", "0", MAX_INFO_STRING, 0);
Info_SetValueForKey (cls.userinfo, "bottomcolor", "0", MAX_INFO_STRING, 0);
Info_SetValueForKey (cls.userinfo, "rate", "2500", MAX_INFO_STRING, 0);
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", 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,
MAX_INFO_STRING);
MAX_INFO_STRING, 0);
CL_Input_Init ();
CL_Ents_Init ();

View file

@ -300,7 +300,7 @@ Model_NextDownload (void)
if (info_key && cl_model_crcs->int_val) {
aliashdr_t *ahdr = (aliashdr_t *) Mod_Extradata (cl.model_precache[i]);
Info_SetValueForKey (cls.userinfo, info_key, va ("%d", ahdr->crc),
MAX_INFO_STRING);
MAX_INFO_STRING, 0);
MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
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);
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);
}
@ -1057,7 +1059,7 @@ CL_ServerInfo (void)
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) {
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");
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);

View file

@ -695,7 +695,7 @@ SV_Serverinfo_f (void)
return;
}
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
var = Cvar_FindVar (Cmd_Argv (1));
@ -733,7 +733,7 @@ SV_Localinfo_f (void)
return;
}
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;
}
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")) {
sv_allow_cheats = true;
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");

View file

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

View file

@ -37,10 +37,12 @@
#endif
#include "QF/crc.h"
#include "compat.h"
#include "QF/cvar.h"
#include "QF/msg.h"
#include "QF/va.h"
#include "QF/vfs.h"
#include "compat.h"
#include "server.h"
#include "sv_progs.h"
#include "world.h"
@ -341,7 +343,7 @@ SV_SpawnServer (const char *server)
// which determines how big each edict is
SV_LoadProgs ();
Info_SetValueForStarKey (svs.info, "*progs", va ("%i", sv_pr_state.crc),
MAX_SERVERINFO_STRING);
MAX_SERVERINFO_STRING, !sv_highchars->int_val);
// allocate edicts
sv.edicts = PR_InitEdicts (&sv_pr_state, MAX_EDICTS);
@ -436,6 +438,7 @@ SV_SpawnServer (const char *server)
SV_CreateBaseline ();
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");
}

View file

@ -734,7 +734,8 @@ SVC_DirectConnect (void)
return;
}
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;
} else {
s = Info_ValueForKey (userinfo, "password");
@ -1468,10 +1469,11 @@ SV_CheckVars (void)
SV_Printf ("Updated needpass.\n");
if (!v)
Info_SetValueForKey (svs.info, "needpass", "", MAX_SERVERINFO_STRING);
Info_SetValueForKey (svs.info, "needpass", "", MAX_SERVERINFO_STRING,
!sv_highchars->int_val);
else
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);
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
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,
MAX_SERVERINFO_STRING);
MAX_SERVERINFO_STRING, !sv_highchars->int_val);
CF_Init ();
@ -1857,12 +1859,14 @@ SV_ExtractFromUserinfo (client_t *cl)
p[1] = 0;
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");
}
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");
}
// 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);
Info_SetValueForKey (cl->userinfo, "name", newname,
MAX_INFO_STRING);
MAX_INFO_STRING, !sv_highchars->int_val);
val = Info_ValueForKey (cl->userinfo, "name");
// 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);
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) {
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]);
MSG_WriteByte (&sv.reliable_datagram, svc_setinfo);
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
|| strcaseequal (key, "sky") // Q2/DarkPlaces
|| 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);
return 1;
}

View file

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