MCPcopy Create free account
hub / github.com/ddnet/ddnet / ProcessSpamProtection

Method ProcessSpamProtection

src/game/server/gamecontext.cpp:4960–4998  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4958}
4959
4960bool CGameContext::ProcessSpamProtection(int ClientId, bool RespectChatInitialDelay)
4961{
4962 if(!m_apPlayers[ClientId])
4963 return false;
4964 if(g_Config.m_SvSpamprotection && m_apPlayers[ClientId]->m_LastChat && m_apPlayers[ClientId]->m_LastChat + Server()->TickSpeed() * g_Config.m_SvChatDelay > Server()->Tick())
4965 return true;
4966 else if(g_Config.m_SvDnsblChat && Server()->DnsblBlack(ClientId))
4967 {
4968 SendChatTarget(ClientId, "Players are not allowed to chat from VPNs at this time");
4969 return true;
4970 }
4971 else
4972 m_apPlayers[ClientId]->m_LastChat = Server()->Tick();
4973
4974 const std::optional<CMute> Muted = m_Mutes.IsMuted(Server()->ClientAddr(ClientId), RespectChatInitialDelay);
4975 if(Muted.has_value())
4976 {
4977 char aChatMessage[128];
4978 if(Muted->m_InitialDelay)
4979 {
4980 str_format(aChatMessage, sizeof(aChatMessage), "This server has an initial chat delay, you will be able to talk in %d seconds.", Muted->SecondsLeft());
4981 }
4982 else
4983 {
4984 str_format(aChatMessage, sizeof(aChatMessage), "You are not permitted to talk for the next %d seconds.", Muted->SecondsLeft());
4985 }
4986 SendChatTarget(ClientId, aChatMessage);
4987 return true;
4988 }
4989
4990 if(g_Config.m_SvSpamMuteDuration && (m_apPlayers[ClientId]->m_ChatScore += g_Config.m_SvChatPenalty) > g_Config.m_SvChatThreshold)
4991 {
4992 MuteWithMessage(Server()->ClientAddr(ClientId), g_Config.m_SvSpamMuteDuration, "Spam protection", Server()->ClientName(ClientId));
4993 m_apPlayers[ClientId]->m_ChatScore = 0;
4994 return true;
4995 }
4996
4997 return false;
4998}
4999
5000int CGameContext::GetDDRaceTeam(int ClientId) const
5001{

Callers 8

ConPracticeMethod · 0.80
ConUnPracticeMethod · 0.80
ConSwapMethod · 0.80
ConLockMethod · 0.80
ConUnlockMethod · 0.80
ConTeam0ModeMethod · 0.80
ConJoinMethod · 0.80
ProcessScoreResultMethod · 0.80

Calls 9

str_formatFunction · 0.85
TickSpeedMethod · 0.80
DnsblBlackMethod · 0.80
IsMutedMethod · 0.80
ClientNameMethod · 0.80
ServerClass · 0.50
TickMethod · 0.45
ClientAddrMethod · 0.45
SecondsLeftMethod · 0.45

Tested by

no test coverage detected