automatic mute on spam

This commit is contained in:
fisted 2011-02-03 14:39:00 +01:00
parent 00f47c18c4
commit addbf8e3d6
4 changed files with 20 additions and 0 deletions

View file

@ -600,6 +600,15 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId)
return;
}
if ((p->m_ChatScore += g_Config.m_SvChatPenalty) > g_Config.m_SvChatThreshold)
{
char aIP[16];
Server()->GetClientIP(ClientId, aIP, sizeof aIP);
Mute(aIP, g_Config.m_SvSpamMuteDuration, Server()->ClientName(ClientId));
p->m_ChatScore = 0;
return;
}
// check for invalid chars
unsigned char *pMessage = (unsigned char *)pMsg->m_pMessage;
while (*pMessage)

View file

@ -19,6 +19,7 @@ CPlayer::CPlayer(CGameContext *pGameServer, int CID, int Team)
this->m_ClientID = CID;
m_Team = GameServer()->m_pController->ClampTeam(Team);
m_LastActionTick = Server()->Tick();
m_ChatScore = 0;
}
CPlayer::~CPlayer()
@ -35,6 +36,9 @@ void CPlayer::Tick()
if(!Server()->ClientIngame(m_ClientID))
return;
if (m_ChatScore > 0)
m_ChatScore--;
Server()->SetClientScore(m_ClientID, m_Score);
// do latency stuff

View file

@ -70,6 +70,8 @@ public:
int m_TargetX;
int m_TargetY;
} m_LatestActivity;
int m_ChatScore;
private:
CCharacter *Character;

View file

@ -64,6 +64,11 @@ MACRO_CONFIG_STR(SvGametype, sv_gametype, 32, "dm", CFGFLAG_SERVER, "Game type (
MACRO_CONFIG_INT(SvTournamentMode, sv_tournament_mode, 0, 0, 1, CFGFLAG_SERVER, "Tournament mode. When enabled, players joins the server as spectator")
MACRO_CONFIG_INT(SvSpamprotection, sv_spamprotection, 1, 0, 1, CFGFLAG_SERVER, "Spam protection")
// these might need some fine tuning
MACRO_CONFIG_INT(SvChatPenalty, sv_chat_penalty, 250, 50, 1000, CFGFLAG_SERVER, "chatscore will be increased by this on every message, and decremented by 1 on every tick.")
MACRO_CONFIG_INT(SvChatThreshold, sv_chat_threshold, 1000, 50, 10000 , CFGFLAG_SERVER, "if chatscore exceeds this, the player will be muted for sv_spam_mute_duration seconds")
MACRO_CONFIG_INT(SvSpamMuteDuration, sv_spam_mute_duration, 60, 0, 3600 , CFGFLAG_SERVER, "how many seconds to mute, if player triggers mute on spam. 0 = off")
MACRO_CONFIG_INT(SvSpectatorSlots, sv_spectator_slots, 0, 0, MAX_CLIENTS, CFGFLAG_SERVER, "Number of slots to reserve for spectators")
MACRO_CONFIG_INT(SvTeambalanceTime, sv_teambalance_time, 1, 0, 1000, CFGFLAG_SERVER, "How many minutes to wait before autobalancing teams")
MACRO_CONFIG_INT(SvInactiveKickTime, sv_inactivekick_time, 3, 0, 1000, CFGFLAG_SERVER, "How many minutes to wait before taking care of inactive players")