diff options
author | M. Kristall <mkpdev@gmail.com> | 2009-10-03 12:02:28 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2013-01-03 00:15:38 +0000 |
commit | a2abdae1179414204035003451b5a10746b46d75 (patch) | |
tree | d5ff9046a1ad6462aee4ab0b3ad31dd5799983ee /src/game/g_admin.c | |
parent | dc94850a57da6e2eba3d0dfcb57265c883438d92 (diff) |
* (bug 2965) Strip colour codes from log messages (Ben Millwood)
* (bug 3596) Buying a battlesuit allows player to pass through some map geometry
(/dev/humancontroller)
* (bug 3679) Remove redundant stage trigger checks (Chris "Lakitu7" Schwartz)
* (bug 3761) selling all upgrades removes energy ammo (/dev/humancontroller)
* Remove some duplicate code
* !showbans did not properly show all valid bans when some bans had expired
* Log renames between ClientConnect and ClientBegin
Diffstat (limited to 'src/game/g_admin.c')
-rw-r--r-- | src/game/g_admin.c | 54 |
1 files changed, 35 insertions, 19 deletions
diff --git a/src/game/g_admin.c b/src/game/g_admin.c index 36a873b2..b7aae83e 100644 --- a/src/game/g_admin.c +++ b/src/game/g_admin.c @@ -2348,6 +2348,7 @@ qboolean G_admin_listplayers( gentity_t *ent, int skiparg ) qboolean G_admin_showbans( gentity_t *ent, int skiparg ) { int i, found = 0; + int max = 0, count; int t; char duration[ 32 ]; char name_fmt[ 32 ] = { "%s" }; @@ -2372,48 +2373,66 @@ qboolean G_admin_showbans( gentity_t *ent, int skiparg ) continue; } found++; + max = i; } - if( G_SayArgc() < 3 + skiparg ) + if( G_SayArgc() == 2 + skiparg ) { G_SayArgv( 1 + skiparg, skip, sizeof( skip ) ); start = atoi( skip ); // showbans 1 means start with ban 0 if( start > 0 ) - start -= 1; + start--; else if( start < 0 ) - start = found + start; + { + for( i = max, count = 0; i > 0 && count < -start; i-- ) + { + if( g_admin_bans[ i ]->expires == 0 || + ( g_admin_bans[ i ]->expires - t ) > 0 ) + count++; + } + + start = i; + } } if( start >= MAX_ADMIN_BANS || start < 0 ) start = 0; - for( i = start; i < MAX_ADMIN_BANS && g_admin_bans[ i ] && - ( i - start ) < MAX_ADMIN_SHOWBANS; i++ ) + for( i = start, count = 0; i < MAX_ADMIN_BANS && g_admin_bans[ i ] && + count < MAX_ADMIN_SHOWBANS; i++ ) { + if( g_admin_bans[ i ]->expires != 0 && + ( g_admin_bans[ i ]->expires - t ) < 1 ) + continue; + + count++; + G_DecolorString( g_admin_bans[ i ]->name, n1, sizeof( n1 ) ); G_DecolorString( g_admin_bans[ i ]->banner, n2, sizeof( n2 ) ); + if( strlen( n1 ) > max_name ) - { max_name = strlen( n1 ); - } + if( strlen( n2 ) > max_banner ) max_banner = strlen( n2 ); } - if( start >= found ) + if( start > max ) { - ADMP( va( "^3!showbans: ^7there are %d active bans\n", found ) ); + ADMP( va( "^3!showbans: ^7%d is the last valid ban\n", max + 1 ) ); return qfalse; } ADMBP_begin(); - for( i = start; i < MAX_ADMIN_BANS && g_admin_bans[ i ] && - ( i - start ) < MAX_ADMIN_SHOWBANS; i++ ) + for( i = start, count = 0; i < MAX_ADMIN_BANS && g_admin_bans[ i ] && + count < MAX_ADMIN_SHOWBANS; i++ ) { if( g_admin_bans[ i ]->expires != 0 && ( g_admin_bans[ i ]->expires - t ) < 1 ) continue; + count++; + // only print out the the date part of made date[ 0 ] = '\0'; made = g_admin_bans[ i ]->made; @@ -2451,16 +2470,13 @@ qboolean G_admin_showbans( gentity_t *ent, int skiparg ) g_admin_bans[ i ]->reason ) ); } - ADMBP( va( "^3!showbans:^7 showing bans %d - %d of %d. ", + ADMBP( va( "^3!showbans:^7 showing bans %d - %d of %d (%d total).", ( found ) ? ( start + 1 ) : 0, - ( ( start + MAX_ADMIN_SHOWBANS ) > found ) ? - found : ( start + MAX_ADMIN_SHOWBANS ), + i, + max + 1, found ) ); - if( ( start + MAX_ADMIN_SHOWBANS ) < found ) - { - ADMBP( va( "run !showbans %d to see more", - ( start + MAX_ADMIN_SHOWBANS + 1 ) ) ); - } + if( i + MAX_ADMIN_SHOWBANS < max ) + ADMBP( va( " run !showbans %d to see more", i + 1 ) ); ADMBP( "\n" ); ADMBP_end(); return qtrue; |