diff --git a/include/QF/info.h b/include/QF/info.h index 7a03ba7ff..489ed65e0 100644 --- a/include/QF/info.h +++ b/include/QF/info.h @@ -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); 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); char *Info_MakeString (info_t *info, int (*filter)(const char *)); diff --git a/libs/util/info.c b/libs/util/info.c index d0a052065..381da0052 100644 --- a/libs/util/info.c +++ b/libs/util/info.c @@ -100,6 +100,7 @@ Info_SetValueForStarKey (info_t *info, const char *key, const char *value, int f info_key_t *k; int cursize; char *str; + byte *s, *d; if (strstr (key, "\\") || strstr (value, "\\")) { 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))) Sys_Error ("Info_SetValueForStarKey: out of memory"); - if (flags & 1) { - byte *s, *d; - for (d = s = str; *s; s++) - if ((*s & 127) >= 32 && (*s & 127) <=127) - *d++ = *s & 127; + for (d = s = str; *s; s++) { + if (flags & 1) { + *s &= 127; + if (*s < 32) + continue; + } if (flags & 2) - for (d = s = str; *s; s++) - *d++ = tolower (*s); - } else { - byte *s, *d; - for (d = s = str; *s; s++) - if (*s >= 13) - *d++ = *s; + *s = tolower (*s); + if (*s > 13) + *d++ = *s; } info->cursize += strlen (str) + 1; k->value = str; @@ -201,7 +199,7 @@ free_key (void *_k, void *unused) } info_t * -Info_ParseString (const char *s, int maxsize) +Info_ParseString (const char *s, int maxsize, int flags) { info_t *info; char *string = Hunk_TempAlloc (strlen (s) + 1); @@ -229,7 +227,7 @@ Info_ParseString (const char *s, int maxsize) } else { value = end = (char *)""; } - Info_SetValueForStarKey (info, key, value, 0); + Info_SetValueForStarKey (info, key, value, flags); key = end; } return info; diff --git a/qw/source/cl_main.c b/qw/source/cl_main.c index 5d58d9a26..14e0bf445 100644 --- a/qw/source/cl_main.c +++ b/qw/source/cl_main.c @@ -393,7 +393,7 @@ CL_ClearState (void) for (i = 0; i < UPDATE_BACKUP; i++) cl.frames[i].packet_entities.entities = cl_entities[i]; 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); @@ -582,7 +582,7 @@ CL_FullServerinfo_f (void) Con_DPrintf ("Cmd_Argv(1): '%s'\n", Cmd_Argv (1)); 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)); if ((p = Info_ValueForKey (cl.serverinfo, "*qf_version")) && *p) { @@ -1692,8 +1692,8 @@ Host_Init (void) pr_gametype = "quakeworld"; - cls.userinfo = Info_ParseString ("", MAX_INFO_STRING); - cl.serverinfo = Info_ParseString ("", MAX_INFO_STRING); + cls.userinfo = Info_ParseString ("", MAX_INFO_STRING, 0); + cl.serverinfo = Info_ParseString ("", MAX_INFO_STRING, 0); QFS_Init ("qw"); PI_Init (); diff --git a/qw/source/cl_parse.c b/qw/source/cl_parse.c index 4708dadfd..f5c1e91eb 100644 --- a/qw/source/cl_parse.c +++ b/qw/source/cl_parse.c @@ -1038,7 +1038,7 @@ CL_UpdateUserinfo (void) if (*info) { // a totally empty userinfo string should not be possible player->userid = uid; - player->userinfo = Info_ParseString (info, MAX_INFO_STRING); + player->userinfo = Info_ParseString (info, MAX_INFO_STRING, 0); CL_ProcessUserInfo (slot, player); } else { // the server dropped the client @@ -1067,7 +1067,7 @@ CL_SetInfo (void) Con_DPrintf ("SETINFO %s: %s=%s\n", player->name, key, value); 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, "team") << 1; diff --git a/qw/source/cl_slist.c b/qw/source/cl_slist.c index b00c5f2e9..188bd2e13 100644 --- a/qw/source/cl_slist.c +++ b/qw/source/cl_slist.c @@ -702,7 +702,7 @@ SL_CheckStatus (const char *cs_from, const char *cs_data) } if (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; tmp_desc = Info_ValueForKey (temp->status, "hostname"); if (tmp_desc[0] != '\0') { diff --git a/qw/source/sv_main.c b/qw/source/sv_main.c index 7a2ff8b52..09c3e6f07 100644 --- a/qw/source/sv_main.c +++ b/qw/source/sv_main.c @@ -751,7 +751,8 @@ SVC_DirectConnect (void) challenge = atoi (Cmd_Argv (3)); 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. if (!userinfo) { @@ -830,17 +831,7 @@ SVC_DirectConnect (void) newcl->userid = userid; - // works properly - 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; + newcl->userinfo = userinfo; // if there is already a slot for this ip, drop it for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) { @@ -2501,8 +2492,8 @@ SV_Init (void) SV_Init_Memory (); svs.maxclients = MAX_CLIENTS; - svs.info = Info_ParseString ("", MAX_SERVERINFO_STRING); - localinfo = Info_ParseString ("", 0); // unlimited + svs.info = Info_ParseString ("", MAX_SERVERINFO_STRING, 0); + localinfo = Info_ParseString ("", 0, 0); // unlimited SV_InitOperatorCommands (); SV_GIB_Init ();