From 40e4a2e5c43aef11b7b8212e1069840dca841198 Mon Sep 17 00:00:00 2001 From: Ludwig Nussel Date: Fri, 8 May 2009 09:31:26 +0000 Subject: [PATCH] fix name compare in 'follow' command (#4013) --- code/game/g_cmds.c | 32 ++++---------------------------- 1 file changed, 4 insertions(+), 28 deletions(-) diff --git a/code/game/g_cmds.c b/code/game/g_cmds.c index 1ecb0cb1..2569b3b8 100644 --- a/code/game/g_cmds.c +++ b/code/game/g_cmds.c @@ -151,29 +151,6 @@ char *ConcatArgs( int start ) { return line; } -/* -================== -SanitizeString - -Remove case and control characters -================== -*/ -void SanitizeString( char *in, char *out ) { - while ( *in ) { - if ( *in == 27 ) { - in += 2; // skip color code - continue; - } - if ( *in < 32 ) { - in++; - continue; - } - *out++ = tolower( *in++ ); - } - - *out = 0; -} - /* ================== ClientNumberFromString @@ -185,8 +162,7 @@ Returns -1 if invalid int ClientNumberFromString( gentity_t *to, char *s ) { gclient_t *cl; int idnum; - char s2[MAX_STRING_CHARS]; - char n2[MAX_STRING_CHARS]; + char cleanName[MAX_STRING_CHARS]; // numeric values are just slot numbers if (s[0] >= '0' && s[0] <= '9') { @@ -205,13 +181,13 @@ int ClientNumberFromString( gentity_t *to, char *s ) { } // check for a name match - SanitizeString( s, s2 ); for ( idnum=0,cl=level.clients ; idnum < level.maxclients ; idnum++,cl++ ) { if ( cl->pers.connected != CON_CONNECTED ) { continue; } - SanitizeString( cl->pers.netname, n2 ); - if ( !strcmp( n2, s2 ) ) { + Q_strncpyz(cleanName, cl->pers.netname, sizeof(cleanName)); + Q_CleanStr(cleanName); + if ( !Q_stricmp( cleanName, s ) ) { return idnum; } }