diff options
Diffstat (limited to 'src/game')
| -rw-r--r-- | src/game/g_admin.c | 70 | ||||
| -rw-r--r-- | src/game/g_admin.h | 3 | ||||
| -rw-r--r-- | src/game/g_cmds.c | 10 | ||||
| -rw-r--r-- | src/game/g_local.h | 1 | ||||
| -rw-r--r-- | src/game/g_main.c | 8 | 
5 files changed, 87 insertions, 5 deletions
diff --git a/src/game/g_admin.c b/src/game/g_admin.c index 05fcd2b..98953e2 100644 --- a/src/game/g_admin.c +++ b/src/game/g_admin.c @@ -1809,6 +1809,9 @@ qboolean G_admin_cmd_check( gentity_t *ent, qboolean say )      return qtrue;     } +  if( G_admin_is_restricted( ent, qtrue ) ) +    return qtrue; +    for( i = 0; i < MAX_ADMIN_COMMANDS && g_admin_commands[ i ]; i++ )    {      if( Q_stricmp( cmd, g_admin_commands[ i ]->command ) ) @@ -3416,6 +3419,67 @@ qboolean G_admin_ban( gentity_t *ent, int skiparg )    return qtrue;  } +// If true then don't let the player join a team, use the chat or run commands. +qboolean G_admin_is_restricted(gentity_t *ent, qboolean sendMessage) +{ +	schachtmeisterJudgement_t *j = NULL; +	int i; + +	// Never restrict admins or whitelisted players. +	if (G_admin_permission(ent, ADMF_NOAUTOBAHN) || +	    G_admin_permission(ent, ADMF_IMMUNITY)) +		return qfalse; + +	// Find the relevant namelog. +	// FIXME: this shouldn't require looping over *all* namelogs. +	for (i = 0; i < MAX_ADMIN_NAMELOGS && g_admin_namelog[i]; i++) { +		if (g_admin_namelog[i]->slot == ent - g_entities) { +			j = &g_admin_namelog[i]->smj; +			break; +		} +	} + +	// A missing namelog shouldn't happen. +	if (!j) +		return qfalse; + +	// Restrictions concern only unrated players. +	if (j->ratingTime) +		return qfalse; + +	// Don't wait forever, allow up to 15 seconds. +	if (level.time - j->queryTime > 15000) +		return qfalse; + +	if (sendMessage) +		trap_SendServerCommand(ent - g_entities, "print \"Please wait a moment before doing anything.\n\""); + +	return qtrue; +} + +static void admin_autobahn(gentity_t *ent, int rating) +{ +	// Allow per-GUID exceptions and never autoban admins. +	if (G_admin_permission(ent, ADMF_NOAUTOBAHN) || +	    G_admin_permission(ent, ADMF_IMMUNITY)) +		return; + +	// Don't do anything if the rating is clear. +	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) +		return; + +	trap_SendServerCommand(ent - g_entities, va("disconnect \"%s\"\n", +	                       g_schachtmeisterAutobahnMessage.string)); +	trap_DropClient(ent - g_entities, "dropped by the Autobahn"); +} +  void G_admin_IPA_judgement( const char *ipa, int rating, const char *comment )  {    int i; @@ -3441,6 +3505,9 @@ void G_admin_IPA_judgement( const char *ipa, int rating, const char *comment )        }        else          j->comment = NULL; + +      if( g_admin_namelog[ i ]->slot ) +        admin_autobahn( g_entities + g_admin_namelog[ i ]->slot, j->rating );      }    }  } @@ -7322,7 +7389,8 @@ static AdminFlagListEntry_t adminFlagList[] =    { ADMF_SEESINCOGNITO,        "sees registered name of players flagged with INCOGNITO" },    { ADMF_NOSCRIMRESTRICTION,   "team joining, vote and chat restrictions during scrims do not apply" },    { ADMF_NO_CHAT,              "can not talk" }, -  { ADMF_NO_VOTE,              "can not call votes" } +  { ADMF_NO_VOTE,              "can not call votes" }, +  { ADMF_NOAUTOBAHN,           "ignored by the Autobahn system" }  };  static int adminNumFlags= sizeof( adminFlagList ) / sizeof( adminFlagList[ 0 ] ); diff --git a/src/game/g_admin.h b/src/game/g_admin.h index b6ed952..61d4353 100644 --- a/src/game/g_admin.h +++ b/src/game/g_admin.h @@ -106,6 +106,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA  #define ADMF_NO_CHAT             ".NOCHAT"  #define ADMF_NO_VOTE             ".NOVOTE" +#define ADMF_NOAUTOBAHN          "NOAUTOBAHN" +  #define MAX_ADMIN_LISTITEMS 20  #define MAX_ADMIN_SHOWBANS 10 @@ -374,5 +376,6 @@ void G_admin_namelog_cleanup( void );  void G_admin_report_check( int clientNum );  void G_admin_schachtmeisterFrame( void ); +qboolean G_admin_is_restricted(gentity_t *ent, qboolean sendMessage);  #endif /* ifndef _G_ADMIN_H */ diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index 9b49010..998cafe 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -5326,7 +5326,7 @@ static void Cmd_Ignore_f( gentity_t *ent )  commands_t cmds[ ] = {    // normal commands    { "team", 0, Cmd_Team_f }, -  { "vote", CMD_INTERMISSION, Cmd_Vote_f }, +  { "vote", CMD_MESSAGE|CMD_INTERMISSION, Cmd_Vote_f },    { "ignore", 0, Cmd_Ignore_f },    { "unignore", 0, Cmd_Ignore_f }, @@ -5494,6 +5494,14 @@ void ClientCommand( int clientNum )        "print \"Must be living to use this command\n\"" );      return;    } +   +  // Disallow a large class of commands if a player is restricted. +  if( G_admin_is_restricted( ent, qtrue ) && +      ( !Q_stricmp( cmd, "team" ) || +      ( cmds[ i ].cmdFlags & ( CMD_MESSAGE | CMD_TEAM | CMD_NOTEAM ) ) ) ) +  { +    return; +  }    cmds[ i ].cmdHandler( ent );  } diff --git a/src/game/g_local.h b/src/game/g_local.h index 550803a..5835385 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -1542,6 +1542,7 @@ extern  vmCvar_t  g_reportWelcomeComment;  extern  vmCvar_t  g_schachtmeisterClearThreshold;  extern  vmCvar_t  g_schachtmeisterAutobahnThreshold; +extern  vmCvar_t  g_schachtmeisterAutobahnMessage;  extern  vmCvar_t  g_scrimMode; diff --git a/src/game/g_main.c b/src/game/g_main.c index 5fe4307..cd53e3f 100644 --- a/src/game/g_main.c +++ b/src/game/g_main.c @@ -281,7 +281,8 @@ vmCvar_t  g_maxUnregReports;  vmCvar_t  g_reportWelcomeComment;  vmCvar_t  g_schachtmeisterClearThreshold; -vmCvar_t  g_schachtmeisterAutobahnThreshold; +vmCvar_t  g_schachtmeisterAutobahnThreshold;  +vmCvar_t  g_schachtmeisterAutobahnMessage;  vmCvar_t  g_scrimMode; @@ -548,8 +549,9 @@ static cvarTable_t   gameCvarTable[ ] =    { &g_scrimMode, "g_scrimMode", "0", CVAR_ARCHIVE, 0, qfalse }, -  { &g_schachtmeisterClearThreshold, "g_schachtmeisterClearThreshold", "0", CVAR_ARCHIVE, 0, qfalse }, -  { &g_schachtmeisterAutobahnThreshold, "g_schachtmeisterAutobahnThreshold", "-50", CVAR_ARCHIVE, 0, qfalse }, +  { &g_schachtmeisterClearThreshold, "g_schachtmeisterClearThreshold", "-10", CVAR_ARCHIVE, 0, qfalse }, +  { &g_schachtmeisterAutobahnThreshold, "g_schachtmeisterAutobahnThreshold", "-30", CVAR_ARCHIVE, 0, qfalse }, +  { &g_schachtmeisterAutobahnMessage, "g_schachtmeisterAutobahnMessage", "Your host is blacklisted.", CVAR_ARCHIVE, 0, qfalse },    { &g_revertCooldownTime, "g_revertCooldownTime", "30", CVAR_ARCHIVE, 0, qfalse }  };  | 
