added !adminlog

added ff percent retribution
changed poll votes to not force yes out of caller
This commit is contained in:
Paradox460 committed 2008-01-20 21:53:39 +00:00
1 parent a8a23e674c
commit 02da7b75c6
7 files changed
+448 -46

No files matched your search

+9
View File
@@ -872,8 +872,17 @@ void ClientTimerActions( gentity_t *ent, int msec )
if( ent->health > 0 && ent->health < client->ps.stats[ STAT_MAX_HEALTH ] &&
( ent->lastDamageTime + ALIEN_REGEN_DAMAGE_TIME ) < level.time &&
!level.paused )
{
ent->health += BG_FindRegenRateForClass( client->ps.stats[ STAT_PCLASS ] ) * modifier;
//if completely healed, cancel retribution
if( ent->health >= client->ps.stats[ STAT_MAX_HEALTH ] )
{
for( i = 0; i < MAX_CLIENTS; i++ )
ent->client->tkcredits[ i ] = 0;
}
}
if( ent->health > client->ps.stats[ STAT_MAX_HEALTH ] )
ent->health = client->ps.stats[ STAT_MAX_HEALTH ];
}
+293 -5
View File
@@ -45,6 +45,11 @@ g_admin_cmd_t g_admin_cmds[ ] =
"[^5ban #^7] (^3length|reason^7)"
},
{"adminlog", G_admin_adminlog, "A",
"list recent admin activity",
"(^5start id#|name|!command|-skip#^7) (^5search skip#^7)"
},
{"admintest", G_admin_admintest, "a",
"display your current admin level",
""
@@ -129,7 +134,7 @@ g_admin_cmd_t g_admin_cmds[ ] =
"(^5command^7)"
},
{"immunity", G_admin_immunity, "b",
{"immunity", G_admin_immunity, "I",
"give a player ban immunity",
"[^3+|-^7](^5slot#^7)"
},
@@ -286,7 +291,7 @@ g_admin_cmd_t g_admin_cmds[ ] =
"[^3name|slot#^7]"
},
{"suspendban", G_admin_suspendban, "b",
{"suspendban", G_admin_suspendban, "J",
"suspend a ban for a length of time. time is specified as numbers "
"followed by units 'w' (weeks), 'd' (days), 'h' (hours) or 'm' (minutes),"
" or seconds if no units are specified",
@@ -356,6 +361,9 @@ g_admin_ban_t *g_admin_bans[ MAX_ADMIN_BANS ];
g_admin_command_t *g_admin_commands[ MAX_ADMIN_COMMANDS ];
g_admin_namelog_t *g_admin_namelog[ MAX_ADMIN_NAMELOGS ];
static int admin_adminlog_index = 0;
g_admin_adminlog_t *g_admin_adminlog[ MAX_ADMIN_ADMINLOGS ];
qboolean G_admin_permission( gentity_t *ent, char flag )
{
int i;
@@ -1281,11 +1289,13 @@ qboolean G_admin_cmd_check( gentity_t *ent, qboolean say )
{
trap_SendConsoleCommand( EXEC_APPEND, g_admin_commands[ i ]->exec );
admin_log( ent, cmd, skip );
G_admin_adminlog_log( ent, cmd, skip, qtrue );
}
else
{
ADMP( va( "^3!%s: ^7permission denied\n", g_admin_commands[ i ]->command ) );
admin_log( ent, "attempted", skip - 1 );
G_admin_adminlog_log( ent, cmd, skip, qfalse );
}
return qtrue;
}
@@ -1299,11 +1309,13 @@ qboolean G_admin_cmd_check( gentity_t *ent, qboolean say )
{
g_admin_cmds[ i ].handler( ent, skip );
admin_log( ent, cmd, skip );
G_admin_adminlog_log( ent, cmd, skip, qtrue );
}
else
{
ADMP( va( "^3!%s: ^7permission denied\n", g_admin_cmds[ i ].keyword ) );
admin_log( ent, "attempted", skip - 1 );
G_admin_adminlog_log( ent, cmd, skip, qfalse );
}
return qtrue;
}
@@ -5113,10 +5125,8 @@ qboolean G_admin_drug( gentity_t *ent, int skiparg )
int pids[ MAX_CLIENTS ];
char name[ MAX_NAME_LENGTH ], err[ MAX_STRING_CHARS ];
int minargc;
gentity_t *vic;
minargc = 2 + skiparg;
minargc = 2 + skiparg;
if( G_SayArgc() < minargc )
{
@@ -5405,6 +5415,284 @@ qboolean G_admin_L0(gentity_t *ent, int skiparg ){
return qtrue;
}
void G_admin_adminlog_cleanup( void )
{
int i;
for( i = 0; i < MAX_ADMIN_ADMINLOGS && g_admin_adminlog[ i ]; i++ )
{
G_Free( g_admin_adminlog[ i ] );
g_admin_adminlog[ i ] = NULL;
}
admin_adminlog_index = 0;
}
void G_admin_adminlog_log( gentity_t *ent, char *command, int skiparg, qboolean success )
{
g_admin_adminlog_t *adminlog;
int previous;
int count = 1;
int i;
if( !command )
return;
if( !Q_stricmp( command, "adminlog" ) ||
!Q_stricmp( command, "admintest" ) ||
!Q_stricmp( command, "help" ) ||
!Q_stricmp( command, "info" ) ||
!Q_stricmp( command, "listadmins" ) ||
!Q_stricmp( command, "listplayers" ) ||
!Q_stricmp( command, "namelog" ) ||
!Q_stricmp( command, "showbans" ) ||
!Q_stricmp( command, "time" ) )
return;
previous = admin_adminlog_index - 1;
if( previous < 0 )
previous = MAX_ADMIN_ADMINLOGS - 1;
if( g_admin_adminlog[ previous ] )
count = g_admin_adminlog[ previous ]->id + 1;
if( g_admin_adminlog[ admin_adminlog_index ] )
adminlog = g_admin_adminlog[ admin_adminlog_index ];
else
adminlog = G_Alloc( sizeof( g_admin_adminlog_t ) );
memset( adminlog, 0, sizeof( adminlog ) );
adminlog->id = count;
adminlog->time = level.time - level.startTime;
adminlog->success = success;
Q_strncpyz( adminlog->command, command, sizeof( adminlog->command ) );
Q_strncpyz( adminlog->args, G_SayConcatArgs( 1 + skiparg ), sizeof( adminlog->args ) );
if( ent )
{
qboolean found = qfalse;
// real admin name
for( i = 0; i < MAX_ADMIN_ADMINS && g_admin_admins[ i ]; i++ )
{
if( !Q_stricmp( g_admin_admins[ i ]->guid, ent->client->pers.guid ) )
{
Q_strncpyz( adminlog->name, g_admin_admins[ i ]->name, sizeof( adminlog->name ) );
found = qtrue;
break;
}
}
if( !found )
Q_strncpyz( adminlog->name, ent->client->pers.netname, sizeof( adminlog->name ) );
adminlog->level = ent->client->pers.adminLevel;
}
else
{
Q_strncpyz( adminlog->name, "console", sizeof( adminlog->name ) );
adminlog->level = 10000;
}
g_admin_adminlog[ admin_adminlog_index ] = adminlog;
admin_adminlog_index++;
if( admin_adminlog_index >= MAX_ADMIN_ADMINLOGS )
admin_adminlog_index = 0;
}
qboolean G_admin_adminlog( gentity_t *ent, int skiparg )
{
g_admin_adminlog_t *results[ 10 ];
int result_index = 0;
char *search_cmd = NULL;
char *search_name = NULL;
int index;
int skip = 0;
int skipped = 0;
int checked = 0;
char n1[ MAX_NAME_LENGTH ];
char fmt_name[ 16 ];
char argbuf[ 32 ];
int name_length = 12;
int max_id = 0;
int i;
qboolean match;
memset( results, 0, sizeof( results ) );
index = admin_adminlog_index;
for( i = 0; i < 10; i++ )
{
int prev;
prev = index - 1;
if( prev < 0 )
prev = MAX_ADMIN_ADMINLOGS - 1;
if( !g_admin_adminlog[ prev ] )
break;
if( g_admin_adminlog[ prev ]->id > max_id )
max_id = g_admin_adminlog[ prev ]->id;
index = prev;
}
if( G_SayArgc() > 1 + skiparg )
{
G_SayArgv( 1 + skiparg, argbuf, sizeof( argbuf ) );
if( ( *argbuf >= '0' && *argbuf <= '9' ) || *argbuf == '-' )
{
int id;
id = atoi( argbuf );
if( id < 0 )
id += ( max_id - 9 );
else if( id <= max_id - MAX_ADMIN_ADMINLOGS )
id = max_id - MAX_ADMIN_ADMINLOGS + 1;
if( id + 9 >= max_id )
id = max_id - 9;
if( id < 1 )
id = 1;
for( i = 0; i < MAX_ADMIN_ADMINLOGS; i++ )
{
if( g_admin_adminlog[ i ]->id == id )
{
index = i;
break;
}
}
}
else if ( *argbuf == '!' )
{
search_cmd = argbuf + 1;
}
else
{
search_name = argbuf;
}
if( G_SayArgc() > 2 + skiparg && ( search_cmd || search_name ) )
{
char skipbuf[ 4 ];
G_SayArgv( 2 + skiparg, skipbuf, sizeof( skipbuf ) );
skip = atoi( skipbuf );
}
}
if( search_cmd || search_name )
{
g_admin_adminlog_t *result_swap[ 10 ];
memset( result_swap, 0, sizeof( result_swap ) );
index = admin_adminlog_index - 1;
if( index < 0 )
index = MAX_ADMIN_ADMINLOGS - 1;
while( g_admin_adminlog[ index ] &&
checked < MAX_ADMIN_ADMINLOGS &&
result_index < 10 )
{
match = qfalse;
if( search_cmd )
{
if( !Q_stricmp( search_cmd, g_admin_adminlog[ index ]->command ) )
match = qtrue;
}
if( search_name )
{
G_SanitiseName( g_admin_adminlog[ index ]->name, n1 );
if( strstr( n1, search_name ) )
match = qtrue;
}
if( match && skip > 0 )
{
match = qfalse;
skip--;
skipped++;
}
if( match )
{
result_swap[ result_index ] = g_admin_adminlog[ index ];
result_index++;
}
checked++;
index--;
if( index < 0 )
index = MAX_ADMIN_ADMINLOGS - 1;
}
// search runs backwards, turn it around
for( i = 0; i < result_index; i++ )
results[ i ] = result_swap[ result_index - i - 1 ];
}
else
{
while( g_admin_adminlog[ index ] && result_index < 10 )
{
results[ result_index ] = g_admin_adminlog[ index ];
result_index++;
index++;
if( index >= MAX_ADMIN_ADMINLOGS )
index = 0;
}
}
for( i = 0; results[ i ] && i < 10; i++ )
{
int l;
G_DecolorString( results[ i ]->name, n1 );
l = strlen( n1 );
if( l > name_length )
name_length = l;
}
ADMBP_begin( );
for( i = 0; results[ i ] && i < 10; i++ )
{
char levelbuf[ 3 ];
int t;
t = results[ i ]->time / 1000;
G_DecolorString( results[ i ]->name, n1 );
Com_sprintf( fmt_name, sizeof( fmt_name ), "%%%ds",
( name_length + strlen( results[ i ]->name ) - strlen( n1 ) ) );
Com_sprintf( n1, sizeof( n1 ), fmt_name, results[ i ]->name );
Com_sprintf( levelbuf, sizeof( levelbuf ), "%2d", results[ i ]->level );
ADMBP( va( "%s%3d %3d:%02d %2s ^7%s^7 %s!%s ^7%s^7\n",
( results[ i ]->success ) ? "^7" : "^1",
results[ i ]->id,
t / 60, t % 60,
( results[ i ]->level ) < 10000 ? levelbuf : " -",
n1,
( results[ i ]->success ) ? "^3" : "^1",
results[ i ]->command,
results[ i ]->args ) );
}
if( search_cmd || search_name )
{
ADMBP( va( "^3!adminlog:^7 Showing %d matches for '%s^7'.",
result_index,
argbuf ) );
if( checked < MAX_ADMIN_ADMINLOGS && g_admin_adminlog[ checked ] )
ADMBP( va( " run '!adminlog %s^7 %d' to see more",
argbuf,
skipped + result_index ) );
ADMBP( "\n" );
}
else if ( results[ 0 ] )
{
ADMBP( va( "^3!adminlog:^7 Showing %d - %d of %d.\n",
results[ 0 ]->id,
results[ result_index - 1 ]->id,
max_id ) );
}
else
{
ADMBP( "^3!adminlog:^7 log is empty.\n" );
}
ADMBP_end( );
return qtrue;
}
void G_admin_maplog_update( void )
{
char map[ 64 ];
+17
View File
@@ -36,6 +36,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#define MAX_ADMIN_BANS 1024
#define MAX_ADMIN_NAMELOGS 128
#define MAX_ADMIN_NAMELOG_NAMES 5
#define MAX_ADMIN_ADMINLOGS 128
#define MAX_ADMIN_ADMINLOG_ARGS 50
#define MAX_ADMIN_FLAGS 64
#define MAX_ADMIN_COMMANDS 64
#define MAX_ADMIN_CMD_LEN 20
@@ -146,6 +148,18 @@ typedef struct g_admin_namelog
}
g_admin_namelog_t;
typedef struct g_admin_adminlog
{
char name[ MAX_NAME_LENGTH ];
char command[ MAX_ADMIN_CMD_LEN ];
char args[ MAX_ADMIN_ADMINLOG_ARGS ];
int id;
int time;
int level;
qboolean success;
}
g_admin_adminlog_t;
qboolean G_admin_ban_check( char *userinfo, char *reason, int rlen );
qboolean G_admin_cmd_check( gentity_t *ent, qboolean say );
qboolean G_admin_readconfig( gentity_t *ent, int skiparg );
@@ -201,6 +215,9 @@ qboolean G_admin_L0( gentity_t *ent, int skiparg );
qboolean G_admin_listmaps( gentity_t *ent, int skiparg );
qboolean G_admin_immunity( gentity_t *ent, int skiparg );
qboolean G_admin_suspendban( gentity_t *ent, int skiparg );
qboolean G_admin_adminlog( gentity_t *ent, int skiparg );
void G_admin_adminlog_cleanup( void );
void G_admin_adminlog_log( gentity_t *ent, char *command, int skiparg, qboolean success );
qboolean G_admin_maplog( gentity_t *ent, int skiparg );
void G_admin_maplog_update( void );
void G_admin_maplog_result( char *flag );
+7
View File
@@ -1967,6 +1967,13 @@ void HMedistat_Think( gentity_t *self )
if( self->enemy->health >= self->enemy->client->ps.stats[ STAT_MAX_HEALTH ] &&
!BG_InventoryContainsUpgrade( UP_MEDKIT, self->enemy->client->ps.stats ) )
BG_AddUpgradeToInventory( UP_MEDKIT, self->enemy->client->ps.stats );
//if completely healed, cancel retribution
if( self->enemy->health >= self->enemy->client->ps.stats[ STAT_MAX_HEALTH ] )
{
for( i = 0; i < MAX_CLIENTS; i++ )
self->enemy->client->tkcredits[ i ] = 0;
}
}
}
}
+9 -2
View File
@@ -1713,13 +1713,20 @@ void Cmd_CallVote_f( gentity_t *ent )
// start the voting, the caller autoamtically votes yes
level.voteTime = level.time;
level.voteYes = 1;
level.voteNo = 0;
for( i = 0 ; i < level.maxclients ; i++ )
level.clients[i].ps.eFlags &= ~EF_VOTED;
ent->client->ps.eFlags |= EF_VOTED;
if( !Q_stricmp( arg1, "poll" ) )
{
level.voteYes = 0;
}
else
{
level.voteYes = 1;
ent->client->ps.eFlags |= EF_VOTED;
}
trap_SetConfigstring( CS_VOTE_TIME, va( "%i", level.voteTime ) );
trap_SetConfigstring( CS_VOTE_STRING, level.voteDisplayString );
+112 -39
View File
@@ -135,6 +135,7 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int
int killer;
int i, j;
char *killerName, *obit;
float totalTK = 0;
float totalDamage = 0.0f;
float percentDamage = 0.0f;
gentity_t *player;
@@ -291,46 +292,8 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int
{
AddScore( attacker, -1 );
// Retribution: transfer value of player from attacker to victim
if( g_retribution.integer) {
if(attacker!=self){
int max = ALIEN_MAX_KILLS, tk_value = 0;
char *type = "evos";
if( attacker->client->ps.stats[ STAT_PTEAM ] == PTE_ALIENS ) {
tk_value = BG_ClassCanEvolveFromTo( PCL_ALIEN_LEVEL0,
self->client->ps.stats[ STAT_PCLASS ], ALIEN_MAX_KILLS, 0 );
} else {
tk_value = BG_GetValueOfEquipment( &self->client->ps );
max = HUMAN_MAX_CREDITS;
type = "credits";
}
if( attacker->client->ps.persistant[ PERS_CREDIT ] < tk_value )
tk_value = attacker->client->ps.persistant[ PERS_CREDIT ];
if( self->client->ps.persistant[ PERS_CREDIT ]+tk_value > max )
tk_value = max-self->client->ps.persistant[ PERS_CREDIT ];
if( tk_value > 0 ) {
// adjust using the retribution cvar (in percent)
tk_value = tk_value*g_retribution.integer/100;
G_AddCreditToClient( self->client, tk_value, qtrue );
G_AddCreditToClient( attacker->client, -tk_value, qtrue );
trap_SendServerCommand( self->client->ps.clientNum,
va( "print \"Received ^3%d %s ^7from %s ^7in retribution.\n\"",
tk_value, type, attacker->client->pers.netname ) );
trap_SendServerCommand( attacker->client->ps.clientNum,
va( "print \"Transfered ^3%d %s ^7to %s ^7in retribution.\n\"",
tk_value, type, self->client->pers.netname ) );
}
}
}
// Normal teamkill penalty
else {
if( !g_retribution.integer ) {
if( attacker->client->ps.stats[ STAT_PTEAM ] == PTE_ALIENS )
G_AddCreditToClient( attacker->client, -FREEKILL_ALIEN, qtrue );
else if( attacker->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS )
@@ -371,7 +334,117 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int
//total up all the damage done by every client
for( i = 0; i < MAX_CLIENTS; i++ )
{
totalDamage += (float)self->credits[ i ];
totalTK += (float)self->client->tkcredits[ i ];
}
// punish players for damaging teammates
if ( g_retribution.integer && totalTK )
{
int totalPrice;
int max = HUMAN_MAX_CREDITS;
if ( self->client->ps.stats[ STAT_PTEAM ] == PTE_ALIENS )
{
totalPrice = BG_ClassCanEvolveFromTo( PCL_ALIEN_LEVEL0, self->client->ps.stats[ STAT_PCLASS ], ALIEN_MAX_KILLS, 0 );
max = ALIEN_MAX_KILLS;
}
else
{
totalPrice = BG_GetValueOfEquipment( &self->client->ps );
}
if ( self->client->ps.persistant[ PERS_CREDIT ] + totalPrice > max )
totalPrice = max - self->client->ps.persistant[ PERS_CREDIT ];
if ( totalPrice )
{
totalTK += totalDamage;
if( totalTK < self->client->ps.stats[ STAT_MAX_HEALTH ] )
totalTK = self->client->ps.stats[ STAT_MAX_HEALTH ];
if ( self->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS )
{
for ( i = 0; i < MAX_CLIENTS; i++ )
{
int price;
// no retribution if self damage or enemmy damage or building damage or no damage from this client
if ( i == self - g_entities || !g_entities[ i ].client || !OnSameTeam( &g_entities[ i ], self ) || !self->client->tkcredits[ i ] )
continue;
// calculate retribution price (rounded up)
price = ( totalPrice * self->client->tkcredits[ i ] ) / totalTK + 0.5f;
self->client->tkcredits[ i ] = 0;
// check for enough credits
if ( g_entities[ i ].client->ps.persistant[ PERS_CREDIT ] < price )
price = g_entities[ i ].client->ps.persistant[ PERS_CREDIT ];
if ( price )
{
G_AddCreditToClient( self->client, price, qtrue );
G_AddCreditToClient( g_entities[ i ].client, -price, qtrue );
trap_SendServerCommand( self->client->ps.clientNum, va( "print \"Received ^3%d credits ^7from %s ^7in retribution.\n\"", price, g_entities[ i ].client->pers.netname ) );
trap_SendServerCommand( g_entities[ i ].client->ps.clientNum, va( "print \"Transfered ^3%d credits ^7to %s ^7in retribution.\n\"", price, self->client->pers.netname ) );
}
}
}
else
{
int toPay[ MAX_CLIENTS ] = { 0 };
int frags = totalPrice;
int damageForEvo = totalTK / totalPrice;
for ( i = 0; i < MAX_CLIENTS; i++ )
{
// no retribution if self damage or enemmy damage or building damage or no damage from this client
if ( i == self - g_entities || !g_entities[ i ].client || !OnSameTeam( &g_entities[ i ], self ) || !self->client->tkcredits[ i ] )
continue;
// find out how many full evos this client needs to pay
toPay[ i ] = ( totalPrice * self->client->tkcredits[ i ] ) / totalTK;
if ( toPay[ i ] > g_entities[ i ].client->ps.persistant[ PERS_CREDIT ] )
toPay[ i ] = g_entities[ i ].client->ps.persistant[ PERS_CREDIT ];
frags -= toPay[ i ];
self->client->tkcredits[ i ] -= damageForEvo * toPay[ i ];
}
// if we have not met the evo count, continue stealing evos
while ( 1 )
{
int maximum = 0;
int topClient = 0;
for ( i = 0; i < MAX_CLIENTS; i++ )
{
if ( self->client->tkcredits[ i ] > maximum && g_entities[ i ].client->ps.persistant[ PERS_CREDIT ] )
{
maximum = self->client->tkcredits[ i ];
topClient = i;
}
}
if ( !maximum )
break;
toPay[ topClient ]++;
self->client->tkcredits[ topClient ] = 0;
frags--;
if ( !frags )
break;
}
// now move the evos around
for ( i = 0; i < MAX_CLIENTS; i++ )
{
if ( !toPay[ i ] )
continue;
G_AddCreditToClient( self->client, toPay[ i ], qtrue );
G_AddCreditToClient( g_entities[ i ].client, -toPay[ i ], qtrue );
trap_SendServerCommand( self->client->ps.clientNum, va( "print \"Received ^3%d ^7evos from %s ^7in retribution.\n\"", toPay[ i ], g_entities[ i ].client->pers.netname ) );
trap_SendServerCommand( g_entities[ i ].client->ps.clientNum, va( "print \"Transfered ^3%d ^7evos to %s ^7in retribution.\n\"", toPay[ i ], self->client->pers.netname ) );
}
}
}
}
// if players did more than DAMAGE_FRACTION_FOR_KILL increment the stage counters
if( !OnSameTeam( self, attacker ) && totalDamage >= ( self->client->ps.stats[ STAT_MAX_HEALTH ] * DAMAGE_FRACTION_FOR_KILL ) )
+1
View File
@@ -809,6 +809,7 @@ void G_ShutdownGame( int restart )
G_admin_cleanup( );
G_admin_namelog_cleanup( );
G_admin_adminlog_cleanup( );
level.restarted = qfalse;
level.surrenderTeam = PTE_NONE;