mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Merge #2102
2102: Add reason to mute r=def- a=trafilaw Co-authored-by: trafilaw <gitlawsserver@outlook.de>
This commit is contained in:
commit
1b546b3e48
|
@ -46,8 +46,8 @@ CONSOLE_COMMAND("vote_mute", "v[id] i[seconds]", CFGFLAG_SERVER, ConVoteMute, th
|
|||
CONSOLE_COMMAND("vote_unmute", "v[id]", CFGFLAG_SERVER, ConVoteUnmute, this, "Give back v's right to vote.")
|
||||
CONSOLE_COMMAND("vote_mutes", "", CFGFLAG_SERVER, ConVoteMutes, this, "List the current active vote mutes.")
|
||||
CONSOLE_COMMAND("mute", "", CFGFLAG_SERVER, ConMute, this, "")
|
||||
CONSOLE_COMMAND("muteid", "v[id] i[seconds]", CFGFLAG_SERVER, ConMuteID, this, "")
|
||||
CONSOLE_COMMAND("muteip", "s[ip] i[seconds]", CFGFLAG_SERVER, ConMuteIP, this, "")
|
||||
CONSOLE_COMMAND("muteid", "v[id] i[seconds] ?r[reason]", CFGFLAG_SERVER, ConMuteID, this, "")
|
||||
CONSOLE_COMMAND("muteip", "s[ip] i[seconds] ?r[reason]", CFGFLAG_SERVER, ConMuteIP, this, "")
|
||||
CONSOLE_COMMAND("unmute", "v[id]", CFGFLAG_SERVER, ConUnmute, this, "")
|
||||
CONSOLE_COMMAND("mutes", "", CFGFLAG_SERVER, ConMutes, this, "")
|
||||
CONSOLE_COMMAND("moderate", "", CFGFLAG_SERVER, ConModerate, this, "Enables/disables active moderator mode for the player")
|
||||
|
|
|
@ -409,7 +409,7 @@ bool CGameContext::VoteUnmute(const NETADDR *pAddr, const char *pDisplayName, in
|
|||
return false;
|
||||
}
|
||||
|
||||
bool CGameContext::TryMute(const NETADDR *pAddr, int Secs)
|
||||
bool CGameContext::TryMute(const NETADDR *pAddr, int Secs, const char *pReason)
|
||||
{
|
||||
// find a matching mute for this ip, update expiration time if found
|
||||
for(int i = 0; i < m_NumMutes; i++)
|
||||
|
@ -418,6 +418,7 @@ bool CGameContext::TryMute(const NETADDR *pAddr, int Secs)
|
|||
{
|
||||
m_aMutes[i].m_Expire = Server()->Tick()
|
||||
+ Secs * Server()->TickSpeed();
|
||||
str_copy(m_aMutes[i].m_aReason, pReason, sizeof(m_aMutes[i].m_aReason));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -428,6 +429,7 @@ bool CGameContext::TryMute(const NETADDR *pAddr, int Secs)
|
|||
m_aMutes[m_NumMutes].m_Addr = *pAddr;
|
||||
m_aMutes[m_NumMutes].m_Expire = Server()->Tick()
|
||||
+ Secs * Server()->TickSpeed();
|
||||
str_copy(m_aMutes[m_NumMutes].m_aReason, pReason, sizeof(m_aMutes[m_NumMutes].m_aReason));
|
||||
m_NumMutes++;
|
||||
return true;
|
||||
}
|
||||
|
@ -436,17 +438,19 @@ bool CGameContext::TryMute(const NETADDR *pAddr, int Secs)
|
|||
return false;
|
||||
}
|
||||
|
||||
void CGameContext::Mute(const NETADDR *pAddr, int Secs, const char *pDisplayName)
|
||||
void CGameContext::Mute(const NETADDR *pAddr, int Secs, const char *pDisplayName, const char *pReason)
|
||||
{
|
||||
if (!TryMute(pAddr, Secs))
|
||||
if (!TryMute(pAddr, Secs, pReason))
|
||||
return;
|
||||
|
||||
if(!pDisplayName)
|
||||
return;
|
||||
|
||||
char aBuf[128];
|
||||
str_format(aBuf, sizeof aBuf, "'%s' has been muted for %d seconds.",
|
||||
pDisplayName, Secs);
|
||||
if (pReason[0])
|
||||
str_format(aBuf, sizeof aBuf, "'%s' has been muted for %d seconds (%s)", pDisplayName, Secs, pReason);
|
||||
else
|
||||
str_format(aBuf, sizeof aBuf, "'%s' has been muted for %d seconds", pDisplayName, Secs);
|
||||
SendChat(-1, CHAT_ALL, aBuf);
|
||||
}
|
||||
|
||||
|
@ -532,7 +536,7 @@ void CGameContext::ConMute(IConsole::IResult *pResult, void *pUserData)
|
|||
pSelf->Console()->Print(
|
||||
IConsole::OUTPUT_LEVEL_STANDARD,
|
||||
"mutes",
|
||||
"Use either 'muteid <client_id> <seconds>' or 'muteip <ip> <seconds>'");
|
||||
"Use either 'muteid <client_id> <seconds> <reason>' or 'muteip <ip> <seconds> <reason>'");
|
||||
}
|
||||
|
||||
// mute through client id
|
||||
|
@ -550,8 +554,10 @@ void CGameContext::ConMuteID(IConsole::IResult *pResult, void *pUserData)
|
|||
NETADDR Addr;
|
||||
pSelf->Server()->GetClientAddr(Victim, &Addr);
|
||||
|
||||
const char *pReason = pResult->NumArguments() > 2 ? pResult->GetString(2) : "";
|
||||
|
||||
pSelf->Mute(&Addr, clamp(pResult->GetInteger(1), 1, 86400),
|
||||
pSelf->Server()->ClientName(Victim));
|
||||
pSelf->Server()->ClientName(Victim), pReason);
|
||||
}
|
||||
|
||||
// mute through ip, arguments reversed to workaround parsing
|
||||
|
@ -564,7 +570,8 @@ void CGameContext::ConMuteIP(IConsole::IResult *pResult, void *pUserData)
|
|||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "mutes",
|
||||
"Invalid network address to mute");
|
||||
}
|
||||
pSelf->Mute(&Addr, clamp(pResult->GetInteger(1), 1, 86400), NULL);
|
||||
const char *pReason = pResult->NumArguments() > 2 ? pResult->GetString(2) : "";
|
||||
pSelf->Mute(&Addr, clamp(pResult->GetInteger(1), 1, 86400), NULL, pReason);
|
||||
}
|
||||
|
||||
// unmute by mute list index
|
||||
|
@ -607,8 +614,8 @@ void CGameContext::ConMutes(IConsole::IResult *pResult, void *pUserData)
|
|||
for (int i = 0; i < pSelf->m_NumMutes; i++)
|
||||
{
|
||||
net_addr_str(&pSelf->m_aMutes[i].m_Addr, aIpBuf, sizeof(aIpBuf), false);
|
||||
str_format(aBuf, sizeof aBuf, "%d: \"%s\", %d seconds left", i, aIpBuf,
|
||||
(pSelf->m_aMutes[i].m_Expire - pSelf->Server()->Tick()) / pSelf->Server()->TickSpeed());
|
||||
str_format(aBuf, sizeof aBuf, "%d: \"%s\", %d seconds left (%s)", i, aIpBuf,
|
||||
(pSelf->m_aMutes[i].m_Expire - pSelf->Server()->Tick()) / pSelf->Server()->TickSpeed(), pSelf->m_aMutes[i].m_aReason);
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "mutes", aBuf);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -380,14 +380,15 @@ private:
|
|||
{
|
||||
NETADDR m_Addr;
|
||||
int m_Expire;
|
||||
char m_aReason[128];
|
||||
};
|
||||
|
||||
CMute m_aMutes[MAX_MUTES];
|
||||
int m_NumMutes;
|
||||
CMute m_aVoteMutes[MAX_VOTE_MUTES];
|
||||
int m_NumVoteMutes;
|
||||
bool TryMute(const NETADDR *pAddr, int Secs);
|
||||
void Mute(const NETADDR *pAddr, int Secs, const char *pDisplayName);
|
||||
bool TryMute(const NETADDR *pAddr, int Secs, const char *pReason);
|
||||
void Mute(const NETADDR *pAddr, int Secs, const char *pDisplayName, const char *pReason = "");
|
||||
bool TryVoteMute(const NETADDR *pAddr, int Secs);
|
||||
bool VoteMute(const NETADDR *pAddr, int Secs, const char *pDisplayName, int AuthedID);
|
||||
bool VoteUnmute(const NETADDR *pAddr, const char *pDisplayName, int AuthedID);
|
||||
|
|
Loading…
Reference in a new issue