3930: Still allow lock/unlock/practice while sv_chat_initial_delay is set r=Jupeyy a=def-

Not sure if we should just allow them whenever someone is muted

Fixes #3929

<!-- What is the motivation for the changes of this pull request -->

## Checklist

- [ ] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: def <dennis@felsin9.de>
This commit is contained in:
bors[bot] 2021-06-23 09:11:17 +00:00 committed by GitHub
commit 0393ac0f88
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 6 deletions

View file

@ -600,7 +600,7 @@ void CGameContext::ConPractice(IConsole::IResult *pResult, void *pUserData)
if(!pPlayer)
return;
if(pSelf->ProcessSpamProtection(pResult->m_ClientID))
if(pSelf->ProcessSpamProtection(pResult->m_ClientID, false))
return;
if(!g_Config.m_SvPractice)
@ -866,7 +866,7 @@ void CGameContext::ConLockTeam(IConsole::IResult *pResult, void *pUserData)
return;
}
if(pSelf->ProcessSpamProtection(pResult->m_ClientID))
if(pSelf->ProcessSpamProtection(pResult->m_ClientID, false))
return;
char aBuf[512];
@ -904,7 +904,7 @@ void CGameContext::ConUnlockTeam(IConsole::IResult *pResult, void *pUserData)
if(Team <= TEAM_FLOCK || Team >= TEAM_SUPER)
return;
if(pSelf->ProcessSpamProtection(pResult->m_ClientID))
if(pSelf->ProcessSpamProtection(pResult->m_ClientID, false))
return;
pSelf->UnlockTeam(pResult->m_ClientID, Team);

View file

@ -3733,7 +3733,7 @@ void CGameContext::SendRecord(int ClientID)
}
}
int CGameContext::ProcessSpamProtection(int ClientID)
int CGameContext::ProcessSpamProtection(int ClientID, bool RespectChatInitialDelay)
{
if(!m_apPlayers[ClientID])
return 0;
@ -3751,7 +3751,7 @@ int CGameContext::ProcessSpamProtection(int ClientID)
Server()->GetClientAddr(ClientID, &Addr);
int Muted = 0;
if(m_apPlayers[ClientID]->m_JoinTick > m_NonEmptySince + 10 * Server()->TickSpeed())
if(m_apPlayers[ClientID]->m_JoinTick > m_NonEmptySince + 10 * Server()->TickSpeed() && RespectChatInitialDelay)
Muted = (m_apPlayers[ClientID]->m_JoinTick + Server()->TickSpeed() * g_Config.m_SvChatInitialDelay - Server()->Tick()) / Server()->TickSpeed();
if(Muted <= 0)
{

View file

@ -274,7 +274,7 @@ public:
// DDRace
bool OnClientDDNetVersionKnown(int ClientID);
virtual void FillAntibot(CAntibotRoundData *pData);
int ProcessSpamProtection(int ClientID);
int ProcessSpamProtection(int ClientID, bool RespectChatInitialDelay = true);
int GetDDRaceTeam(int ClientID);
// Describes the time when the first player joined the server.
int64 m_NonEmptySince;