diff options
author | M. Kristall <mkpdev@gmail.com> | 2009-10-03 12:05:47 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2013-01-03 00:15:40 +0000 |
commit | c9006304896cd95d989f68d5b103702d51fdf7bb (patch) | |
tree | c4d3e61c40fb7e1c72cc6858778126b3a4648cbd /src/game | |
parent | ae0a3343c5e6ce341896e0c0204dc385bc682e6f (diff) |
* (bug 3379) !adjustban command to change reason and duration of bans (flag b)
* (bug 3746) Lookup table for UI commands (Ben Millwood)
* and some other refactoring
* Fix a couple null dereferences introduced in 1120
Diffstat (limited to 'src/game')
-rw-r--r-- | src/game/g_admin.c | 298 | ||||
-rw-r--r-- | src/game/g_admin.h | 1 | ||||
-rw-r--r-- | src/game/g_cmds.c | 41 | ||||
-rw-r--r-- | src/game/g_local.h | 5 | ||||
-rw-r--r-- | src/game/g_main.c | 33 |
5 files changed, 212 insertions, 166 deletions
diff --git a/src/game/g_admin.c b/src/game/g_admin.c index e712dfeb..375e560f 100644 --- a/src/game/g_admin.c +++ b/src/game/g_admin.c @@ -38,6 +38,15 @@ static char g_bfb[ 32000 ]; // note: list ordered alphabetically g_admin_cmd_t g_admin_cmds[ ] = { + {"adjustban", G_admin_adjustban, "b", + "change the duration or reason of a ban. duration is specified as " + "numbers followed by units 'w' (weeks), 'd' (days), 'h' (hours) or " + "'m' (minutes), or seconds if no units are specified. if the duration is" + " preceded by a + or -, the ban duration will be extended or shortened by" + " the specified amount", + "[^3ban#^7] (^5duration^7) (^5reason^7)" + }, + {"admintest", G_admin_admintest, "a", "display your current admin level", "" @@ -55,9 +64,10 @@ g_admin_cmd_t g_admin_cmds[ ] = {"ban", G_admin_ban, "b", "ban a player by IP and GUID with an optional expiration time and reason." - " time is seconds or suffix with 'w' - weeks, 'd' - days, 'h' - hours, " - "or 'm' - minutes", - "[^3name|slot#|IP^7] (^5time^7) (^5reason^7)" + " duration is specified as numbers followed by units 'w' (weeks), 'd' " + "(days), 'h' (hours) or 'm' (minutes), or seconds if no units are " + "specified", + "[^3name|slot#|IP^7] (^5duration^7) (^5reason^7)" }, {"cancelvote", G_admin_cancelvote, "c", @@ -165,7 +175,7 @@ g_admin_cmd_t g_admin_cmds[ ] = {"unban", G_admin_unban, "b", "unbans a player specified by the slot as seen in showbans", - "[^3ban slot#^7]" + "[^3ban#^7]" }, {"unlock", G_admin_unlock, "K", @@ -330,8 +340,7 @@ static qboolean admin_higher_guid( char *admin_guid, char *victim_guid ) { if( alevel < g_admin_admins[ i ]->level ) return qfalse; - if( strstr( g_admin_admins[ i ]->flags, va( "%c", ADMF_IMMUTABLE ) ) ) - return qfalse; + return !strstr( g_admin_admins[ i ]->flags, va( "%c", ADMF_IMMUTABLE ) ); } } return qtrue; @@ -729,8 +738,7 @@ static int admin_listadmins( gentity_t *ent, int start, char *search ) char name[ MAX_NAME_LENGTH ] = {""}; char name2[ MAX_NAME_LENGTH ] = {""}; char lname[ MAX_NAME_LENGTH ] = {""}; - char lname_fmt[ 5 ]; - int i,j; + int i, j; gentity_t *vic; int l = 0; qboolean dup = qfalse; @@ -756,17 +764,13 @@ static int admin_listadmins( gentity_t *ent, int start, char *search ) guid_stub[ j ] = '\0'; lname[ 0 ] = '\0'; - Q_strncpyz( lname_fmt, "%s", sizeof( lname_fmt ) ); for( j = 0; j < MAX_ADMIN_LEVELS && g_admin_levels[ j ]; j++ ) { if( g_admin_levels[ j ]->level == l ) { - G_DecolorString( g_admin_levels[ j ]->name, lname, sizeof( lname ) ); - Com_sprintf( lname_fmt, sizeof( lname_fmt ), "%%%is", - ( admin_level_maxname + strlen( g_admin_levels[ j ]->name ) - - strlen( lname ) ) ); - Com_sprintf( lname, sizeof( lname ), lname_fmt, - g_admin_levels[ j ]->name ); + Com_sprintf( lname, sizeof( lname ), va( "%%%is", + Q_PrintStrlen( g_admin_levels[ j ]->name ) - admin_level_maxname - + strlen( g_admin_levels[ j ]->name ) ), g_admin_levels[ j ]->name ); break; } } @@ -812,17 +816,13 @@ static int admin_listadmins( gentity_t *ent, int start, char *search ) guid_stub[ j ] = '\0'; lname[ 0 ] = '\0'; - Q_strncpyz( lname_fmt, "%s", sizeof( lname_fmt ) ); for( j = 0; j < MAX_ADMIN_LEVELS && g_admin_levels[ j ]; j++ ) { if( g_admin_levels[ j ]->level == g_admin_admins[ i ]->level ) { - G_DecolorString( g_admin_levels[ j ]->name, lname, sizeof( lname ) ); - Com_sprintf( lname_fmt, sizeof( lname_fmt ), "%%%is", - ( admin_level_maxname + strlen( g_admin_levels[ j ]->name ) - - strlen( lname ) ) ); - Com_sprintf( lname, sizeof( lname ), lname_fmt, - g_admin_levels[ j ]->name ); + Com_sprintf( lname, sizeof( lname ), va( "%%%is", + Q_PrintStrlen( g_admin_levels[ j ]->name ) - admin_level_maxname - + strlen( g_admin_levels[ j ]->name ) ), g_admin_levels[ j ]->name ); break; } } @@ -927,15 +927,15 @@ qboolean G_admin_cmd_check( gentity_t *ent, qboolean say ) command[ 0 ] = '\0'; G_SayArgv( 0, command, sizeof( command ) ); + if( !command[ 0 ] ) + return qfalse; if( !Q_stricmp( command, "say" ) || - ( G_admin_permission( ent, ADMF_TEAMCHAT_CMD ) && - ( !Q_stricmp( command, "say_team" ) ) ) ) + ( !Q_stricmp( command, "say_team" ) && + G_admin_permission( ent, ADMF_TEAMCHAT_CMD ) ) ) { skip = 1; G_SayArgv( 1, command, sizeof( command ) ); } - if( !command[ 0 ] ) - return qfalse; if( command[ 0 ] == '!' ) { @@ -954,7 +954,7 @@ qboolean G_admin_cmd_check( gentity_t *ent, qboolean say ) if( admin_command_permission( ent, cmd ) ) { // flooding say will have already been accounted for in ClientCommand - if( !say && G_FloodLimited( ent ) ) + if( ent && !say && G_FloodLimited( ent ) ) return qtrue; trap_SendConsoleCommand( EXEC_APPEND, g_admin_commands[ i ]->exec ); admin_log( ent, cmd, skip ); @@ -975,7 +975,7 @@ qboolean G_admin_cmd_check( gentity_t *ent, qboolean say ) if( G_admin_permission( ent, g_admin_cmds[ i ].flag[ 0 ] ) ) { // flooding say will have already been accounted for in ClientCommand - if( !say && G_FloodLimited( ent ) ) + if( ent && !say && G_FloodLimited( ent ) ) return qtrue; g_admin_cmds[ i ].handler( ent, skip ); admin_log( ent, cmd, skip ); @@ -1314,14 +1314,12 @@ qboolean G_admin_readconfig( gentity_t *ent, int skiparg ) admin_default_levels(); else { - char n[ MAX_NAME_LENGTH ] = {""}; - // max printable name length for formatting for( i = 0; i < MAX_ADMIN_LEVELS && g_admin_levels[ i ]; i++ ) { - G_DecolorString( l->name, n, sizeof( n ) ); - if( strlen( n ) > admin_level_maxname ) - admin_level_maxname = strlen( n ); + len = Q_PrintStrlen( l->name ); + if( len > admin_level_maxname ) + admin_level_maxname = len; } } @@ -1578,6 +1576,36 @@ static qboolean admin_create_ban( gentity_t *ent, return qtrue; } +int G_admin_parse_time( const char *time ) +{ + int seconds = 0, num = 0; + while( *time ) + { + if( !isdigit( *time ) ) + return -1; + while( isdigit( *time ) ) + { + num = num * 10 + *time++ - '0'; + continue; + } + if( !*time ) + break; + switch( *time++ ) + { + case 'w': num *= 7; + case 'd': num *= 24; + case 'h': num *= 60; + case 'm': num *= 60; + case 's': break; + default: return -1; + } + seconds += num; + num = 0; + } + if( num ) + seconds += num; + return seconds; +} qboolean G_admin_kick( gentity_t *ent, int skiparg ) { @@ -1615,16 +1643,14 @@ qboolean G_admin_kick( gentity_t *ent, int skiparg ) ADMP( "^3!kick: ^7disconnecting the host would end the game\n" ); return qfalse; } - if( g_adminTempBan.integer > 0 ) - { - admin_create_ban( ent, - vic->client->pers.netname, - vic->client->pers.guid, - vic->client->pers.ip, g_adminTempBan.integer, - "automatic temp ban created by kick" ); - if( g_admin.string[ 0 ] ) - admin_writeconfig(); - } + admin_create_ban( ent, + vic->client->pers.netname, + vic->client->pers.guid, + vic->client->pers.ip, + G_admin_parse_time( va( "1s%s", g_adminTempBan.string ) ), + ( *reason ) ? reason : "kicked by admin" ); + if( g_admin.string[ 0 ] ) + admin_writeconfig(); trap_SendServerCommand( pids[ 0 ], va( "disconnect \"You have been kicked.\n%s^7\nreason:\n%s\"", @@ -1642,11 +1668,10 @@ qboolean G_admin_ban( gentity_t *ent, int skiparg ) { int seconds; char search[ MAX_NAME_LENGTH ]; - char secs[ 7 ]; + char secs[ MAX_TOKEN_CHARS ]; char *reason; int minargc; char duration[ 32 ]; - int modifier = 1; int logmatch = -1, logmatches = 0; int i, j; qboolean exactmatch = qfalse; @@ -1670,32 +1695,14 @@ qboolean G_admin_ban( gentity_t *ent, int skiparg ) } if( G_SayArgc() < minargc ) { - ADMP( "^3!ban: ^7usage: !ban [name|slot|ip] [seconds] [reason]\n" ); + ADMP( "^3!ban: ^7usage: !ban [name|slot|ip] [duration] [reason]\n" ); return qfalse; } G_SayArgv( 1 + skiparg, search, sizeof( search ) ); G_SanitiseString( search, s2, sizeof( s2 ) ); G_SayArgv( 2 + skiparg, secs, sizeof( secs ) ); - // support "w" (weeks), "d" (days), "h" (hours), and "m" (minutes) modifiers - if( secs[ 0 ] ) - { - int lastchar = strlen( secs ) - 1; - if( secs[ lastchar ] == 'w' ) - modifier = 60 * 60 * 24 * 7; - else if( secs[ lastchar ] == 'd' ) - modifier = 60 * 60 * 24; - else if( secs[ lastchar ] == 'h' ) - modifier = 60 * 60; - else if( secs[ lastchar ] == 'm' ) - modifier = 60; - else if( !isdigit( secs[ lastchar ] ) ) - secs[ lastchar ] = '\0'; - } - seconds = atoi( secs ); - if( seconds > 0 ) - seconds *= modifier; - + seconds = G_admin_parse_time( secs ); if( seconds <= 0 ) { if( G_admin_permission( ent, ADMF_CAN_PERM_BAN ) ) @@ -1704,7 +1711,7 @@ qboolean G_admin_ban( gentity_t *ent, int skiparg ) } else { - ADMP( "^3!ban: ^7ban time must be positive\n" ); + ADMP( "^3!ban: ^7ban duration must be positive\n" ); return qfalse; } reason = G_SayConcatArgs( 2 + skiparg ); @@ -1829,7 +1836,7 @@ qboolean G_admin_ban( gentity_t *ent, int skiparg ) if( g_admin_namelog[ logmatch ]->slot == -1 ) { // client is already disconnected so stop here - AP( va( "print \"^3!ban:^7 %s^7 has been banned by %s^7 " + AP( va( "print \"^3!ban:^7 %s^7 has been banned by %s^7, " "duration: %s, reason: %s\n\"", g_admin_namelog[ logmatch ]->name[ 0 ], ( ent ) ? ent->client->pers.netname : "console", @@ -1846,7 +1853,7 @@ qboolean G_admin_ban( gentity_t *ent, int skiparg ) ( *reason ) ? reason : "kicked by admin" ) ); trap_DropClient( g_admin_namelog[ logmatch ]->slot, - va( "has been banned by %s^7 duration: %s, reason: %s", + va( "has been banned by %s^7, duration: %s, reason: %s", ( ent ) ? ent->client->pers.netname : "console", duration, ( *reason ) ? reason : "banned by admin" ) ); @@ -1856,23 +1863,18 @@ qboolean G_admin_ban( gentity_t *ent, int skiparg ) qboolean G_admin_unban( gentity_t *ent, int skiparg ) { int bnum; - char bs[ 4 ]; + char bs[ 5 ]; if( G_SayArgc() < 2 + skiparg ) { - ADMP( "^3!unban: ^7usage: !unban [ban #]\n" ); + ADMP( "^3!unban: ^7usage: !unban [ban#]\n" ); return qfalse; } G_SayArgv( 1 + skiparg, bs, sizeof( bs ) ); bnum = atoi( bs ); - if( bnum < 1 ) - { - ADMP( "^3!unban: ^7invalid ban #\n" ); - return qfalse; - } - if( !g_admin_bans[ bnum - 1 ] ) + if( bnum < 1 || bnum > MAX_ADMIN_BANS || !g_admin_bans[ bnum - 1 ] ) { - ADMP( "^3!unban: ^7invalid ban #\n" ); + ADMP( "^3!unban: ^7invalid ban#\n" ); return qfalse; } g_admin_bans[ bnum - 1 ]->expires = trap_RealTime( NULL ); @@ -1885,6 +1887,92 @@ qboolean G_admin_unban( gentity_t *ent, int skiparg ) return qtrue; } +qboolean G_admin_adjustban( gentity_t *ent, int skiparg ) +{ + int bnum; + int length; + int expires; + int time = trap_RealTime( NULL ); + char duration[ 32 ] = {""}; + char *reason; + char bs[ 5 ]; + char secs[ MAX_TOKEN_CHARS ]; + char mode = '\0'; + g_admin_ban_t *ban; + + if( G_SayArgc() < 3 + skiparg ) + { + ADMP( "^3!adjustban: ^7usage: !adjustban [ban#] [duration] [reason]\n" ); + return qfalse; + } + G_SayArgv( 1 + skiparg, bs, sizeof( bs ) ); + bnum = atoi( bs ); + if( bnum < 1 || bnum > MAX_ADMIN_BANS || !g_admin_bans[ bnum - 1 ] ) + { + ADMP( "^3!adjustban: ^7invalid ban#\n" ); + return qfalse; + } + ban = g_admin_bans[ bnum - 1 ]; + + G_SayArgv( 2 + skiparg, secs, sizeof( secs ) ); + if( secs[ 0 ] == '+' || secs[ 0 ] == '-' ) + mode = secs[ 0 ]; + length = G_admin_parse_time( &secs[ mode ? 1 : 0 ] ); + if( length < 0 ) + skiparg--; + else + { + if( length ) + { + if( ban->expires == 0 && mode ) + { + ADMP( "^3!adjustban: ^7new duration must be explicit\n" ); + return qfalse; + } + if( mode == '+' ) + expires = ban->expires + length; + else if( mode == '-' ) + expires = ban->expires - length; + else + expires = time + length; + if( expires <= time ) + { + ADMP( "^3!adjustban: ^7ban duration must be positive\n" ); + return qfalse; + } + } + else if( G_admin_permission( ent, ADMF_CAN_PERM_BAN ) ) + expires = 0; + else + { + ADMP( "^3!adjustban: ^7ban duration must be positive\n" ); + return qfalse; + } + + ban->expires = expires; + G_admin_duration( ( expires ) ? expires - time : -1, duration, + sizeof( duration ) ); + } + reason = G_SayConcatArgs( 3 + skiparg ); + if( *reason ) + Q_strncpyz( ban->reason, reason, sizeof( ban->reason ) ); + AP( va( "print \"^3!adjustban: ^7ban #%d for %s^7 has been updated by %s^7 " + "%s%s%s%s%s\n\"", + bnum, + ban->name, + ( ent ) ? ent->client->pers.netname : "console", + ( length >= 0 ) ? "duration: " : "", + duration, + ( length >= 0 && *reason ) ? ", " : "", + ( *reason ) ? "reason: " : "", + reason ) ); + if( ent ) + Q_strncpyz( ban->banner, ent->client->pers.netname, sizeof( ban->banner ) ); + if( g_admin.string[ 0 ] ) + admin_writeconfig(); + return qtrue; +} + qboolean G_admin_putteam( gentity_t *ent, int skiparg ) { int pids[ MAX_CLIENTS ], found; @@ -2354,12 +2442,11 @@ 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 max = -1, count; int t; char duration[ 32 ]; - char name_fmt[ 32 ] = { "%s" }; - char banner_fmt[ 32 ] = { "%s" }; int max_name = 1, max_banner = 1; + int len; int secs; int start = 0; char skip[ 11 ]; @@ -2402,11 +2489,16 @@ qboolean G_admin_showbans( gentity_t *ent, int skiparg ) } } - if( start >= MAX_ADMIN_BANS || start < 0 ) + if( start < 0 ) start = 0; - for( i = start, count = 0; i < MAX_ADMIN_BANS && g_admin_bans[ i ] && - count < MAX_ADMIN_SHOWBANS; i++ ) + if( start > max ) + { + ADMP( va( "^3!showbans: ^7%d is the last valid ban\n", max + 1 ) ); + return qfalse; + } + + for( i = start, count = 0; i <= max && count < MAX_ADMIN_SHOWBANS; i++ ) { if( g_admin_bans[ i ]->expires != 0 && ( g_admin_bans[ i ]->expires - t ) < 1 ) @@ -2414,24 +2506,17 @@ qboolean G_admin_showbans( gentity_t *ent, int skiparg ) 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 ); + len = Q_PrintStrlen( g_admin_bans[ i ]->name ); + if( len > max_name ) + max_name = len; - if( strlen( n2 ) > max_banner ) - max_banner = strlen( n2 ); + len = Q_PrintStrlen( g_admin_bans[ i ]->banner ); + if( len > max_banner ) + max_banner = len; } - if( start > max ) - { - ADMP( va( "^3!showbans: ^7%d is the last valid ban\n", max + 1 ) ); - return qfalse; - } ADMBP_begin(); - for( i = start, count = 0; i < MAX_ADMIN_BANS && g_admin_bans[ i ] && - count < MAX_ADMIN_SHOWBANS; i++ ) + for( i = start, count = 0; i <= max && count < MAX_ADMIN_SHOWBANS; i++ ) { if( g_admin_bans[ i ]->expires != 0 && ( g_admin_bans[ i ]->expires - t ) < 1 ) @@ -2456,15 +2541,12 @@ qboolean G_admin_showbans( gentity_t *ent, int skiparg ) secs = ( g_admin_bans[ i ]->expires - t ); G_admin_duration( secs, duration, sizeof( duration ) ); - G_DecolorString( g_admin_bans[ i ]->name, n1, sizeof( n1 ) ); - Com_sprintf( name_fmt, sizeof( name_fmt ), "%%%is", - ( max_name + strlen( g_admin_bans[ i ]->name ) - strlen( n1 ) ) ); - Com_sprintf( n1, sizeof( n1 ), name_fmt, g_admin_bans[ i ]->name ); - - G_DecolorString( g_admin_bans[ i ]->banner, n2, sizeof( n2 ) ); - Com_sprintf( banner_fmt, sizeof( banner_fmt ), "%%%is", - ( max_banner + strlen( g_admin_bans[ i ]->banner ) - strlen( n2 ) ) ); - Com_sprintf( n2, sizeof( n2 ), banner_fmt, g_admin_bans[ i ]->banner ); + Com_sprintf( n1, sizeof( n1 ), va( "%%%is", + Q_PrintStrlen( g_admin_bans[ i ]->name ) - max_name - + strlen( g_admin_bans[ i ]->name ) ), g_admin_bans[ i ]->name ); + Com_sprintf( n2, sizeof( n2 ), va( "%%%is", + Q_PrintStrlen( g_admin_bans[ i ]->banner ) - max_banner - + strlen( g_admin_bans[ i ]->banner ) ), g_admin_bans[ i ]->banner ); ADMBP( va( "%4i %s^7 %-15s %-8s %s^7 %-10s\n \\__ %s\n", ( i + 1 ), @@ -2481,7 +2563,7 @@ qboolean G_admin_showbans( gentity_t *ent, int skiparg ) i, max + 1, found ) ); - if( i + MAX_ADMIN_SHOWBANS < max ) + if( i <= max ) ADMBP( va( " run !showbans %d to see more", i + 1 ) ); ADMBP( "\n" ); ADMBP_end(); @@ -2840,7 +2922,7 @@ qboolean G_admin_namelog( gentity_t *ent, int skiparg ) ADMBP_begin(); for( i = 0; i < MAX_ADMIN_NAMELOGS && g_admin_namelog[ i ]; i++ ) { - if( search[0] ) + if( search[ 0 ] ) { found = qfalse; for( j = 0; j < MAX_ADMIN_NAMELOG_NAMES && diff --git a/src/game/g_admin.h b/src/game/g_admin.h index 87475b02..ee0f6ad7 100644 --- a/src/game/g_admin.h +++ b/src/game/g_admin.h @@ -145,6 +145,7 @@ int G_admin_level( gentity_t *ent ); qboolean G_admin_time( gentity_t *ent, int skiparg ); qboolean G_admin_setlevel( gentity_t *ent, int skiparg ); qboolean G_admin_kick( gentity_t *ent, int skiparg ); +qboolean G_admin_adjustban( gentity_t *ent, int skiparg ); qboolean G_admin_ban( gentity_t *ent, int skiparg ); qboolean G_admin_unban( gentity_t *ent, int skiparg ); qboolean G_admin_putteam( gentity_t *ent, int skiparg ); diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index 86a26483..c015a210 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -1110,7 +1110,7 @@ void Cmd_CallVote_f( gentity_t *ent ) char arg1[ MAX_STRING_TOKENS ]; char arg2[ MAX_NAME_LENGTH ]; int clientNum = -1; - char name[ MAX_NETNAME ]; + char name[ MAX_NAME_LENGTH ]; if( !g_allowVote.integer ) { @@ -1207,8 +1207,8 @@ void Cmd_CallVote_f( gentity_t *ent ) // use ip in case this player disconnects before the vote ends Com_sprintf( level.voteString, sizeof( level.voteString ), - "!ban %s %d vote kick", level.clients[ clientNum ].pers.ip, - g_adminTempBan.integer + 1 ); + "!ban %s \"1s%s\" vote kick", level.clients[ clientNum ].pers.ip, + g_adminTempBan.string ); Com_sprintf( level.voteDisplayString, sizeof( level.voteDisplayString ), "Kick player \'%s\'", name ); } @@ -1344,7 +1344,7 @@ void Cmd_CallTeamVote_f( gentity_t *ent ) char arg1[ MAX_STRING_TOKENS ]; char arg2[ MAX_NAME_LENGTH ]; int clientNum = -1; - char name[ MAX_NETNAME ]; + char name[ MAX_NAME_LENGTH ]; team = ent->client->pers.teamSelection; @@ -1447,8 +1447,8 @@ void Cmd_CallTeamVote_f( gentity_t *ent ) // use ip in case this player disconnects before the vote ends Com_sprintf( level.teamVoteString[ cs_offset ], sizeof( level.teamVoteString[ cs_offset ] ), - "!ban %s %d team vote kick", level.clients[ clientNum ].pers.ip, - g_adminTempBan.integer + 1 ); + "!ban %s \"1s%s\" team vote kick", level.clients[ clientNum ].pers.ip, + g_adminTempBan.string ); Com_sprintf( level.teamVoteDisplayString[ cs_offset ], sizeof( level.teamVoteDisplayString[ cs_offset ] ), "Kick player '%s'", name ); @@ -3224,8 +3224,6 @@ int G_SayArgc( void ) qboolean G_SayArgv( int n, char *buffer, int bufferLength ) { - int bc = 0; - int c = 0; char *s; if( bufferLength < 1 ) @@ -3233,47 +3231,40 @@ qboolean G_SayArgv( int n, char *buffer, int bufferLength ) if( n < 0 ) return qfalse; s = ConcatArgs( 0 ); - while( c < n ) + while( 1 ) { while( *s == ' ' ) s++; - if( !*s ) + if( !*s || n == 0 ) break; - c++; + n--; while( *s && *s != ' ' ) s++; } - if( c < n ) - return qfalse; - while( *s == ' ' ) - s++; - if( !*s ) + if( n > 0 ) return qfalse; //memccpy( buffer, s, ' ', bufferLength ); - while( bc < bufferLength - 1 && *s && *s != ' ' ) - buffer[ bc++ ] = *s++; - buffer[ bc ] = 0; + while( bufferLength > 1 && *s && *s != ' ' ) + *buffer++ = *s++; + *buffer = 0; return qtrue; } char *G_SayConcatArgs( int start ) { char *s; - int c = 0; s = ConcatArgs( 0 ); - while( c < start ) + while( 1 ) { while( *s == ' ' ) s++; - if( !*s ) + if( !*s || start == 0 ) break; - c++; + start--; while( *s && *s != ' ' ) s++; } - while( *s == ' ' ) - s++; return s; } diff --git a/src/game/g_local.h b/src/game/g_local.h index da99d44e..d94e99f9 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -277,8 +277,6 @@ typedef struct clientList_t ignoreList; } clientSession_t; -#define MAX_NETNAME 36 - // data to store details of clients that have abnormally disconnected typedef struct connectionRecord_s { @@ -299,7 +297,7 @@ typedef struct qboolean initialSpawn; // the first spawn should be at a cool location qboolean stickySpec; // don't stop spectating a player after they get killed qboolean pmoveFixed; // - char netname[ MAX_NETNAME ]; + char netname[ MAX_NAME_LENGTH ]; int maxHealth; // for handicapping int enterTime; // level.time the client entered the game int location; // player locations @@ -680,6 +678,7 @@ void G_ChangeTeam( gentity_t *ent, team_t newTeam ); void G_SanitiseString( char *in, char *out, int len ); void G_PrivateMessage( gentity_t *ent ); void Cmd_Test_f( gentity_t *ent ); +qboolean G_FloodLimited( gentity_t *ent ); // // g_physics.c diff --git a/src/game/g_main.c b/src/game/g_main.c index 37477980..fc0651ea 100644 --- a/src/game/g_main.c +++ b/src/game/g_main.c @@ -33,7 +33,6 @@ typedef struct int cvarFlags; int modificationCount; // for tracking changes qboolean trackChange; // track this variable, and announce if changed - qboolean teamShader; // track and if changed, update shader state } cvarTable_t; gentity_t g_entities[ MAX_GENTITIES ]; @@ -259,7 +258,7 @@ static cvarTable_t gameCvarTable[ ] = { &g_adminLog, "g_adminLog", "admin.log", CVAR_ARCHIVE, 0, qfalse }, { &g_adminParseSay, "g_adminParseSay", "1", CVAR_ARCHIVE, 0, qfalse }, { &g_adminNameProtect, "g_adminNameProtect", "1", CVAR_ARCHIVE, 0, qfalse }, - { &g_adminTempBan, "g_adminTempBan", "120", CVAR_ARCHIVE, 0, qfalse }, + { &g_adminTempBan, "g_adminTempBan", "2m", CVAR_ARCHIVE, 0, qfalse }, { &g_dretchPunt, "g_dretchPunt", "0", CVAR_ARCHIVE, 0, qfalse }, @@ -429,10 +428,6 @@ void G_FindTeams( void ) G_Printf( "%i teams with %i entities\n", c, c2 ); } -void G_RemapTeamShaders( void ) -{ -} - /* ================= @@ -443,7 +438,6 @@ void G_RegisterCvars( void ) { int i; cvarTable_t *cv; - qboolean remapped = qfalse; for( i = 0, cv = gameCvarTable; i < gameCvarTableSize; i++, cv++ ) { @@ -452,14 +446,8 @@ void G_RegisterCvars( void ) if( cv->vmCvar ) cv->modificationCount = cv->vmCvar->modificationCount; - - if( cv->teamShader ) - remapped = qtrue; } - if( remapped ) - G_RemapTeamShaders( ); - // check some things level.warmupModificationCount = g_warmup.modificationCount; } @@ -473,7 +461,6 @@ void G_UpdateCvars( void ) { int i; cvarTable_t *cv; - qboolean remapped = qfalse; for( i = 0, cv = gameCvarTable; i < gameCvarTableSize; i++, cv++ ) { @@ -492,15 +479,9 @@ void G_UpdateCvars( void ) // update serverinfo in case this cvar is passed to clients indirectly CalculateRanks( ); } - - if( cv->teamShader ) - remapped = qtrue; } } } - - if( remapped ) - G_RemapTeamShaders( ); } /* @@ -653,8 +634,6 @@ void G_InitGame( int levelTime, int randomSeed, int restart ) G_Printf( "-----------------------------------\n" ); - G_RemapTeamShaders( ); - // so the server counts the spawns without a client attached G_CountSpawns( ); @@ -790,20 +769,14 @@ void G_InitSpawnQueue( spawnQueue_t *sq ) ============ G_GetSpawnQueueLength -Return tha length of a spawn queue +Return the length of a spawn queue ============ */ int G_GetSpawnQueueLength( spawnQueue_t *sq ) { int length = sq->back - sq->front + 1; - while( length < 0 ) - length += MAX_CLIENTS; - - while( length >= MAX_CLIENTS ) - length -= MAX_CLIENTS; - - return length; + return length % MAX_CLIENTS; } /* |