From f1af68dff9751c319acad001de2410909d381a24 Mon Sep 17 00:00:00 2001 From: Learath2 Date: Mon, 1 Mar 2021 19:44:59 +0100 Subject: [PATCH] Add initial delay to talking in chat --- src/engine/shared/config_variables.h | 1 + src/game/server/gamecontext.cpp | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/engine/shared/config_variables.h b/src/engine/shared/config_variables.h index 33c7b6456..543a86024 100644 --- a/src/engine/shared/config_variables.h +++ b/src/engine/shared/config_variables.h @@ -327,6 +327,7 @@ MACRO_CONFIG_INT(SvTimeInBroadcastInterval, sv_time_in_broadcast_interval, 1, 0, MACRO_CONFIG_INT(SvDefaultTimerType, sv_default_timer_type, 0, 0, 3, CFGFLAG_SERVER, "Default way of displaying time either game/round timer or broadcast. 0 = game/round timer, 1 = broadcast, 2 = 0+1, 3 = none") // these might need some fine tuning +MACRO_CONFIG_INT(SvChatInitialDelay, sv_chat_initial_delay, 0, 0, 360, CFGFLAG_SERVER, "The time in seconds before the first message can be sent") MACRO_CONFIG_INT(SvChatPenalty, sv_chat_penalty, 250, 50, 1000, CFGFLAG_SERVER, "chat score 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 chats core 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") diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index 5e6a6a66a..a2404e392 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -3743,12 +3743,17 @@ int CGameContext::ProcessSpamProtection(int ClientID) m_apPlayers[ClientID]->m_LastChat = Server()->Tick(); NETADDR Addr; Server()->GetClientAddr(ClientID, &Addr); - int Muted = 0; - for(int i = 0; i < m_NumMutes && !Muted; i++) + int Muted = 0; + if(m_apPlayers[ClientID]->m_JoinTick > m_NonEmptySince + 10 * Server()->TickSpeed()) + Muted = (m_apPlayers[ClientID]->m_JoinTick + Server()->TickSpeed() * g_Config.m_SvChatInitialDelay - Server()->Tick()) / Server()->TickSpeed(); + if(Muted <= 0) { - if(!net_addr_comp_noport(&Addr, &m_aMutes[i].m_Addr)) - Muted = (m_aMutes[i].m_Expire - Server()->Tick()) / Server()->TickSpeed(); + for(int i = 0; i < m_NumMutes && Muted <= 0; i++) + { + if(!net_addr_comp_noport(&Addr, &m_aMutes[i].m_Addr)) + Muted = (m_aMutes[i].m_Expire - Server()->Tick()) / Server()->TickSpeed(); + } } if(Muted > 0)