diff --git a/src/game/ddracecommands.h b/src/game/ddracecommands.h index 554fd1a8b..31c69ba77 100644 --- a/src/game/ddracecommands.h +++ b/src/game/ddracecommands.h @@ -48,6 +48,7 @@ CONSOLE_COMMAND("muteip", "s[ip] i[seconds]", 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") +CONSOLE_COMMAND("vote_no", "", CFGFLAG_SERVER, ConVoteNo, this, "Same as \"vote no\"") CONSOLE_COMMAND("freezehammer", "v[id]", CFGFLAG_SERVER|CMDFLAG_TEST, ConFreezeHammer, this, "Gives a player Freeze Hammer") CONSOLE_COMMAND("unfreezehammer", "v[id]", CFGFLAG_SERVER|CMDFLAG_TEST, ConUnFreezeHammer, this, "Removes Freeze Hammer from a player") diff --git a/src/game/server/ddracecommands.cpp b/src/game/server/ddracecommands.cpp index 0feb6fa97..a97e37783 100644 --- a/src/game/server/ddracecommands.cpp +++ b/src/game/server/ddracecommands.cpp @@ -573,3 +573,9 @@ void CGameContext::ConUnFreezeHammer(IConsole::IResult *pResult, void *pUserData pChr->m_FreezeHammer = false; } +void CGameContext::ConVoteNo(IConsole::IResult *pResult, void *pUserData) +{ + CGameContext *pSelf = (CGameContext *)pUserData; + + pSelf->ForceVote(pResult->m_ClientID, false); +} diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index 5f1aa3415..654a9230f 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -2411,20 +2411,10 @@ void CGameContext::ConVote(IConsole::IResult *pResult, void *pUserData) { CGameContext *pSelf = (CGameContext *)pUserData; - // check if there is a vote running - if(!pSelf->m_VoteCloseTime) - return; - if(str_comp_nocase(pResult->GetString(0), "yes") == 0) - pSelf->m_VoteEnforce = CGameContext::VOTE_ENFORCE_YES_ADMIN; + pSelf->ForceVote(pResult->m_ClientID, true); else if(str_comp_nocase(pResult->GetString(0), "no") == 0) - pSelf->m_VoteEnforce = CGameContext::VOTE_ENFORCE_NO_ADMIN; - pSelf->m_VoteEnforcer = pResult->m_ClientID; - char aBuf[256]; - str_format(aBuf, sizeof(aBuf), "moderator forced vote %s", pResult->GetString(0)); - pSelf->SendChatTarget(-1, aBuf); - str_format(aBuf, sizeof(aBuf), "forcing vote %s", pResult->GetString(0)); - pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf); + pSelf->ForceVote(pResult->m_ClientID, false); } void CGameContext::ConchainSpecialMotdupdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData) @@ -3394,3 +3384,20 @@ bool CGameContext::PlayerModerating() } return false; } + +void CGameContext::ForceVote(int EnforcerID, bool Success) +{ + // check if there is a vote running + if(m_VoteCloseTime) + return; + + m_VoteEnforce = Success ? CGameContext::VOTE_ENFORCE_YES_ADMIN : CGameContext::VOTE_ENFORCE_NO_ADMIN; + m_VoteEnforcer = EnforcerID; + + char aBuf[256]; + const char *pOption = Success ? "yes" : "no"; + str_format(aBuf, sizeof(aBuf), "moderator forced vote %s", pOption); + SendChatTarget(-1, aBuf); + str_format(aBuf, sizeof(aBuf), "forcing vote %s", pOption); + Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf); +} diff --git a/src/game/server/gamecontext.h b/src/game/server/gamecontext.h index c88c17512..41dd22b8a 100644 --- a/src/game/server/gamecontext.h +++ b/src/game/server/gamecontext.h @@ -101,6 +101,7 @@ class CGameContext : public IGameServer static void ConForceVote(IConsole::IResult *pResult, void *pUserData); static void ConClearVotes(IConsole::IResult *pResult, void *pUserData); static void ConVote(IConsole::IResult *pResult, void *pUserData); + static void ConVoteNo(IConsole::IResult *pResult, void *pUserData); static void ConchainSpecialMotdupdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); CGameContext(int Resetting); @@ -247,6 +248,7 @@ public: bool PlayerExists(int ClientID) { return m_apPlayers[ClientID]; }; // Returns true if someone is actively moderating. bool PlayerModerating(); + void ForceVote(int EnforcerID, bool Success); private: