diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index 60af8855a..bcba0208d 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -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) diff --git a/src/game/server/player.cpp b/src/game/server/player.cpp index 3f32d6af1..c2cdb82bb 100644 --- a/src/game/server/player.cpp +++ b/src/game/server/player.cpp @@ -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 diff --git a/src/game/server/player.h b/src/game/server/player.h index c4c413fc1..2bb07d2f9 100644 --- a/src/game/server/player.h +++ b/src/game/server/player.h @@ -70,6 +70,8 @@ public: int m_TargetX; int m_TargetY; } m_LatestActivity; + + int m_ChatScore; private: CCharacter *Character; diff --git a/src/game/variables.h b/src/game/variables.h index 0621f6afa..bcf5c6463 100644 --- a/src/game/variables.h +++ b/src/game/variables.h @@ -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")