summaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
authorTony J. White <tjw@tjw.org>2007-01-03 18:04:57 +0000
committerTony J. White <tjw@tjw.org>2007-01-03 18:04:57 +0000
commitf57b74635da93485851fb2e722bd765194c899a9 (patch)
treeb1561a8e4824452d5b7352f40aabf9573228017a /src/game
parentbfc7853860c7c40d1c11d34b2c5f92b1a2428229 (diff)
* (bug 2996) better support for using "!" commands when g_admin is
disabled. * (bug 2973) account for the *BUILTIN* layout in the count returned by G_LayoutList() * !readconfig now clears all g_admin data properly even if there is an error reading or no g_admin data file is defined
Diffstat (limited to 'src/game')
-rw-r--r--src/game/g_admin.c39
-rw-r--r--src/game/g_buildable.c2
-rw-r--r--src/game/g_cmds.c4
3 files changed, 29 insertions, 16 deletions
diff --git a/src/game/g_admin.c b/src/game/g_admin.c
index 12ba721c..1af65c55 100644
--- a/src/game/g_admin.c
+++ b/src/game/g_admin.c
@@ -300,7 +300,7 @@ qboolean G_admin_name_check( gentity_t *ent, char *name, char *err, int len )
}
}
- if( !g_admin.string[ 0 ] || !g_adminNameProtect.string[ 0 ] )
+ if( !g_adminNameProtect.string[ 0 ] )
return qtrue;
for( i = 0; i < MAX_ADMIN_ADMINS && g_admin_admins[ i ]; i++ )
@@ -401,8 +401,9 @@ static void admin_writeconfig( void )
len = trap_FS_FOpenFile( g_admin.string, &f, FS_WRITE );
if( len < 0 )
{
- G_Printf( "admin_writeconfig: could not open %s\n",
+ G_Printf( "admin_writeconfig: could not open g_admin file \"%s\"\n",
g_admin.string );
+ return;
}
for( i = 0; i < MAX_ADMIN_LEVELS && g_admin_levels[ i ]; i++ )
{
@@ -1063,10 +1064,13 @@ qboolean G_admin_readconfig( gentity_t *ent, int skiparg )
qboolean level_open, admin_open, ban_open, command_open;
char levels[ MAX_STRING_CHARS ] = {""};
+ G_admin_cleanup();
+
if( !g_admin.string[ 0 ] )
{
ADMP( "^3!readconfig: g_admin is not set, not loading configuration "
"from a file\n" );
+ admin_default_levels();
return qfalse;
}
@@ -1084,8 +1088,6 @@ qboolean G_admin_readconfig( gentity_t *ent, int skiparg )
*( cnf + len ) = '\0';
trap_FS_FCloseFile( f );
- G_admin_cleanup();
-
t = COM_Parse( &cnf );
level_open = admin_open = ban_open = command_open = qfalse;
while( *t )
@@ -1512,7 +1514,12 @@ qboolean G_admin_setlevel( gentity_t *ent, int skiparg )
adminname, l, ( ent ) ? ent->client->pers.netname : "console" ) );
if( vic )
vic->client->pers.adminLevel = l;
- admin_writeconfig();
+
+ if( !g_admin.string[ 0 ] )
+ ADMP( "^3!setlevel: ^7WARNING g_admin not set, not saving admin record "
+ "to a file\n" );
+ else
+ admin_writeconfig();
return qtrue;
}
@@ -1565,7 +1572,6 @@ static qboolean admin_create_ban( gentity_t *ent,
return qfalse;
}
g_admin_bans[ i ] = b;
- admin_writeconfig();
return qtrue;
}
@@ -1608,6 +1614,8 @@ qboolean G_admin_kick( gentity_t *ent, int skiparg )
vic->client->pers.guid,
vic->client->pers.ip, g_adminTempBan.integer,
"automatic temp ban created by kick" );
+ if( g_admin.string[ 0 ] )
+ admin_writeconfig();
}
trap_SendServerCommand( pids[ 0 ],
@@ -1773,6 +1781,10 @@ qboolean G_admin_ban( gentity_t *ent, int skiparg )
g_admin_namelog[ logmatch ]->guid,
g_admin_namelog[ logmatch ]->ip,
seconds, reason );
+ if( !g_admin.string[ 0 ] )
+ ADMP( "^3!ban: ^7WARNING g_admin not set, not saving ban to a file\n" );
+ else
+ admin_writeconfig();
if(g_admin_namelog[ logmatch ]->slot == -1 )
{
@@ -1831,7 +1843,8 @@ qboolean G_admin_unban( gentity_t *ent, int skiparg )
bnum,
g_admin_bans[ bnum - 1 ]->name,
( ent ) ? ent->client->pers.netname : "console" ) );
- admin_writeconfig();
+ if( g_admin.string[ 0 ] )
+ admin_writeconfig();
return qtrue;
}
@@ -2010,6 +2023,11 @@ qboolean G_admin_listadmins( gentity_t *ent, int skiparg )
continue;
found++;
}
+ if( !found )
+ {
+ ADMP( "^3!listadmins: ^7no admins defined\n" );
+ return qfalse;
+ }
if( G_SayArgc() == 2 + skiparg )
{
@@ -2037,7 +2055,7 @@ qboolean G_admin_listadmins( gentity_t *ent, int skiparg )
if( start >= found )
{
- ADMP( va( "^3!listadmins: ^7there are only %d admins\n", found ) );
+ ADMP( va( "^3!listadmins: ^7listing %d admins\n", found ) );
return qfalse;
}
@@ -2082,11 +2100,6 @@ qboolean G_admin_listlayouts( gentity_t *ent, int skiparg )
trap_Cvar_VariableStringBuffer( "mapname", map, sizeof( map ) );
count = G_LayoutList( map, list, sizeof( list ) );
- if( !count )
- {
- ADMP( va( "^3!listlayouts:^7 ^7no layouts found for map '%s'\n", map ) );
- return qfalse;
- }
ADMBP_begin( );
ADMBP( va( "^3!listlayouts:^7 %d layouts found for '%s':\n", count, map ) );
s = &list[ 0 ];
diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c
index 1737b73c..7d02ec15 100644
--- a/src/game/g_buildable.c
+++ b/src/game/g_buildable.c
@@ -3410,7 +3410,7 @@ int G_LayoutList( const char *map, char *list, int len )
count, numFiles, map );
}
Q_strncpyz( list, layouts, len );
- return count;
+ return count + 1;
}
/*
diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c
index f17236d5..b7ca16d7 100644
--- a/src/game/g_cmds.c
+++ b/src/game/g_cmds.c
@@ -886,7 +886,7 @@ void G_Say( gentity_t *ent, gentity_t *target, int mode, const char *chatText )
G_SayTo( ent, other, mode, color, name, text );
}
- if( g_admin.string[ 0 ] && g_adminParseSay.integer )
+ if( g_adminParseSay.integer )
{
G_admin_cmd_check ( ent, qtrue );
}
@@ -2712,7 +2712,7 @@ void ClientCommand( int clientNum )
return;
}
- if( g_admin.string[ 0 ] && G_admin_cmd_check( ent, qfalse ) )
+ if( G_admin_cmd_check( ent, qfalse ) )
return;
// ignore all other commands when at intermission