mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-18 05:58:19 +00:00
Merge pull request #8568 from def-/pr-whispers
Add option to disable whispers
This commit is contained in:
commit
1a0f28c5bd
|
@ -505,16 +505,22 @@ void CGameContext::ConDND(IConsole::IResult *pResult, void *pUserData)
|
|||
if(!pPlayer)
|
||||
return;
|
||||
|
||||
if(pPlayer->m_DND)
|
||||
{
|
||||
pPlayer->m_DND = false;
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "chatresp", "You will receive global chat and server messages");
|
||||
}
|
||||
else
|
||||
{
|
||||
pPlayer->m_DND = true;
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "chatresp", "You will not receive any further global chat and server messages");
|
||||
}
|
||||
pPlayer->m_DND = pResult->NumArguments() == 0 ? !pPlayer->m_DND : pResult->GetInteger(0);
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "chatresp", pPlayer->m_DND ? "You will not receive any further global chat and server messages" : "You will receive global chat and server messages");
|
||||
}
|
||||
|
||||
void CGameContext::ConWhispers(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
if(!CheckClientId(pResult->m_ClientId))
|
||||
return;
|
||||
|
||||
CPlayer *pPlayer = pSelf->m_apPlayers[pResult->m_ClientId];
|
||||
if(!pPlayer)
|
||||
return;
|
||||
|
||||
pPlayer->m_Whispers = pResult->NumArguments() == 0 ? !pPlayer->m_Whispers : pResult->GetInteger(0);
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "chatresp", pPlayer->m_Whispers ? "You will receive whispers" : "You will not receive any further whispers");
|
||||
}
|
||||
|
||||
void CGameContext::ConMap(IConsole::IResult *pResult, void *pUserData)
|
||||
|
|
|
@ -3659,7 +3659,8 @@ void CGameContext::RegisterChatCommands()
|
|||
Console()->Register("spec", "?r[player name]", CFGFLAG_CHAT | CFGFLAG_SERVER, ConToggleSpec, this, "Toggles spec (if not available behaves as /pause)");
|
||||
Console()->Register("pausevoted", "", CFGFLAG_CHAT | CFGFLAG_SERVER, ConTogglePauseVoted, this, "Toggles pause on the currently voted player");
|
||||
Console()->Register("specvoted", "", CFGFLAG_CHAT | CFGFLAG_SERVER, ConToggleSpecVoted, this, "Toggles spec on the currently voted player");
|
||||
Console()->Register("dnd", "", CFGFLAG_CHAT | CFGFLAG_SERVER | CFGFLAG_NONTEEHISTORIC, ConDND, this, "Toggle Do Not Disturb (no chat and server messages)");
|
||||
Console()->Register("dnd", "?i['0'|'1']", CFGFLAG_CHAT | CFGFLAG_SERVER | CFGFLAG_NONTEEHISTORIC, ConDND, this, "Toggle Do Not Disturb (no chat and server messages)");
|
||||
Console()->Register("whispers", "?i['0'|'1']", CFGFLAG_CHAT | CFGFLAG_SERVER | CFGFLAG_NONTEEHISTORIC, ConWhispers, this, "Toggle receiving whispers");
|
||||
Console()->Register("mapinfo", "?r[map]", CFGFLAG_CHAT | CFGFLAG_SERVER, ConMapInfo, this, "Show info about the map with name r gives (current map by default)");
|
||||
Console()->Register("timeout", "?s[code]", CFGFLAG_CHAT | CFGFLAG_SERVER, ConTimeout, this, "Set timeout protection code s");
|
||||
Console()->Register("practice", "?i['0'|'1']", CFGFLAG_CHAT | CFGFLAG_SERVER, ConPractice, this, "Enable cheats for your current team's run, but you can't earn a rank");
|
||||
|
@ -4615,6 +4616,12 @@ void CGameContext::WhisperId(int ClientId, int VictimId, const char *pMessage)
|
|||
SendChatTarget(ClientId, aBuf);
|
||||
}
|
||||
|
||||
if(!m_apPlayers[VictimId]->m_Whispers)
|
||||
{
|
||||
SendChatTarget(ClientId, "This person has disabled receiving whispers");
|
||||
return;
|
||||
}
|
||||
|
||||
if(Server()->IsSixup(VictimId))
|
||||
{
|
||||
protocol7::CNetMsg_Sv_Chat Msg;
|
||||
|
|
|
@ -431,6 +431,7 @@ private:
|
|||
static void ConTimeCP(IConsole::IResult *pResult, void *pUserData);
|
||||
|
||||
static void ConDND(IConsole::IResult *pResult, void *pUserData);
|
||||
static void ConWhispers(IConsole::IResult *pResult, void *pUserData);
|
||||
static void ConMapInfo(IConsole::IResult *pResult, void *pUserData);
|
||||
static void ConTimeout(IConsole::IResult *pResult, void *pUserData);
|
||||
static void ConPractice(IConsole::IResult *pResult, void *pUserData);
|
||||
|
|
|
@ -116,6 +116,7 @@ void CPlayer::Reset()
|
|||
|
||||
m_Paused = PAUSE_NONE;
|
||||
m_DND = false;
|
||||
m_Whispers = true;
|
||||
|
||||
m_LastPause = 0;
|
||||
m_Score.reset();
|
||||
|
|
|
@ -172,6 +172,7 @@ public:
|
|||
};
|
||||
|
||||
bool m_DND;
|
||||
bool m_Whispers;
|
||||
int64_t m_FirstVoteTick;
|
||||
char m_aTimeoutCode[64];
|
||||
|
||||
|
|
Loading…
Reference in a new issue