From 22dc341f791627ceead61d0d31d06ce1b1edbff8 Mon Sep 17 00:00:00 2001 From: Teetime Date: Sat, 22 Oct 2011 20:02:41 +0200 Subject: added automated mute on spamming --- src/game/server/gamecontext.cpp | 33 ++++++++++++++++++++------------- src/game/server/player.cpp | 6 +++++- src/game/server/player.h | 1 + src/game/variables.h | 4 ++++ 4 files changed, 30 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index 7b651486..a22f2415 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -690,6 +690,25 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID) *pMessage = ' '; pMessage++; } + + //Check if the player is muted + char aAddrStr[NETADDR_MAXSTRSIZE] = {0}; + Server()->GetClientAddr(ClientID, aAddrStr, sizeof(aAddrStr)); + int Pos; + if((Pos = Muted(aAddrStr)) > -1) + { + char aBuf[128]; + int Expires = (m_aMutes[Pos].m_Expires - Server()->Tick())/Server()->TickSpeed(); + str_format(aBuf, sizeof(aBuf), "You are muted for %d minutes and %d seconds.", Expires/60, Expires%60); + SendChatTarget(ClientID, aBuf); + return; + } + else if((pPlayer->m_ChatTicks += g_Config.m_SvChatValue) > g_Config.m_SvChatThreshold) //is he spamming? + { + AddMute(ClientID, 60); + pPlayer->m_ChatTicks = 0; + return; + } /* begin zCatch*/ if(!str_comp("/info", pMsg->m_pMessage) || !str_comp("/about", pMsg->m_pMessage)) @@ -728,20 +747,8 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID) else if(!str_comp_num("/", pMsg->m_pMessage, 1)) SendChatTarget(ClientID, "Unknown command."); else - { - char aAddrStr[NETADDR_MAXSTRSIZE] = {0}; - Server()->GetClientAddr(ClientID, aAddrStr, sizeof(aAddrStr)); - int Pos = Muted(aAddrStr); - if(Pos > -1) - { - char aBuf[128]; - int Expires = (m_aMutes[Pos].m_Expires - Server()->Tick())/Server()->TickSpeed(); - str_format(aBuf, sizeof(aBuf), "You are muted for %d minutes and %d seconds.", Expires/60, Expires%60); - SendChatTarget(ClientID, aBuf); - return; - } SendChat(ClientID, Team, pMsg->m_pMessage); - } + /* end zCatch */ } else if(MsgID == NETMSGTYPE_CL_CALLVOTE) diff --git a/src/game/server/player.cpp b/src/game/server/player.cpp index 4ea2a4a6..ea1e0233 100644 --- a/src/game/server/player.cpp +++ b/src/game/server/player.cpp @@ -31,6 +31,7 @@ CPlayer::CPlayer(CGameContext *pGameServer, int ClientID, int Team) m_LastKillTry = Server()->Tick(); m_TicksSpec = 0; m_TicksIngame = 0; + m_ChatTicks = 0; } CPlayer::~CPlayer() @@ -55,7 +56,10 @@ void CPlayer::Tick() m_TicksSpec++; else m_TicksIngame++; - + + if(m_ChatTicks > 0) + m_ChatTicks--; + /* end zCatch*/ // do latency stuff diff --git a/src/game/server/player.h b/src/game/server/player.h index 05e52f05..fdad4b09 100644 --- a/src/game/server/player.h +++ b/src/game/server/player.h @@ -107,6 +107,7 @@ public: int m_TicksSpec; int m_TicksIngame; + int m_ChatTicks; private: CCharacter *m_pCharacter; diff --git a/src/game/variables.h b/src/game/variables.h index 3166bc84..b2ed91d6 100644 --- a/src/game/variables.h +++ b/src/game/variables.h @@ -96,4 +96,8 @@ MACRO_CONFIG_INT(SvAllowJoin, sv_allow_join, 2, 1, 2, CFGFLAG_SERVER, "Allow new MACRO_CONFIG_INT(SvColorIndicator, sv_color_indicator, 1, 0, 1, CFGFLAG_SERVER, "Color tees apropriate to the number of currently catched players") MACRO_CONFIG_INT(SvBonus, sv_bonus, 0, 0, 10000, CFGFLAG_SERVER, "Give the last player extra points") MACRO_CONFIG_INT(SvFollowCatcher, sv_follow_catcher, 1, 0, 1, CFGFLAG_SERVER, "If a victim should follow his catcher") + +MACRO_CONFIG_INT(SvChatValue, sv_chat_value, 250, 100, 1000, CFGFLAG_SERVER, "A value wich is added on each message and decreased on each tick") +MACRO_CONFIG_INT(SvChatThreshold, sv_chat_threshold, 1000, 250, 10000, CFGFLAG_SERVER, "If this threshold will exceed by too many messages the player will be muted") +MACRO_CONFIG_INT(SvMuteDuration, sv_mute_duration, 60, 0, 3600, CFGFLAG_SERVER, "How long the player will be muted (in seconds)") #endif -- cgit 1.4.1