Index: src/game/g_admin.c =================================================================== --- src/game/g_admin.c (revision 1034) +++ src/game/g_admin.c (working copy) @@ -282,20 +282,43 @@ gclient_t *client; char testName[ MAX_NAME_LENGTH ] = {""}; char name2[ MAX_NAME_LENGTH ] = {""}; + int alphaCount = 0; G_SanitiseName( name, name2 ); if( !Q_stricmp( name2, "UnnamedPlayer" ) ) return qtrue; + G_DecolorString( name, testName ); + if( isdigit( testName[ 0 ] ) ) + { + Q_strncpyz( err, "Names cannot begin with numbers", len ); + return qfalse; + } + + for( i = 0; testName[ i ]; i++) + { + if( isalpha( testName[ i ] ) ) + alphaCount++; + else if( testName[ i ] == '/' ) + if( testName[ i + 1 ] == '/' || testName[ i + 1 ] == '*' ) + { + Q_strncpyz( err, "Names cannot contain '//' or '/*'", len ); + return qfalse; + } + } + + if( alphaCount == 0 ) + { + Q_strncpyz( err, "Names must contain letters", len ); + return qfalse; + } + for( i = 0; i < level.maxclients; i++ ) { client = &level.clients[ i ]; - if( client->pers.connected != CON_CONNECTING - && client->pers.connected != CON_CONNECTED ) - { + if( client->pers.connected != CON_DISCONNECTED ) continue; - } // can rename ones self to the same name using different colors if( i == ( ent - g_entities ) ) @@ -1741,14 +1764,14 @@ if( g_admin_namelog[ i ]->slot == -1 ) continue; - if( !Q_stricmp( va( "%d", g_admin_namelog[ i ]->slot ), s2 ) ) + if( !Q_stricmp( va( "%d", g_admin_namelog[ i ]->slot ), search ) ) { logmatches = 1; logmatch = i; exactmatch = qtrue; break; } - } + } for( i = 0; !exactmatch && i < MAX_ADMIN_NAMELOGS && g_admin_namelog[ i ]; @@ -1758,7 +1781,7 @@ if( g_admin_namelog[ i ]->banned ) continue; - if( !Q_stricmp( g_admin_namelog[ i ]->ip, s2 ) ) + if( !Q_stricmp( g_admin_namelog[ i ]->ip, search ) ) { logmatches = 1; logmatch = i; Index: src/game/g_cmds.c =================================================================== --- src/game/g_cmds.c (revision 1034) +++ src/game/g_cmds.c (working copy) @@ -27,47 +27,23 @@ ================== G_SanitiseName -Remove case and control characters from a player name +Remove non-alphanumeric characters from a player name ================== */ void G_SanitiseName( char *in, char *out ) { - qboolean skip = qtrue; - int spaces = 0; - while( *in ) { - // strip leading white space - if( *in == ' ' ) + if( *in == 27 || Q_IsColorString( in ) ) { - if( skip ) - { - in++; - continue; - } - spaces++; - } - else - { - spaces = 0; - skip = qfalse; - } - - if( *in == 27 || *in == '^' ) - { in += 2; // skip color code continue; } - if( *in < 32 ) - { - in++; - continue; - } - - *out++ = tolower( *in++ ); + if( isalnum( *in ) ) + *out++ = tolower( *in ); + in++; } - out -= spaces; *out = 0; }