[quake3-commits] r2355 - trunk/code/game
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Sun Nov 18 16:55:41 EST 2012
Author: ztm
Date: 2012-11-18 16:55:40 -0500 (Sun, 18 Nov 2012)
New Revision: 2355
Modified:
trunk/code/game/g_cmds.c
Log:
Fix follow command to find clients whose name begins with a number.
Modified: trunk/code/game/g_cmds.c
===================================================================
--- trunk/code/game/g_cmds.c 2012-11-18 19:14:07 UTC (rev 2354)
+++ trunk/code/game/g_cmds.c 2012-11-18 21:55:40 UTC (rev 2355)
@@ -153,8 +153,34 @@
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
Returns a player number for either a number or name string
@@ -166,20 +192,15 @@
int idnum;
char cleanName[MAX_STRING_CHARS];
- // numeric values are just slot numbers
- if (s[0] >= '0' && s[0] <= '9') {
+ // numeric values could be slot numbers
+ if ( StringIsInteger( s ) ) {
idnum = atoi( s );
- if ( idnum < 0 || idnum >= level.maxclients ) {
- trap_SendServerCommand( to-g_entities, va("print \"Bad client slot: %i\n\"", idnum));
- return -1;
+ if ( idnum >= 0 && idnum < level.maxclients ) {
+ cl = &level.clients[idnum];
+ 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
More information about the quake3-commits
mailing list