diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/game/g_admin.c | 185 | ||||
-rw-r--r-- | src/game/g_admin.h | 1 | ||||
-rw-r--r-- | src/game/g_client.c | 6 | ||||
-rw-r--r-- | src/game/g_local.h | 1 | ||||
-rw-r--r-- | src/game/g_main.c | 2 |
5 files changed, 80 insertions, 115 deletions
diff --git a/src/game/g_admin.c b/src/game/g_admin.c index c917e412..850d556e 100644 --- a/src/game/g_admin.c +++ b/src/game/g_admin.c @@ -606,93 +606,47 @@ static void admin_default_levels( void ) admin_level_maxname = 15; } -static void admin_log( gentity_t *admin, char *cmd, int skiparg ) +void G_admin_authlog( gentity_t *ent ) { - fileHandle_t f; - int len; - char string[ MAX_STRING_CHARS ]; - int min, tens, sec; - g_admin_admin_t *a; - g_admin_level_t *l; - char flags[ MAX_ADMIN_FLAGS * 2 ]; - gentity_t *victim = NULL; - int pids[ MAX_CLIENTS ]; - char name[ MAX_NAME_LENGTH ]; - - if( !g_adminLog.string[ 0 ] ) - return; + char aflags[ MAX_ADMIN_FLAGS * 2 ]; + g_admin_level_t *level; + int levelNum = 0; - - len = trap_FS_FOpenFile( g_adminLog.string, &f, FS_APPEND ); - if( len < 0 ) - { - G_Printf( "admin_log: error could not open %s\n", g_adminLog.string ); + if( !ent ) return; - } - sec = level.time / 1000; - min = sec / 60; - sec -= min * 60; - tens = sec / 10; - sec -= tens * 10; + if( ent->client->pers.admin ) + levelNum = ent->client->pers.admin->level; - *flags = '\0'; - if( admin ) - { - if( ( a = admin->client->pers.admin ) ) - Q_strncpyz( flags, a->flags, sizeof( flags ) ); + level = G_admin_level( levelNum ); - if( ( l = G_admin_level( a ? a->level : 0 ) ) && l->flags[ 0 ] ) - { - if( flags[ 0 ] ) - Q_strcat( flags, sizeof( flags ), " " ); - Q_strcat( flags, sizeof( flags ), l->flags ); - } - } + Com_sprintf( aflags, sizeof( aflags ), "%s %s", + ent->client->pers.admin->flags, + ( level ) ? level->flags : "" ); - if( G_SayArgc() > 1 + skiparg ) - { - G_SayArgv( 1 + skiparg, name, sizeof( name ) ); - if( G_ClientNumbersFromString( name, pids, MAX_CLIENTS ) == 1 ) - { - victim = &g_entities[ pids[ 0 ] ]; - } - } + G_LogPrintf( "AdminAuth: %i \"%s" S_COLOR_WHITE "\": \"%s" S_COLOR_WHITE + "\" [%d] (%s): %s\n", + ent - g_entities, ent->client->pers.netname, + ent->client->pers.admin->name, ent->client->pers.admin->level, + ent->client->pers.guid, aflags ); +} - if( victim && Q_stricmp( cmd, "attempted" ) ) - { - Com_sprintf( string, sizeof( string ), - "%3i:%i%i: %i: %s: %s: %s: %s: %s: %s: \"%s\"\n", - min, - tens, - sec, - ( admin ) ? admin->s.clientNum : -1, - ( admin ) ? admin->client->pers.guid - : "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", - ( admin ) ? admin->client->pers.netname : "console", - flags, - cmd, - victim->client->pers.guid, - victim->client->pers.netname, - G_SayConcatArgs( 2 + skiparg ) ); - } - else - { - Com_sprintf( string, sizeof( string ), - "%3i:%i%i: %i: %s: %s: %s: %s: \"%s\"\n", - min, - tens, - sec, - ( admin ) ? admin->s.clientNum : -1, - ( admin ) ? admin->client->pers.guid - : "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", - ( admin ) ? admin->client->pers.netname : "console", - flags, - cmd, - G_SayConcatArgs( 1 + skiparg ) ); - } - trap_FS_Write( string, strlen( string ), f ); - trap_FS_FCloseFile( f ); +static void admin_log( gentity_t *admin, char *cmd, int skiparg ) +{ + char *name; + + name = ( admin ) ? admin->client->pers.netname : "console"; + + G_LogPrintf( "AdminCmd: %i \"%s" S_COLOR_WHITE "\" " + "(\"%s" S_COLOR_WHITE "\") [%d]: %s %s\n", + ( admin ) ? admin->s.clientNum : -1, + name, + ( admin && admin->client->pers.admin ) ? + admin->client->pers.admin->name : name, + ( admin && admin->client->pers.admin ) ? + admin->client->pers.admin->level : 0, + cmd, + G_SayConcatArgs( 1 + skiparg ) ); } static int admin_listadmins( gentity_t *ent, int start, char *search ) @@ -904,7 +858,7 @@ qboolean G_admin_cmd_check( gentity_t *ent, qboolean say ) else { ADMP( va( "^3!%s: ^7permission denied\n", c->command ) ); - admin_log( ent, "attempted", skip - 1 ); + admin_log( ent, S_COLOR_RED "attempted" S_COLOR_WHITE, skip - 1 ); } return qtrue; } @@ -1203,8 +1157,11 @@ qboolean G_admin_readconfig( gentity_t *ent, int skiparg ) for( i = 0; i < level.maxclients; i++ ) { if( level.clients[ i ].pers.connected != CON_DISCONNECTED ) + { level.clients[ i ].pers.admin = G_admin_admin( level.clients[ i ].pers.guid ); + G_admin_authlog( &g_entities[ i ] ); + } } return qtrue; @@ -1357,6 +1314,8 @@ qboolean G_admin_setlevel( gentity_t *ent, int skiparg ) a->name, a->level, ( ent ) ? ent->client->pers.netname : "console" ) ); admin_writeconfig(); + if( vic ) + G_admin_authlog( vic ); return qtrue; } @@ -1368,9 +1327,10 @@ static qboolean admin_create_ban( gentity_t *ent, char *reason ) { g_admin_ban_t *b = NULL; - qtime_t qt; - int t; - int i; + qtime_t qt; + int t; + int i; + char *name; t = trap_RealTime( &qt ); @@ -1398,15 +1358,18 @@ static qboolean admin_create_ban( gentity_t *ent, Q_strncpyz( b->guid, guid, sizeof( b->guid ) ); Q_strncpyz( b->ip, ip, sizeof( b->ip ) ); - //strftime( b->made, sizeof( b->made ), "%m/%d/%y %H:%M:%S", lt ); Com_sprintf( b->made, sizeof( b->made ), "%02i/%02i/%02i %02i:%02i:%02i", qt.tm_mon + 1, qt.tm_mday, qt.tm_year % 100, qt.tm_hour, qt.tm_min, qt.tm_sec ); - if( ent ) - Q_strncpyz( b->banner, ent->client->pers.netname, sizeof( b->banner ) ); + if( ent && ent->client->pers.admin ) + name = ent->client->pers.admin->name; + else if( ent ) + name = ent->client->pers.netname; else - Q_strncpyz( b->banner, "console", sizeof( b->banner ) ); + name = "console"; + + Q_strncpyz( b->banner, name, sizeof( b->banner ) ); if( !seconds ) b->expires = 0; else @@ -2152,15 +2115,15 @@ qboolean G_admin_listlayouts( gentity_t *ent, int skiparg ) qboolean G_admin_listplayers( gentity_t *ent, int skiparg ) { - int i, j; - gclient_t *p; - char c, t; // color and team letter - char n[ MAX_NAME_LENGTH ] = {""}; - char n2[ MAX_NAME_LENGTH ] = {""}; - char n3[ MAX_NAME_LENGTH ] = {""}; - char lname[ MAX_NAME_LENGTH ]; - char muted, denied; - int colorlen; + int i, j; + gclient_t *p; + char c, t; // color and team letter + char *registeredname = NULL; + char lname[ MAX_NAME_LENGTH ]; + char muted, denied; + int colorlen; + char namecleaned[ MAX_NAME_LENGTH ]; + char name2cleaned[ MAX_NAME_LENGTH ]; g_admin_level_t *l, *d = G_admin_level( 0 ); ADMBP_begin(); @@ -2191,19 +2154,18 @@ qboolean G_admin_listplayers( gentity_t *ent, int skiparg ) denied = p->pers.denyBuild ? 'B' : ' '; l = d; - G_SanitiseString( p->pers.netname, n2, sizeof( n2 ) ); - n[ 0 ] = '\0'; - if( p->pers.admin ) + if( ( !ent || !G_admin_permission( &g_entities[ i ], ADMF_INCOGNITO ) ) && + p->pers.admin ) { - if( ent && !G_admin_permission( &g_entities[ i ], ADMF_INCOGNITO ) ) - { - l = G_admin_level( p->pers.admin->level ); - G_SanitiseString( p->pers.admin->name, n3, sizeof( n3 ) ); - if( strcmp( n2, n3 ) ) - Q_strncpyz( n, p->pers.admin->name, sizeof( n ) ); - } + l = G_admin_level( p->pers.admin->level ); + G_SanitiseString( p->pers.netname, + namecleaned, sizeof( namecleaned ) ); + G_SanitiseString( p->pers.admin->name, + name2cleaned, sizeof( name2cleaned ) ); + if( Q_stricmp( namecleaned, name2cleaned ) ) + registeredname = p->pers.admin->name; } - lname[ 0 ] = '\0'; + if( l ) Q_strncpyz( lname, l->name, sizeof( lname ) ); @@ -2213,7 +2175,7 @@ qboolean G_admin_listplayers( gentity_t *ent, int skiparg ) colorlen += 2; } - ADMBP( va( "%2i ^%c%c^7 %-2i %*s^7 (*%s) ^1%c%c^7 %s^7 %s%s^7%s\n", + ADMBP( va( "%2i ^%c%c^7 %-2i %*s^7 (*%s) ^1%c%c^7 %s^7 %s%s%s\n", i, c, t, @@ -2224,9 +2186,10 @@ qboolean G_admin_listplayers( gentity_t *ent, int skiparg ) muted, denied, p->pers.netname, - ( *n ) ? "(a.k.a. " : "", - n, - ( *n ) ? ")" : "" ) ); + ( registeredname ) ? "(a.k.a. " : "", + ( registeredname ) ? registeredname : "", + ( registeredname ) ? S_COLOR_WHITE ")" : "" ) ); + } ADMBP_end(); return qtrue; diff --git a/src/game/g_admin.h b/src/game/g_admin.h index 545a3007..1391cb89 100644 --- a/src/game/g_admin.h +++ b/src/game/g_admin.h @@ -143,6 +143,7 @@ qboolean G_admin_permission( gentity_t *ent, const char *flag ); qboolean G_admin_name_check( gentity_t *ent, char *name, char *err, int len ); void G_admin_namelog_update( gclient_t *ent, qboolean disconnect ); g_admin_admin_t *G_admin_admin( const char *guid ); +void G_admin_authlog( gentity_t *ent ); // ! command functions qboolean G_admin_time( gentity_t *ent, int skiparg ); diff --git a/src/game/g_client.c b/src/game/g_client.c index ca002506..03a63147 100644 --- a/src/game/g_client.c +++ b/src/game/g_client.c @@ -1280,7 +1280,11 @@ char *ClientConnect( int clientNum, qboolean firstTime ) // don't do the "xxx connected" messages if they were caried over from previous level if( firstTime ) - trap_SendServerCommand( -1, va( "print \"%s" S_COLOR_WHITE " connected\n\"", client->pers.netname ) ); + trap_SendServerCommand( -1, va( "print \"%s" S_COLOR_WHITE " connected\n\"", + client->pers.netname ) ); + + if( client->pers.admin ) + G_admin_authlog( ent ); // count current clients and rank for scoreboard CalculateRanks( ); diff --git a/src/game/g_local.h b/src/game/g_local.h index 81f45505..50e73a9e 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -1127,7 +1127,6 @@ extern vmCvar_t g_layoutAuto; extern vmCvar_t g_emoticonsAllowedInNames; extern vmCvar_t g_admin; -extern vmCvar_t g_adminLog; extern vmCvar_t g_adminParseSay; extern vmCvar_t g_adminTempBan; extern vmCvar_t g_adminMaxBan; diff --git a/src/game/g_main.c b/src/game/g_main.c index 01df75d6..4cfd9346 100644 --- a/src/game/g_main.c +++ b/src/game/g_main.c @@ -129,7 +129,6 @@ vmCvar_t g_layoutAuto; vmCvar_t g_emoticonsAllowedInNames; vmCvar_t g_admin; -vmCvar_t g_adminLog; vmCvar_t g_adminParseSay; vmCvar_t g_adminTempBan; vmCvar_t g_adminMaxBan; @@ -257,7 +256,6 @@ static cvarTable_t gameCvarTable[ ] = { &g_emoticonsAllowedInNames, "g_emoticonsAllowedInNames", "1", CVAR_LATCH|CVAR_ARCHIVE, 0, qfalse }, { &g_admin, "g_admin", "admin.dat", CVAR_ARCHIVE, 0, qfalse }, - { &g_adminLog, "g_adminLog", "admin.log", CVAR_ARCHIVE, 0, qfalse }, { &g_adminParseSay, "g_adminParseSay", "1", CVAR_ARCHIVE, 0, qfalse }, { &g_adminTempBan, "g_adminTempBan", "2m", CVAR_ARCHIVE, 0, qfalse }, { &g_adminMaxBan, "g_adminMaxBan", "2w", CVAR_ARCHIVE, 0, qfalse }, |