aboutsummaryrefslogtreecommitdiffstats
path: root/code
diff options
context:
space:
mode:
authorthilo <thilo@edf5b092-35ff-0310-97b2-ce42778d08ea>2006-05-02 21:20:07 +0000
committerthilo <thilo@edf5b092-35ff-0310-97b2-ce42778d08ea>2006-05-02 21:20:07 +0000
commit01c266dda2a707782bc6c2d58c7c8ea3f19803ba (patch)
tree7e5334ad2b424121204f0f3e0a15282195188a7b /code
parent1c7b9a2a697aa2e1727cc5328e64c68a6b20c093 (diff)
downloadioquake3-aero-01c266dda2a707782bc6c2d58c7c8ea3f19803ba.tar.gz
ioquake3-aero-01c266dda2a707782bc6c2d58c7c8ea3f19803ba.zip
- Replaced SV_GetPlayerByName with SV_GetPlayerByHandle that supports lookup of client_t structures by playernum, too.
That means the ban and kick commands will now accept the playernum - as seen in the status command - as argument. git-svn-id: svn://svn.icculus.org/quake3/trunk@737 edf5b092-35ff-0310-97b2-ce42778d08ea
Diffstat (limited to 'code')
-rw-r--r--code/server/sv_ccmds.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/code/server/sv_ccmds.c b/code/server/sv_ccmds.c
index 7f9ebf1..6d83b1d 100644
--- a/code/server/sv_ccmds.c
+++ b/code/server/sv_ccmds.c
@@ -34,12 +34,12 @@ These commands can only be entered from stdin or by a remote operator datagram
/*
==================
-SV_GetPlayerByName
+SV_GetPlayerByHandle
-Returns the player with name from Cmd_Argv(1)
+Returns the player with player id or name from Cmd_Argv(1)
==================
*/
-static client_t *SV_GetPlayerByName( void ) {
+static client_t *SV_GetPlayerByHandle( void ) {
client_t *cl;
int i;
char *s;
@@ -57,6 +57,23 @@ static client_t *SV_GetPlayerByName( void ) {
s = Cmd_Argv(1);
+ // Check whether this is a numeric player handle
+ for(i = 0; s[i] >= '0' && s[i] <= '9'; i++);
+
+ if(!s[i])
+ {
+ int plid = atoi(s);
+
+ // Check for numeric playerid match
+ if(plid >= 0 && plid < sv_maxclients->integer)
+ {
+ cl = &svs.clients[plid];
+
+ if(cl->state)
+ return cl;
+ }
+ }
+
// check for a name match
for ( i=0, cl=svs.clients ; i < sv_maxclients->integer ; i++,cl++ ) {
if ( !cl->state ) {
@@ -343,7 +360,7 @@ static void SV_Kick_f( void ) {
return;
}
- cl = SV_GetPlayerByName();
+ cl = SV_GetPlayerByHandle();
if ( !cl ) {
if ( !Q_stricmp(Cmd_Argv(1), "all") ) {
for ( i=0, cl=svs.clients ; i < sv_maxclients->integer ; i++,cl++ ) {
@@ -402,7 +419,7 @@ static void SV_Ban_f( void ) {
return;
}
- cl = SV_GetPlayerByName();
+ cl = SV_GetPlayerByHandle();
if (!cl) {
return;
@@ -681,7 +698,7 @@ static void SV_DumpUser_f( void ) {
return;
}
- cl = SV_GetPlayerByName();
+ cl = SV_GetPlayerByHandle();
if ( !cl ) {
return;
}