Fix follow command to find clients whose name begins with a number.

This commit is contained in:
Zack Middleton 2012-11-18 21:55:40 +00:00
parent f13a87daad
commit 1cdb3b33e7

View file

@ -153,6 +153,32 @@ char *ConcatArgs( int start ) {
return line; return line;
} }
/*
==================
StringIsInteger
==================
*/
qboolean StringIsInteger( const char * s ) {
int i;
int len;
qboolean foundDigit;
len = strlen( s );
foundDigit = qfalse;
for ( i=0 ; i < len ; i++ ) {
if ( !isdigit( s[i] ) ) {
return qfalse;
}
foundDigit = qtrue;
}
return foundDigit;
}
/* /*
================== ==================
ClientNumberFromString ClientNumberFromString
@ -166,20 +192,15 @@ int ClientNumberFromString( gentity_t *to, char *s ) {
int idnum; int idnum;
char cleanName[MAX_STRING_CHARS]; char cleanName[MAX_STRING_CHARS];
// numeric values are just slot numbers // numeric values could be slot numbers
if (s[0] >= '0' && s[0] <= '9') { if ( StringIsInteger( s ) ) {
idnum = atoi( s ); idnum = atoi( s );
if ( idnum < 0 || idnum >= level.maxclients ) { if ( idnum >= 0 && idnum < level.maxclients ) {
trap_SendServerCommand( to-g_entities, va("print \"Bad client slot: %i\n\"", idnum)); cl = &level.clients[idnum];
return -1; if ( cl->pers.connected == CON_CONNECTED ) {
return idnum;
}
} }
cl = &level.clients[idnum];
if ( cl->pers.connected != CON_CONNECTED ) {
trap_SendServerCommand( to-g_entities, va("print \"Client %i is not active\n\"", idnum));
return -1;
}
return idnum;
} }
// check for a name match // check for a name match