mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-20 06:58:20 +00:00
Merge pull request #996 from Ryozuki/pr_cmd_vote_no
Add vote_no command
This commit is contained in:
commit
8f2ce84f4e
|
@ -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")
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
|
||||
|
|
Loading…
Reference in a new issue