summaryrefslogtreecommitdiff
path: root/src/game/g_admin.c
diff options
context:
space:
mode:
authorChristopher Schwarz <lakitu7@gmail.com>2009-10-26 23:38:59 +0000
committerTim Angus <tim@ngus.net>2013-01-03 00:17:08 +0000
commit4f35f4be9d2bb86babe1570b8610279d04466fda (patch)
treedc69ff3f2488940e604a69fbde60d9e386a9553f /src/game/g_admin.c
parent66bd10ca6eaf423cbfcd265ebe3964440268e0f2 (diff)
* Fix several broken/segfaulting cases of the !setlevel command (Rezyn)
Diffstat (limited to 'src/game/g_admin.c')
-rw-r--r--src/game/g_admin.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/game/g_admin.c b/src/game/g_admin.c
index 7798d8c0..81f7d1e6 100644
--- a/src/game/g_admin.c
+++ b/src/game/g_admin.c
@@ -1191,28 +1191,39 @@ qboolean G_admin_setlevel( gentity_t *ent, int skiparg )
{
int id = atoi( testname );
if( id < MAX_CLIENTS )
+ {
vic = &g_entities[ id ];
- else if( id < na )
- for( i = 0, a = g_admin_admins; i < na; a = a->next );
+ if( !vic || !vic->client || vic->client->pers.connected == CON_DISCONNECTED )
+ {
+ ADMP( va( "^3!setlevel: ^7no player connected in slot %d\n", id ) );
+ return qfalse;
+ }
+ }
+ else if( id < na + MAX_CLIENTS )
+ for( i = 0, a = g_admin_admins; i < id - MAX_CLIENTS; i++, a = a->next );
else
{
- ADMP( va( "^3!setlevel: ^7%s not in range 1-%d\n", testname, na ) );
+ ADMP( va( "^3!setlevel: ^7%s not in range 1-%d\n",
+ testname, na + MAX_CLIENTS - 1 ) );
return qfalse;
}
}
else
G_SanitiseString( testname, name, sizeof( name ) );
- if( vic && vic->client && vic->client->pers.connected != CON_DISCONNECTED )
+ if( vic )
a = vic->client->pers.admin;
else if( !a )
{
- int matches = 0;
- for( a = g_admin_admins; a && matches < 2; a = a->next )
+ g_admin_admin_t *wa;
+ int matches = 0;
+
+ for( wa = g_admin_admins; wa && matches < 2; wa = wa->next )
{
- G_SanitiseString( a->name, testname, sizeof( testname ) );
+ G_SanitiseString( wa->name, testname, sizeof( testname ) );
if( strstr( testname, name ) )
{
+ a = wa;
matches++;
}
}