summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/game/g_admin.c49
-rw-r--r--src/game/g_admin.h11
-rw-r--r--src/game/g_client.c8
3 files changed, 53 insertions, 15 deletions
diff --git a/src/game/g_admin.c b/src/game/g_admin.c
index fbe8eb52..8cf374d3 100644
--- a/src/game/g_admin.c
+++ b/src/game/g_admin.c
@@ -1005,16 +1005,26 @@ void G_admin_namelog_cleanup( )
}
}
-void G_admin_namelog_update( gclient_t *client, int clientNum )
+void G_admin_namelog_update( gclient_t *client, qboolean disconnect )
{
int i, j;
g_admin_namelog_t *namelog;
char n1[ MAX_NAME_LENGTH ];
char n2[ MAX_NAME_LENGTH ];
+ int clientNum = ( client - level.clients );
G_SanitiseName( client->pers.netname, n1 );
for( i = 0; i < MAX_ADMIN_NAMELOGS && g_admin_namelog[ i ]; i++ )
{
+ if( disconnect && g_admin_namelog[ i ]->slot != clientNum )
+ continue;
+
+ if( !disconnect && !( g_admin_namelog[ i ]->slot == clientNum ||
+ g_admin_namelog[ i ]->slot == -1 ) )
+ {
+ continue;
+ }
+
if( !Q_stricmp( client->pers.ip, g_admin_namelog[ i ]->ip )
&& !Q_stricmp( client->pers.guid, g_admin_namelog[ i ]->guid ) )
{
@@ -1029,7 +1039,7 @@ void G_admin_namelog_update( gclient_t *client, int clientNum )
j = MAX_ADMIN_NAMELOG_NAMES - 1;
Q_strncpyz( g_admin_namelog[ i ]->name[ j ], client->pers.netname,
sizeof( g_admin_namelog[ i ]->name[ j ] ) );
- g_admin_namelog[ i ]->slot = clientNum;
+ g_admin_namelog[ i ]->slot = ( disconnect ) ? -1 : clientNum;
return;
}
}
@@ -1046,7 +1056,7 @@ void G_admin_namelog_update( gclient_t *client, int clientNum )
Q_strncpyz( namelog->guid, client->pers.guid, sizeof( namelog->guid ) );
Q_strncpyz( namelog->name[ 0 ], client->pers.netname,
sizeof( namelog->name[ 0 ] ) );
- namelog->slot = clientNum;
+ namelog->slot = ( disconnect ) ? -1 : clientNum;
g_admin_namelog[ i ] = namelog;
}
@@ -1705,11 +1715,35 @@ qboolean G_admin_ban( gentity_t *ent, int skiparg )
{
reason = G_SayConcatArgs( 3 + skiparg );
}
-
+
for( i = 0; i < MAX_ADMIN_NAMELOGS && g_admin_namelog[ i ]; i++ )
{
- if( !Q_stricmp( g_admin_namelog[ i ]->ip, s2 )
- || !Q_stricmp( va( "%d", g_admin_namelog[ i ]->slot ), s2 ) )
+ // skip players in the namelog who have already been banned
+ if( g_admin_namelog[ i ]->banned )
+ continue;
+
+ // skip disconnected players when banning on slot number
+ if( g_admin_namelog[ i ]->slot == -1 )
+ continue;
+
+ if( !Q_stricmp( va( "%d", g_admin_namelog[ i ]->slot ), s2 ) )
+ {
+ logmatches = 1;
+ logmatch = i;
+ exactmatch = qtrue;
+ break;
+ }
+ }
+
+ for( i = 0;
+ !exactmatch && i < MAX_ADMIN_NAMELOGS && g_admin_namelog[ i ];
+ i++ )
+ {
+ // skip players in the namelog who have already been banned
+ if( g_admin_namelog[ i ]->banned )
+ continue;
+
+ if( !Q_stricmp( g_admin_namelog[ i ]->ip, s2 ) )
{
logmatches = 1;
logmatch = i;
@@ -1781,6 +1815,9 @@ qboolean G_admin_ban( gentity_t *ent, int skiparg )
g_admin_namelog[ logmatch ]->guid,
g_admin_namelog[ logmatch ]->ip,
seconds, reason );
+
+ g_admin_namelog[ logmatch ]->banned = qtrue;
+
if( !g_admin.string[ 0 ] )
ADMP( "^3!ban: ^7WARNING g_admin not set, not saving ban to a file\n" );
else
diff --git a/src/game/g_admin.h b/src/game/g_admin.h
index 7958bda3..21e63fa1 100644
--- a/src/game/g_admin.h
+++ b/src/game/g_admin.h
@@ -125,10 +125,11 @@ g_admin_command_t;
typedef struct g_admin_namelog
{
- char name[ MAX_ADMIN_NAMELOG_NAMES ][MAX_NAME_LENGTH ];
- char ip[ 16 ];
- char guid[ 33 ];
- int slot;
+ char name[ MAX_ADMIN_NAMELOG_NAMES ][MAX_NAME_LENGTH ];
+ char ip[ 16 ];
+ char guid[ 33 ];
+ int slot;
+ qboolean banned;
}
g_admin_namelog_t;
@@ -137,7 +138,7 @@ qboolean G_admin_cmd_check( gentity_t *ent, qboolean say );
qboolean G_admin_readconfig( gentity_t *ent, int skiparg );
qboolean G_admin_permission( gentity_t *ent, char flag );
qboolean G_admin_name_check( gentity_t *ent, char *name, char *err, int len );
-void G_admin_namelog_update( gclient_t *ent, int clientNum );
+void G_admin_namelog_update( gclient_t *ent, qboolean disconnect );
int G_admin_level( gentity_t *ent );
// ! command functions
diff --git a/src/game/g_client.c b/src/game/g_client.c
index e2bbf948..6184bad0 100644
--- a/src/game/g_client.c
+++ b/src/game/g_client.c
@@ -1049,7 +1049,7 @@ void ClientUserinfoChanged( int clientNum )
" renamed to %s\n\"", oldname, client->pers.netname ) );
G_LogPrintf( "ClientRename: %i [%s] (%s) \"%s\" -> \"%s\"\n", clientNum,
client->pers.ip, client->pers.guid, oldname, client->pers.netname );
- G_admin_namelog_update( client, clientNum );
+ G_admin_namelog_update( client, qfalse );
}
}
@@ -1259,7 +1259,7 @@ char *ClientConnect( int clientNum, qboolean firstTime )
// count current clients and rank for scoreboard
CalculateRanks( );
- G_admin_namelog_update( client, clientNum );
+ G_admin_namelog_update( client, qfalse );
return NULL;
}
@@ -1311,7 +1311,7 @@ void ClientBegin( int clientNum )
trap_SendServerCommand( -1, va( "print \"%s" S_COLOR_WHITE " entered the game\n\"", client->pers.netname ) );
// name can change between ClientConnect() and ClientBegin()
- G_admin_namelog_update( client, clientNum );
+ G_admin_namelog_update( client, qfalse );
// request the clients PTR code
trap_SendServerCommand( ent - g_entities, "ptrcrequest" );
@@ -1658,7 +1658,7 @@ void ClientDisconnect( int clientNum )
if( !ent->client )
return;
- G_admin_namelog_update( ent->client, -1 );
+ G_admin_namelog_update( ent->client, qtrue );
// stop any following clients
for( i = 0; i < level.maxclients; i++ )