From a9a39a92f75dc8343e78570a3ebe91c2a7698bd3 Mon Sep 17 00:00:00 2001 From: MaeJong Date: Tue, 18 Apr 2017 00:40:47 +0200 Subject: Purify r/arc/list, add rshow to view reports/archives in detail --- src/game/g_admin.c | 152 ++++++++++++++++++++++++++++++++++++++++++++++------- src/game/g_admin.h | 1 + 2 files changed, 134 insertions(+), 19 deletions(-) diff --git a/src/game/g_admin.c b/src/game/g_admin.c index 79dfb71..fed3c63 100644 --- a/src/game/g_admin.c +++ b/src/game/g_admin.c @@ -350,6 +350,11 @@ g_admin_cmd_t g_admin_cmds[ ] = "purges a report or archive entry", "[^3report#^7] (^3!^7) - ^3!^7 means archive instead of report" }, + + {"rshow", G_admin_rshow, "reportmanage", + "shows a report/archive entry in its entirety", + "[^3rshow#^7] (^3!^7) [report#] - ^3!^7 shows archive instead of report" + }, {"seen", G_admin_seen, "seen", "find the last time a player was on the server", @@ -9293,6 +9298,7 @@ qboolean G_admin_rlist( gentity_t *ent, int skiparg ) char reporter_fmt[ 32 ] = { "%s" }; char name_match[ MAX_NAME_LENGTH ] = {""}; char duration[ 32 ]; + char reason[ 81 ]; char *ip_match = NULL; int i, t; int show_count = 0; @@ -9506,18 +9512,25 @@ qboolean G_admin_rlist( gentity_t *ent, int skiparg ) secs = ( report->expires - t ); G_admin_duration( secs, duration, sizeof( duration ) ); - ADMBP( va( "%4i %s^7 %-15s Expires: %s\n | Reported by: %-15s^7 Level:%2i\n | ^5%s^7\n | Made: %s^7 on ^3%s^7 with ^3%i^7 players online\n | Admins online: %s^7\n \\__ ^5Note: %s^7\n", + if( strlen(report->reason) > 80 ) + { + strncpy( reason, report->reason, 77 ); + strcat( reason, "..." ); + } else { + strncpy( reason, report->reason, 80 ); + } + + ADMBP( va( "%4i %s^7 %-15s Expires: %s\n" + " | Reported by: %-15s^7 Level:%2i\n" + " | ^5%s^7\n" + " \\__ ^5Note: %s^7\n", ( i + 1 ), n1, report->ip, duration, n2, report->level, - report->reason, - report->time, - report->map, - report->players, - report->admins, + reason, report->note ) ); show_count++; @@ -9792,6 +9805,7 @@ qboolean G_admin_rarclist( gentity_t *ent, int skiparg ) char reporter_fmt[ 32 ] = { "%s" }; char name_match[ MAX_NAME_LENGTH ] = {""}; char duration[ 32 ]; + char reason[ 81 ]; char *ip_match = NULL; int show_count = 0; int max_name = 1, max_reporter = 1; @@ -9968,19 +9982,26 @@ qboolean G_admin_rarclist( gentity_t *ent, int skiparg ) secs = ( archive->expires - t ); G_admin_duration( secs, duration, sizeof( duration ) ); - ADMBP( va( "%4i %s^7 %-15s Archive expires in: %s\n | Reported by: %-15s^7 Level:%2i\n | ^5%s^7\n | Made: %s^7 on ^3%s^7 with ^3%i^7 players online\n | Admins online: %s\n \\__ Note: ^5%s^7\n", - ( i + 1 ), - n1, - archive->ip, - duration, - n2, - archive->level, - archive->reason, - archive->time, - archive->map, - archive->players, - archive->admins, - archive->note ) ); + if( strlen(archive->reason) > 80 ) + { + strncpy( reason, archive->reason, 77 ); + strcat( reason, "..." ); + } else { + strncpy( reason, archive->reason, 80 ); + } + + ADMBP( va( "%4i %s^7 %-15s Expires: %s\n" + " | Reported by: %-15s^7 Level:%2i\n" + " | ^5%s^7\n" + " \\__ ^5Note: %s^7\n", + ( i + 1 ), + n1, + archive->ip, + duration, + n2, + archive->level, + reason, + archive->note ) ); } show_count++; } @@ -10147,6 +10168,99 @@ qboolean G_admin_rnote( gentity_t *ent, int skiparg ) return qtrue; } +qboolean G_admin_rshow( gentity_t *ent, int skiparg ) +{ + char tmp[ 2 ]; + char arg2[ 5 ]; + char duration[ 32 ]; + int ID, secs, t; + g_admin_report_t *report; + g_admin_archive_t *archive; + qtime_t qt; + + t = trap_RealTime( &qt ); + + if( G_SayArgc() < 2 + skiparg ) + { + ADMP( "^3!rshow: ^7usage: !rshow [report#] (!) - adding ! shows archive# instead of report#\n" ); + return qfalse; + } + + G_SayArgv( 1 + skiparg, arg2, sizeof( arg2 ) ); + ID = atoi( arg2 ); + G_SayArgv( 2 + skiparg, tmp, sizeof( tmp ) ); + + archive = g_admin_archives[ ID ]; + report = g_admin_reports[ ID ]; + + if( !strcmp( tmp, "!" ) ) + { + if( ID < 1 || + ID > MAX_ADMIN_ARCHIVES || + !archive ) + { + ADMP( "^3!rshow: ^7invalid archive#\n" ); + return qfalse; + } + + secs = ( archive->expires - t ); + G_admin_duration( secs, duration, sizeof( duration ) ); + + ADMP( va( "%4i %s^7 %-15s Expires: %s\n" + " | Reported by: %-15s^7 Level:%2i\n" + " | ^5%s^7\n" + " | Made: %s^7 on ^3%s^7 with ^3%i^7 players online\n" + " | Admins online: %s^7\n" + " \\__ ^5Note: %s^7\n", + ID, + archive->name, + archive->ip, + duration, + archive->rep, + archive->level, + archive->reason, + archive->time, + archive->map, + archive->players, + archive->admins, + archive->note ) ); + + return qtrue; + + } + else if( ID < 1 || + ID > MAX_ADMIN_REPORTS || + !report ) + { + ADMP( "^3!rshow: ^7invalid report#\n" ); + return qfalse; + } + + secs = ( report->expires - t ); + G_admin_duration( secs, duration, sizeof( duration ) ); + + ADMP( va( "%4i %s^7 %-15s Expires: %s\n" + " | Reported by: %-15s^7 Level:%2i\n" + " | ^5%s^7\n" + " | Made: %s^7 on ^3%s^7 with ^3%i^7 players online\n" + " | Admins online: %s^7\n" + " \\__ ^5Note: %s^7\n", + ID, + report->name, + report->ip, + duration, + report->rep, + report->level, + report->reason, + report->time, + report->map, + report->players, + report->admins, + report->note ) ); + + return qtrue; +} + qboolean G_admin_scrim(gentity_t *ent, int skiparg ) { char state[5]; diff --git a/src/game/g_admin.h b/src/game/g_admin.h index 61d4353..0850cea 100644 --- a/src/game/g_admin.h +++ b/src/game/g_admin.h @@ -359,6 +359,7 @@ qboolean G_admin_rarclist( gentity_t *ent, int skiparg ); qboolean G_admin_rclose( gentity_t *ent, int skiparg ); qboolean G_admin_rpurge( gentity_t *ent, int skiparg ); qboolean G_admin_rnote( gentity_t *ent, int skiparg ); +qboolean G_admin_rshow( gentity_t *ent, int skiparg ); qboolean G_admin_scrim( gentity_t *ent, int skiparg ); -- cgit From 2c275bb955473de03c0e5400cb342847098eda4d Mon Sep 17 00:00:00 2001 From: MaeJong Date: Tue, 18 Apr 2017 01:32:01 +0200 Subject: Fix off-by-1 error in rshow --- src/game/g_admin.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/game/g_admin.c b/src/game/g_admin.c index fed3c63..14b2cc1 100644 --- a/src/game/g_admin.c +++ b/src/game/g_admin.c @@ -9548,11 +9548,11 @@ qboolean G_admin_rlist( gentity_t *ent, int skiparg ) else Com_sprintf( matchmethod, sizeof(matchmethod), "ip range size" ); - ADMBP( va( "^3!rlist:^7 found %d matching reports by %s.", + ADMBP( va( "^3!rlist:^7 found %d matching reports by %s. ", show_count, matchmethod ) ); } else { - ADMBP( va( "^3!rlist:^7 showing reports %d - %d of %d.", + ADMBP( va( "^3!rlist:^7 showing reports %d - %d of %d. ", ( found ) ? ( start + 1 ) : 0, ( ( start + MAX_ADMIN_SHOWREPORTS ) > found ) ? found : ( start + MAX_ADMIN_SHOWREPORTS ), @@ -9566,7 +9566,7 @@ qboolean G_admin_rlist( gentity_t *ent, int skiparg ) (filter[0]) ? filter : "" ) ); } - ADMBP( "^3rlist:^7 run ^3!rshow^7 to see all details about a report" ); + ADMBP( "Run ^3!rshow^7 to see full report\n" ); ADMBP( "\n" ); ADMBP_end(); @@ -10017,13 +10017,13 @@ qboolean G_admin_rarclist( gentity_t *ent, int skiparg ) Com_sprintf( matchmethod, sizeof(matchmethod), "ip range size" ); - ADMBP( va( "^3!rarclist:^7 found %d matching archived reports by %s. ", + ADMBP( va( "^3!rarclist:^7 found %d matching archived reports by %s. ", show_count, matchmethod ) ); } else { - ADMBP( va( "^3!rarclist:^7 showing archived reports %d - %d of %d. ", + ADMBP( va( "^3!rarclist:^7 showing archived reports %d - %d of %d. ", ( found ) ? ( start + 1 ) : 0, ( ( start + MAX_ADMIN_SHOWREPORTS ) > found ) ? found : ( start + MAX_ADMIN_SHOWREPORTS ), @@ -10037,7 +10037,7 @@ qboolean G_admin_rarclist( gentity_t *ent, int skiparg ) (filter[0]) ? filter : "" ) ); } - ADMBP( "^3rlist:^7 run ^3!rshow^7 ^5!^7 to see all details about an archive" ); + ADMBP( "Run ^3!rshow^7 ^5!^7 to see full archive\n" ); ADMBP( "\n" ); ADMBP_end(); @@ -10190,8 +10190,8 @@ qboolean G_admin_rshow( gentity_t *ent, int skiparg ) ID = atoi( arg2 ); G_SayArgv( 2 + skiparg, tmp, sizeof( tmp ) ); - archive = g_admin_archives[ ID ]; - report = g_admin_reports[ ID ]; + archive = g_admin_archives[ ID - 1 ]; + report = g_admin_reports[ ID - 1 ]; if( !strcmp( tmp, "!" ) ) { -- cgit From 0474368df3200337bb2dcf2d3b3f10fa7b60929f Mon Sep 17 00:00:00 2001 From: MaeJong Date: Tue, 18 Apr 2017 01:39:54 +0200 Subject: Eradicate \nazis in rlist --- src/game/g_admin.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/game/g_admin.c b/src/game/g_admin.c index 14b2cc1..3b37b32 100644 --- a/src/game/g_admin.c +++ b/src/game/g_admin.c @@ -9566,7 +9566,7 @@ qboolean G_admin_rlist( gentity_t *ent, int skiparg ) (filter[0]) ? filter : "" ) ); } - ADMBP( "Run ^3!rshow^7 to see full report\n" ); + ADMBP( "Run ^3!rshow^7 to see full report" ); ADMBP( "\n" ); ADMBP_end(); @@ -10037,7 +10037,7 @@ qboolean G_admin_rarclist( gentity_t *ent, int skiparg ) (filter[0]) ? filter : "" ) ); } - ADMBP( "Run ^3!rshow^7 ^5!^7 to see full archive\n" ); + ADMBP( "Run ^3!rshow^7 ^5!^7 to see full archive" ); ADMBP( "\n" ); ADMBP_end(); -- cgit From fb1c012ae1dfb56a1393e20571c2faf1f271a817 Mon Sep 17 00:00:00 2001 From: MaeJong Date: Tue, 18 Apr 2017 01:41:10 +0200 Subject: Add a \nazi in rban auth check --- src/game/g_admin.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game/g_admin.c b/src/game/g_admin.c index 3b37b32..365229f 100644 --- a/src/game/g_admin.c +++ b/src/game/g_admin.c @@ -9626,7 +9626,7 @@ qboolean G_admin_rban( gentity_t *ent, int skiparg ) if( admin_guid_to_level( ent->client->pers.guid ) < admin_guid_to_level( report->guid ) ) { - ADMP( "Your target has a higher admin level than you." ); + ADMP( "Your target has a higher admin level than you.\n" ); return qfalse; } -- cgit From b8db90f6dbf6c894ebc1bfccbbf61fdb27025bc1 Mon Sep 17 00:00:00 2001 From: MaeJong Date: Tue, 18 Apr 2017 23:47:33 +0200 Subject: Implement g_reportAdminListMinLvl Specifies the minimum level needed for a player's name to be written in the "admins" field in reports. Defaults to 4 --- src/game/g_admin.c | 2 +- src/game/g_local.h | 1 + src/game/g_main.c | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/game/g_admin.c b/src/game/g_admin.c index 365229f..c5f18d3 100644 --- a/src/game/g_admin.c +++ b/src/game/g_admin.c @@ -9259,7 +9259,7 @@ qboolean G_admin_report( gentity_t *ent, int skiparg ) { vic = &g_entities[ i ]; - if( G_admin_level( vic ) >= 3 ) + if( G_admin_level( vic ) >= g_reportAdminListMinLvl ) { Q_strcat( admins, sizeof(admins), va( "%s^7 ", G_admin_get_adminname( vic ) ) ); } diff --git a/src/game/g_local.h b/src/game/g_local.h index 5835385..8edcc71 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -1539,6 +1539,7 @@ extern vmCvar_t g_maxReports; extern vmCvar_t g_maxUnregReports; extern vmCvar_t g_reportWelcomeComment; +extern vmCvar_t g_reportAdminListMinLvl; extern vmCvar_t g_schachtmeisterClearThreshold; extern vmCvar_t g_schachtmeisterAutobahnThreshold; diff --git a/src/game/g_main.c b/src/game/g_main.c index cd53e3f..4c68925 100644 --- a/src/game/g_main.c +++ b/src/game/g_main.c @@ -279,6 +279,7 @@ vmCvar_t g_maxReports; vmCvar_t g_maxUnregReports; vmCvar_t g_reportWelcomeComment; +vmCvar_t g_reportAdminListMinLvl; vmCvar_t g_schachtmeisterClearThreshold; vmCvar_t g_schachtmeisterAutobahnThreshold; @@ -546,6 +547,7 @@ static cvarTable_t gameCvarTable[ ] = { &g_maxUnregReports, "g_maxUnregReports", "1", CVAR_ARCHIVE, 0, qfalse }, { &g_reportWelcomeComment, "g_reportWelcomeComment", "", CVAR_ARCHIVE, 0, qfalse }, + { &g_reportAdminListMinLvl, "g_reportAdminListMinLvl", "4", CVAR_ARCHIVE, 0, qfalse }, { &g_scrimMode, "g_scrimMode", "0", CVAR_ARCHIVE, 0, qfalse }, -- cgit From 02ce015ecc5a946cebdef6e25ad4da466c6c7a98 Mon Sep 17 00:00:00 2001 From: MaeJong Date: Wed, 19 Apr 2017 00:05:34 +0200 Subject: g_adminListMinLvl.integer, dumbass --- src/game/g_admin.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game/g_admin.c b/src/game/g_admin.c index c5f18d3..a7c4477 100644 --- a/src/game/g_admin.c +++ b/src/game/g_admin.c @@ -9259,7 +9259,7 @@ qboolean G_admin_report( gentity_t *ent, int skiparg ) { vic = &g_entities[ i ]; - if( G_admin_level( vic ) >= g_reportAdminListMinLvl ) + if( G_admin_level( vic ) >= g_reportAdminListMinLvl.integer ) { Q_strcat( admins, sizeof(admins), va( "%s^7 ", G_admin_get_adminname( vic ) ) ); } -- cgit