| 4958 | } |
| 4959 | |
| 4960 | bool 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 | |
| 5000 | int CGameContext::GetDDRaceTeam(int ClientId) const |
| 5001 | { |
no test coverage detected