mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-06 15:51:25 +00:00
fix a snafu in SVC_DirectConnect related to info strings, make
Info_ParseString take (and pass on to Info_SetValueForStarKey) a flags arg and simplify the flags handing in Info_SetValueForStarKey.
This commit is contained in:
parent
b6a3bc8d1c
commit
d93fceea38
6 changed files with 25 additions and 36 deletions
|
@ -55,7 +55,7 @@ void Info_SetValueForKey (info_t *info, const char *key, const char *value, int
|
||||||
void Info_SetValueForStarKey (info_t *info, const char *key, const char *value, int flags);
|
void Info_SetValueForStarKey (info_t *info, const char *key, const char *value, int flags);
|
||||||
const char *Info_ValueForKey (info_t *info, const char *key);
|
const char *Info_ValueForKey (info_t *info, const char *key);
|
||||||
|
|
||||||
info_t *Info_ParseString (const char *s, int maxsize);
|
info_t *Info_ParseString (const char *s, int maxsize, int flags);
|
||||||
void Info_Destroy (info_t *info);
|
void Info_Destroy (info_t *info);
|
||||||
char *Info_MakeString (info_t *info, int (*filter)(const char *));
|
char *Info_MakeString (info_t *info, int (*filter)(const char *));
|
||||||
|
|
||||||
|
|
|
@ -100,6 +100,7 @@ Info_SetValueForStarKey (info_t *info, const char *key, const char *value, int f
|
||||||
info_key_t *k;
|
info_key_t *k;
|
||||||
int cursize;
|
int cursize;
|
||||||
char *str;
|
char *str;
|
||||||
|
byte *s, *d;
|
||||||
|
|
||||||
if (strstr (key, "\\") || strstr (value, "\\")) {
|
if (strstr (key, "\\") || strstr (value, "\\")) {
|
||||||
Sys_Printf ("Can't use keys or values with a \\\n");
|
Sys_Printf ("Can't use keys or values with a \\\n");
|
||||||
|
@ -141,19 +142,16 @@ Info_SetValueForStarKey (info_t *info, const char *key, const char *value, int f
|
||||||
}
|
}
|
||||||
if (!(str = strdup (value)))
|
if (!(str = strdup (value)))
|
||||||
Sys_Error ("Info_SetValueForStarKey: out of memory");
|
Sys_Error ("Info_SetValueForStarKey: out of memory");
|
||||||
if (flags & 1) {
|
for (d = s = str; *s; s++) {
|
||||||
byte *s, *d;
|
if (flags & 1) {
|
||||||
for (d = s = str; *s; s++)
|
*s &= 127;
|
||||||
if ((*s & 127) >= 32 && (*s & 127) <=127)
|
if (*s < 32)
|
||||||
*d++ = *s & 127;
|
continue;
|
||||||
|
}
|
||||||
if (flags & 2)
|
if (flags & 2)
|
||||||
for (d = s = str; *s; s++)
|
*s = tolower (*s);
|
||||||
*d++ = tolower (*s);
|
if (*s > 13)
|
||||||
} else {
|
*d++ = *s;
|
||||||
byte *s, *d;
|
|
||||||
for (d = s = str; *s; s++)
|
|
||||||
if (*s >= 13)
|
|
||||||
*d++ = *s;
|
|
||||||
}
|
}
|
||||||
info->cursize += strlen (str) + 1;
|
info->cursize += strlen (str) + 1;
|
||||||
k->value = str;
|
k->value = str;
|
||||||
|
@ -201,7 +199,7 @@ free_key (void *_k, void *unused)
|
||||||
}
|
}
|
||||||
|
|
||||||
info_t *
|
info_t *
|
||||||
Info_ParseString (const char *s, int maxsize)
|
Info_ParseString (const char *s, int maxsize, int flags)
|
||||||
{
|
{
|
||||||
info_t *info;
|
info_t *info;
|
||||||
char *string = Hunk_TempAlloc (strlen (s) + 1);
|
char *string = Hunk_TempAlloc (strlen (s) + 1);
|
||||||
|
@ -229,7 +227,7 @@ Info_ParseString (const char *s, int maxsize)
|
||||||
} else {
|
} else {
|
||||||
value = end = (char *)"";
|
value = end = (char *)"";
|
||||||
}
|
}
|
||||||
Info_SetValueForStarKey (info, key, value, 0);
|
Info_SetValueForStarKey (info, key, value, flags);
|
||||||
key = end;
|
key = end;
|
||||||
}
|
}
|
||||||
return info;
|
return info;
|
||||||
|
|
|
@ -393,7 +393,7 @@ CL_ClearState (void)
|
||||||
for (i = 0; i < UPDATE_BACKUP; i++)
|
for (i = 0; i < UPDATE_BACKUP; i++)
|
||||||
cl.frames[i].packet_entities.entities = cl_entities[i];
|
cl.frames[i].packet_entities.entities = cl_entities[i];
|
||||||
memset (cl_entities, 0, sizeof (cl_entities));
|
memset (cl_entities, 0, sizeof (cl_entities));
|
||||||
cl.serverinfo = Info_ParseString ("", MAX_INFO_STRING);
|
cl.serverinfo = Info_ParseString ("", MAX_INFO_STRING, 0);
|
||||||
|
|
||||||
CL_Init_Entity (&cl.viewent);
|
CL_Init_Entity (&cl.viewent);
|
||||||
|
|
||||||
|
@ -582,7 +582,7 @@ CL_FullServerinfo_f (void)
|
||||||
|
|
||||||
Con_DPrintf ("Cmd_Argv(1): '%s'\n", Cmd_Argv (1));
|
Con_DPrintf ("Cmd_Argv(1): '%s'\n", Cmd_Argv (1));
|
||||||
Info_Destroy (cl.serverinfo);
|
Info_Destroy (cl.serverinfo);
|
||||||
cl.serverinfo = Info_ParseString (Cmd_Argv (1), MAX_SERVERINFO_STRING);
|
cl.serverinfo = Info_ParseString (Cmd_Argv (1), MAX_SERVERINFO_STRING, 0);
|
||||||
Con_DPrintf ("cl.serverinfo: '%s'\n", Info_MakeString (cl.serverinfo, 0));
|
Con_DPrintf ("cl.serverinfo: '%s'\n", Info_MakeString (cl.serverinfo, 0));
|
||||||
|
|
||||||
if ((p = Info_ValueForKey (cl.serverinfo, "*qf_version")) && *p) {
|
if ((p = Info_ValueForKey (cl.serverinfo, "*qf_version")) && *p) {
|
||||||
|
@ -1692,8 +1692,8 @@ Host_Init (void)
|
||||||
|
|
||||||
pr_gametype = "quakeworld";
|
pr_gametype = "quakeworld";
|
||||||
|
|
||||||
cls.userinfo = Info_ParseString ("", MAX_INFO_STRING);
|
cls.userinfo = Info_ParseString ("", MAX_INFO_STRING, 0);
|
||||||
cl.serverinfo = Info_ParseString ("", MAX_INFO_STRING);
|
cl.serverinfo = Info_ParseString ("", MAX_INFO_STRING, 0);
|
||||||
|
|
||||||
QFS_Init ("qw");
|
QFS_Init ("qw");
|
||||||
PI_Init ();
|
PI_Init ();
|
||||||
|
|
|
@ -1038,7 +1038,7 @@ CL_UpdateUserinfo (void)
|
||||||
if (*info) {
|
if (*info) {
|
||||||
// a totally empty userinfo string should not be possible
|
// a totally empty userinfo string should not be possible
|
||||||
player->userid = uid;
|
player->userid = uid;
|
||||||
player->userinfo = Info_ParseString (info, MAX_INFO_STRING);
|
player->userinfo = Info_ParseString (info, MAX_INFO_STRING, 0);
|
||||||
CL_ProcessUserInfo (slot, player);
|
CL_ProcessUserInfo (slot, player);
|
||||||
} else {
|
} else {
|
||||||
// the server dropped the client
|
// the server dropped the client
|
||||||
|
@ -1067,7 +1067,7 @@ 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);
|
||||||
|
|
||||||
if (!player->userinfo)
|
if (!player->userinfo)
|
||||||
player->userinfo = Info_ParseString ("", MAX_INFO_STRING);
|
player->userinfo = Info_ParseString ("", MAX_INFO_STRING, 0);
|
||||||
|
|
||||||
flags = !strequal (key, "name");
|
flags = !strequal (key, "name");
|
||||||
flags |= strequal (key, "team") << 1;
|
flags |= strequal (key, "team") << 1;
|
||||||
|
|
|
@ -702,7 +702,7 @@ SL_CheckStatus (const char *cs_from, const char *cs_data)
|
||||||
}
|
}
|
||||||
if (temp->status)
|
if (temp->status)
|
||||||
Info_Destroy (temp->status);
|
Info_Destroy (temp->status);
|
||||||
temp->status = Info_ParseString (cs_data, strlen (data));
|
temp->status = Info_ParseString (cs_data, strlen (data), 0);
|
||||||
temp->waitstatus = 0;
|
temp->waitstatus = 0;
|
||||||
tmp_desc = Info_ValueForKey (temp->status, "hostname");
|
tmp_desc = Info_ValueForKey (temp->status, "hostname");
|
||||||
if (tmp_desc[0] != '\0') {
|
if (tmp_desc[0] != '\0') {
|
||||||
|
|
|
@ -751,7 +751,8 @@ SVC_DirectConnect (void)
|
||||||
challenge = atoi (Cmd_Argv (3));
|
challenge = atoi (Cmd_Argv (3));
|
||||||
|
|
||||||
if (strlen (Cmd_Argv (4)) < MAX_INFO_STRING)
|
if (strlen (Cmd_Argv (4)) < MAX_INFO_STRING)
|
||||||
userinfo = Info_ParseString (Cmd_Argv (4), 1023);
|
userinfo = Info_ParseString (Cmd_Argv (4), 1023,
|
||||||
|
!sv_highchars->int_val);
|
||||||
|
|
||||||
// Validate the userinfo string.
|
// Validate the userinfo string.
|
||||||
if (!userinfo) {
|
if (!userinfo) {
|
||||||
|
@ -830,17 +831,7 @@ SVC_DirectConnect (void)
|
||||||
|
|
||||||
newcl->userid = userid;
|
newcl->userid = userid;
|
||||||
|
|
||||||
// works properly
|
newcl->userinfo = userinfo;
|
||||||
if (!sv_highchars->int_val) {
|
|
||||||
byte *p, *q;
|
|
||||||
|
|
||||||
for (p = (byte *) newcl->userinfo, q = (byte *) userinfo;
|
|
||||||
*q && p < (byte *) newcl->userinfo + sizeof (newcl->userinfo) - 1;
|
|
||||||
q++)
|
|
||||||
if (*q > 31 && *q <= 127)
|
|
||||||
*p++ = *q;
|
|
||||||
} else
|
|
||||||
newcl->userinfo = userinfo;
|
|
||||||
|
|
||||||
// if there is already a slot for this ip, drop it
|
// if there is already a slot for this ip, drop it
|
||||||
for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) {
|
for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) {
|
||||||
|
@ -2501,8 +2492,8 @@ SV_Init (void)
|
||||||
SV_Init_Memory ();
|
SV_Init_Memory ();
|
||||||
|
|
||||||
svs.maxclients = MAX_CLIENTS;
|
svs.maxclients = MAX_CLIENTS;
|
||||||
svs.info = Info_ParseString ("", MAX_SERVERINFO_STRING);
|
svs.info = Info_ParseString ("", MAX_SERVERINFO_STRING, 0);
|
||||||
localinfo = Info_ParseString ("", 0); // unlimited
|
localinfo = Info_ParseString ("", 0, 0); // unlimited
|
||||||
SV_InitOperatorCommands ();
|
SV_InitOperatorCommands ();
|
||||||
SV_GIB_Init ();
|
SV_GIB_Init ();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue