Merge pull request #8568 from def-/pr-whispers

Add option to disable whispers
This commit is contained in:
heinrich5991 2024-08-14 08:21:57 +00:00 committed by GitHub
commit 1a0f28c5bd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 27 additions and 11 deletions

View file

@ -505,16 +505,22 @@ void CGameContext::ConDND(IConsole::IResult *pResult, void *pUserData)
if(!pPlayer) if(!pPlayer)
return; return;
if(pPlayer->m_DND) 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");
pPlayer->m_DND = false; }
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "chatresp", "You will receive global chat and server messages");
} void CGameContext::ConWhispers(IConsole::IResult *pResult, void *pUserData)
else {
{ CGameContext *pSelf = (CGameContext *)pUserData;
pPlayer->m_DND = true; if(!CheckClientId(pResult->m_ClientId))
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "chatresp", "You will not receive any further global chat and server messages"); 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) void CGameContext::ConMap(IConsole::IResult *pResult, void *pUserData)

View file

@ -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("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("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("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("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("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"); 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); SendChatTarget(ClientId, aBuf);
} }
if(!m_apPlayers[VictimId]->m_Whispers)
{
SendChatTarget(ClientId, "This person has disabled receiving whispers");
return;
}
if(Server()->IsSixup(VictimId)) if(Server()->IsSixup(VictimId))
{ {
protocol7::CNetMsg_Sv_Chat Msg; protocol7::CNetMsg_Sv_Chat Msg;

View file

@ -431,6 +431,7 @@ private:
static void ConTimeCP(IConsole::IResult *pResult, void *pUserData); static void ConTimeCP(IConsole::IResult *pResult, void *pUserData);
static void ConDND(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 ConMapInfo(IConsole::IResult *pResult, void *pUserData);
static void ConTimeout(IConsole::IResult *pResult, void *pUserData); static void ConTimeout(IConsole::IResult *pResult, void *pUserData);
static void ConPractice(IConsole::IResult *pResult, void *pUserData); static void ConPractice(IConsole::IResult *pResult, void *pUserData);

View file

@ -116,6 +116,7 @@ void CPlayer::Reset()
m_Paused = PAUSE_NONE; m_Paused = PAUSE_NONE;
m_DND = false; m_DND = false;
m_Whispers = true;
m_LastPause = 0; m_LastPause = 0;
m_Score.reset(); m_Score.reset();

View file

@ -172,6 +172,7 @@ public:
}; };
bool m_DND; bool m_DND;
bool m_Whispers;
int64_t m_FirstVoteTick; int64_t m_FirstVoteTick;
char m_aTimeoutCode[64]; char m_aTimeoutCode[64];