Merge pull request #996 from Ryozuki/pr_cmd_vote_no

Add vote_no command
This commit is contained in:
Dennis Felsing 2018-01-22 20:36:20 +01:00 committed by GitHub
commit 8f2ce84f4e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 12 deletions

View file

@ -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("unmute", "v[id]", CFGFLAG_SERVER, ConUnmute, this, "")
CONSOLE_COMMAND("mutes", "", CFGFLAG_SERVER, ConMutes, 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("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("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") CONSOLE_COMMAND("unfreezehammer", "v[id]", CFGFLAG_SERVER|CMDFLAG_TEST, ConUnFreezeHammer, this, "Removes Freeze Hammer from a player")

View file

@ -573,3 +573,9 @@ void CGameContext::ConUnFreezeHammer(IConsole::IResult *pResult, void *pUserData
pChr->m_FreezeHammer = false; pChr->m_FreezeHammer = false;
} }
void CGameContext::ConVoteNo(IConsole::IResult *pResult, void *pUserData)
{
CGameContext *pSelf = (CGameContext *)pUserData;
pSelf->ForceVote(pResult->m_ClientID, false);
}

View file

@ -2411,20 +2411,10 @@ void CGameContext::ConVote(IConsole::IResult *pResult, void *pUserData)
{ {
CGameContext *pSelf = (CGameContext *)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) 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) else if(str_comp_nocase(pResult->GetString(0), "no") == 0)
pSelf->m_VoteEnforce = CGameContext::VOTE_ENFORCE_NO_ADMIN; pSelf->ForceVote(pResult->m_ClientID, false);
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);
} }
void CGameContext::ConchainSpecialMotdupdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData) void CGameContext::ConchainSpecialMotdupdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData)
@ -3394,3 +3384,20 @@ bool CGameContext::PlayerModerating()
} }
return false; 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);
}

View file

@ -101,6 +101,7 @@ class CGameContext : public IGameServer
static void ConForceVote(IConsole::IResult *pResult, void *pUserData); static void ConForceVote(IConsole::IResult *pResult, void *pUserData);
static void ConClearVotes(IConsole::IResult *pResult, void *pUserData); static void ConClearVotes(IConsole::IResult *pResult, void *pUserData);
static void ConVote(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); static void ConchainSpecialMotdupdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
CGameContext(int Resetting); CGameContext(int Resetting);
@ -247,6 +248,7 @@ public:
bool PlayerExists(int ClientID) { return m_apPlayers[ClientID]; }; bool PlayerExists(int ClientID) { return m_apPlayers[ClientID]; };
// Returns true if someone is actively moderating. // Returns true if someone is actively moderating.
bool PlayerModerating(); bool PlayerModerating();
void ForceVote(int EnforcerID, bool Success);
private: private: