From bf57f0b7a4c7093f7af54587d02d710b62a7da41 Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Tue, 6 Mar 2018 22:06:57 +0100 Subject: Log all Autobahn events. --- src/game/g_admin.c | 11 +++++++---- src/game/g_client.c | 33 +++++++++++++++++++++++++++++++++ src/game/g_local.h | 2 ++ src/game/g_main.c | 2 ++ 4 files changed, 44 insertions(+), 4 deletions(-) diff --git a/src/game/g_admin.c b/src/game/g_admin.c index 61e0c1c..c3341d0 100644 --- a/src/game/g_admin.c +++ b/src/game/g_admin.c @@ -3496,12 +3496,15 @@ static void admin_autobahn(gentity_t *ent, int rating) if (rating >= g_schachtmeisterClearThreshold.integer) return; - G_AdminsPrintf("%s^7 (#%d) has rating %d\n", ent->client->pers.netname, - ent - g_entities, rating); - // Ban only if the rating is low enough. - if (rating > g_schachtmeisterAutobahnThreshold.integer) + if (rating > g_schachtmeisterAutobahnThreshold.integer) { + G_AdminsPrintf("%s^7 (#%d) has rating %d\n", + ent->client->pers.netname, ent - g_entities, + rating); return; + } + + G_LogAutobahn(ent, NULL, rating, qfalse); if (!ent->client->pers.isPlaceholder) trap_SendServerCommand(ent - g_entities, va("disconnect \"%s\"\n", diff --git a/src/game/g_client.c b/src/game/g_client.c index 6e941f5..8119e3b 100644 --- a/src/game/g_client.c +++ b/src/game/g_client.c @@ -1374,6 +1374,36 @@ void ClientUserinfoChanged( int clientNum, qboolean forceName ) /*G_LogPrintf( "ClientUserinfoChanged: %i %s\n", clientNum, userinfo );*/ } +/* +=========== +LogAutobahn +=========== +*/ +void G_LogAutobahn(gentity_t *ent, const char *userinfo, int rating, + qboolean onConnect) +{ + char ip_buffer[20]; + const char *ip, *name, *verb; + + verb = (onConnect ? "refused" : "dropped"); + + if (userinfo) { + Q_strncpyz(ip_buffer, Info_ValueForKey(userinfo, "ip"), + sizeof(ip_buffer)); + ip = ip_buffer; + name = Info_ValueForKey(userinfo, "name"); + } else { + ip = ent->client->pers.ip; + name = ent->client->pers.netname; + } + + G_LogPrintf("Autobahn: %s %i %s %+i \"%s^7\"\n", verb, ent - g_entities, + ip, rating, name); + + if (g_adminAutobahnNotify.integer) + G_AdminsPrintf("Autobahn %s \"%s^7\" with rating %+i, connecting from %s.\n", + verb, name, rating, ip); +} /* =========== @@ -1507,7 +1537,10 @@ const char *ClientConnect( int clientNum, qboolean firstTime, qboolean isPlaceho if (j->rating >= g_schachtmeisterClearThreshold.integer) break; else if (j->rating <= g_schachtmeisterAutobahnThreshold.integer) + { + G_LogAutobahn( ent, userinfo, j->rating, qtrue ); return g_schachtmeisterAutobahnMessage.string; + } smj = j; } break; diff --git a/src/game/g_local.h b/src/game/g_local.h index e59a6ad..489b52a 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -1129,6 +1129,7 @@ void ClientSpawn( gentity_t *ent, gentity_t *spawn, vec3_t origin, vec3_t a void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int mod ); qboolean SpotWouldTelefrag( gentity_t *spot ); char *G_NextNewbieName( gentity_t *ent ); +void G_LogAutobahn( gentity_t *ent, const char *userinfo, int rating, qboolean onConnect ); // // g_svcmds.c @@ -1491,6 +1492,7 @@ extern vmCvar_t g_karma; extern vmCvar_t g_chat; extern vmCvar_t g_adminExpireTime; extern vmCvar_t g_adminCurses; +extern vmCvar_t g_adminAutobahnNotify; extern vmCvar_t g_nullifyTyrantKills; diff --git a/src/game/g_main.c b/src/game/g_main.c index 82c963d..b2e329a 100644 --- a/src/game/g_main.c +++ b/src/game/g_main.c @@ -191,6 +191,7 @@ vmCvar_t g_adminRegisterAdminLevel; vmCvar_t g_minLevelToJoinTeam; vmCvar_t g_forceAutoSelect; vmCvar_t g_adminCurses; +vmCvar_t g_adminAutobahnNotify; vmCvar_t g_privateMessages; vmCvar_t g_logPrivateMessages; @@ -495,6 +496,7 @@ static cvarTable_t gameCvarTable[ ] = { &g_chat, "g_chat", "chat.dat", CVAR_ARCHIVE, 0, qfalse }, { &g_adminExpireTime, "g_adminExpireTime", "0", CVAR_ARCHIVE, 0, qfalse }, { &g_adminCurses, "g_adminCurses", "1", CVAR_ARCHIVE, 0, qfalse }, + { &g_adminAutobahnNotify, "g_adminAutobahnNotify", "1", CVAR_ARCHIVE, 0, qfalse }, { &g_devmapKillerHP, "g_devmapKillerHP", "0", CVAR_ARCHIVE, 0, qtrue }, { &g_killerHP, "g_killerHP", "0", CVAR_ARCHIVE, 0, qfalse }, -- cgit