diff --git a/src/game/server/ddracechat.cpp b/src/game/server/ddracechat.cpp index b46594e56..9d75010ed 100644 --- a/src/game/server/ddracechat.cpp +++ b/src/game/server/ddracechat.cpp @@ -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) diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index 1e3c2524d..d119b26e5 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -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; diff --git a/src/game/server/gamecontext.h b/src/game/server/gamecontext.h index 6005801d3..4cbd518ee 100644 --- a/src/game/server/gamecontext.h +++ b/src/game/server/gamecontext.h @@ -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); diff --git a/src/game/server/player.cpp b/src/game/server/player.cpp index d36e631c8..7ee50451e 100644 --- a/src/game/server/player.cpp +++ b/src/game/server/player.cpp @@ -116,6 +116,7 @@ void CPlayer::Reset() m_Paused = PAUSE_NONE; m_DND = false; + m_Whispers = true; m_LastPause = 0; m_Score.reset(); diff --git a/src/game/server/player.h b/src/game/server/player.h index d2b029905..c281ac5b1 100644 --- a/src/game/server/player.h +++ b/src/game/server/player.h @@ -172,6 +172,7 @@ public: }; bool m_DND; + bool m_Whispers; int64_t m_FirstVoteTick; char m_aTimeoutCode[64];