back port the info key fix from 0.5. This should take care of the team

kicking.
This commit is contained in:
Bill Currie 2001-08-12 03:45:37 +00:00
parent 6714119351
commit f4dc013a3d
14 changed files with 53 additions and 47 deletions

View file

@ -45,8 +45,8 @@ qboolean Info_FilterForKey (const char *key);
void Info_Print (char *s);
void Info_RemoveKey (char *s, char *key);
void Info_RemovePrefixedKeys (char *start, char prefix);
void Info_SetValueForKey (char *s, char *key, char *value, size_t maxsize);
void Info_SetValueForStarKey (char *s, char *key, char *value, size_t maxsize);
void Info_SetValueForKey (char *s, char *key, char *value, size_t maxsize, int flags);
void Info_SetValueForStarKey (char *s, char *key, char *value, size_t maxsize, int flags);
char *Info_ValueForKey (char *s, char *key);
qboolean Info_Validate (char *s);

View file

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

View file

@ -31,6 +31,7 @@
#endif
#include "client.h"
#include "compat.h"
#include "cvar.h"
#include "msg.h"
#include "va.h"
@ -40,7 +41,9 @@ 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

@ -651,11 +651,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", QSG_VERSION,
MAX_INFO_STRING);
MAX_INFO_STRING, 0);
Con_Printf ("QuakeForge server detected\n");
}
@ -717,7 +717,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));
}
}
@ -742,7 +744,8 @@ 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 ();
}
@ -1143,14 +1146,14 @@ 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);
#ifdef PACKET_LOGGING
Net_Log_Init();
#endif

View file

@ -1034,7 +1034,8 @@ 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);
}
@ -1055,7 +1056,8 @@ 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,
(!strequal (key, "name"))| (strequal (key, "team") << 1));
}
/*

View file

@ -216,10 +216,10 @@ Info_RemovePrefixedKeys (char *start, char prefix)
void
Info_SetValueForStarKey (char *s, char *key, char *value, size_t maxsize)
Info_SetValueForStarKey (char *s, char *key, char *value, size_t maxsize, int flags)
{
char newstr[1024], *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");
@ -258,17 +258,15 @@ Info_SetValueForStarKey (char *s, char *key, char *value, size_t maxsize)
// 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)
@ -278,14 +276,14 @@ Info_SetValueForStarKey (char *s, char *key, char *value, size_t maxsize)
}
void
Info_SetValueForKey (char *s, char *key, char *value, size_t maxsize)
Info_SetValueForKey (char *s, char *key, 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

@ -109,7 +109,7 @@ Mod_LoadAliasModel (model_t *mod, void *buffer)
Info_SetValueForKey (cls.userinfo,
!strcmp (loadmodel->name,
"progs/player.mdl") ? pmodel_name :
emodel_name, st, MAX_INFO_STRING);
emodel_name, st, MAX_INFO_STRING, 0);
if (cls.state >= ca_connected) {
MSG_WriteByte (&cls.netchan.message, clc_stringcmd);

View file

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

View file

@ -555,7 +555,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));
@ -593,7 +593,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);
}
@ -645,7 +645,7 @@ 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);
}
/*
@ -804,7 +804,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 (char *key, char *value);
extern cvar_t *sv_highchars;
/*
Cvar_Info
@ -62,10 +60,10 @@ Cvar_Info (cvar_t *var)
}
*p = 0;
Info_SetValueForKey (svs.info, var->name, info,
MAX_SERVERINFO_STRING);
MAX_SERVERINFO_STRING, !sv_highchars->int_val);
} else
Info_SetValueForKey (svs.info, var->name, var->string,
MAX_SERVERINFO_STRING);
MAX_SERVERINFO_STRING, !sv_highchars->int_val);
SV_SendServerInfoChange (var->name, var->string);
// SV_BroadcastCommand ("fullserverinfo \"%s\"\n", svs.info);

View file

@ -336,7 +336,7 @@ SV_SpawnServer (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 = Hunk_AllocName (MAX_EDICTS * sv_pr_state.pr_edict_size, "edicts");
@ -422,6 +422,6 @@ SV_SpawnServer (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

@ -714,7 +714,7 @@ 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");
@ -1402,10 +1402,10 @@ SV_CheckVars (void)
Con_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);
}
/*
@ -1606,13 +1606,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", QSG_VERSION,
MAX_SERVERINFO_STRING);
MAX_SERVERINFO_STRING, !sv_highchars->int_val);
// init fraglog stuff
svs.logsequence = 1;
@ -1733,12 +1733,12 @@ 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
@ -1763,7 +1763,7 @@ SV_ExtractFromUserinfo (client_t *cl)
snprintf (newname, sizeof (newname), "(%d)%-.40s", dupc++, p);
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 being too long), drop the client to prevent an infinite loop

View file

@ -124,7 +124,7 @@ ED_Parse_Extra_Fields (progs_t *pr, char *key, char *value)
|| strcaseequal (key, "skyname")
|| strcaseequal (key, "qlsky")) {
Info_SetValueForKey (svs.info, "skybox",
"1", MAX_SERVERINFO_STRING);
"1", MAX_SERVERINFO_STRING, !sv_highchars->int_val);
Cvar_Set (r_skyname, value);
return 1;
}

View file

@ -1120,7 +1120,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);
// name is extracted below in ExtractFromUserInfo
// strncpy (host_client->name, Info_ValueForKey (host_client->userinfo, "name")
// , sizeof(host_client->name)-1);