From 1e88ad92a09b9c247919be5a7973ce08276b7af1 Mon Sep 17 00:00:00 2001 From: Ryozuki Date: Thu, 18 Jan 2018 07:56:07 +0100 Subject: [PATCH] add vote_no command and show auth rank in force vote --- src/game/ddracecommands.h | 1 + src/game/server/ddracecommands.cpp | 17 +++++++++++++++++ src/game/server/gamecontext.cpp | 3 ++- src/game/server/gamecontext.h | 1 + src/game/server/player.cpp | 14 ++++++++++++++ src/game/server/player.h | 2 ++ 6 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/game/ddracecommands.h b/src/game/ddracecommands.h index 554fd1a8b..9dbee4244 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\", used by helpers") 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..8bc2a19dc 100644 --- a/src/game/server/ddracecommands.cpp +++ b/src/game/server/ddracecommands.cpp @@ -573,3 +573,20 @@ void CGameContext::ConUnFreezeHammer(IConsole::IResult *pResult, void *pUserData pChr->m_FreezeHammer = false; } +void CGameContext::ConVoteNo(IConsole::IResult *pResult, void *pUserData) +{ + CGameContext *pSelf = (CGameContext *)pUserData; + + // check if there is a vote running + if(!pSelf->m_VoteCloseTime) + return; + + pSelf->m_VoteEnforce = CGameContext::VOTE_ENFORCE_NO_ADMIN; + pSelf->m_VoteEnforcer = pResult->m_ClientID; + char aBuf[256]; + str_format(aBuf, sizeof(aBuf), "%s forced vote %s", pResult->GetString(0), + pSelf->m_apPlayers[pResult->m_ClientID]->GetAuthStateName(true)); + pSelf->SendChatTarget(-1, aBuf); + str_format(aBuf, sizeof(aBuf), "forcing vote %s", pResult->GetString(0)); + pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf); +} \ No newline at end of file diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index 5f1aa3415..191bc79e1 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -2421,7 +2421,8 @@ void CGameContext::ConVote(IConsole::IResult *pResult, void *pUserData) 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)); + str_format(aBuf, sizeof(aBuf), "%s forced vote %s", pResult->GetString(0), + pSelf->m_apPlayers[pResult->m_ClientID]->GetAuthStateName(true)); pSelf->SendChatTarget(-1, aBuf); str_format(aBuf, sizeof(aBuf), "forcing vote %s", pResult->GetString(0)); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf); diff --git a/src/game/server/gamecontext.h b/src/game/server/gamecontext.h index c88c17512..5bb469841 100644 --- a/src/game/server/gamecontext.h +++ b/src/game/server/gamecontext.h @@ -336,6 +336,7 @@ private: static void ConSetTimerType(IConsole::IResult *pResult, void *pUserData); static void ConRescue(IConsole::IResult *pResult, void *pUserData); static void ConProtectedKill(IConsole::IResult *pResult, void *pUserData); + static void ConVoteNo(IConsole::IResult *pResult, void *pUserData); static void ConMute(IConsole::IResult *pResult, void *pUserData); static void ConMuteID(IConsole::IResult *pResult, void *pUserData); diff --git a/src/game/server/player.cpp b/src/game/server/player.cpp index aba398ed0..09b05b8cf 100644 --- a/src/game/server/player.cpp +++ b/src/game/server/player.cpp @@ -778,3 +778,17 @@ void CPlayer::SpectatePlayerName(const char *pName) } } } + +const char* CPlayer::GetAuthStateName(bool IsFirstWord) +{ + int State = Server()->GetAuthedState(m_ClientID); + + if(State == IServer::AUTHED_HELPER) + return IsFirstWord ? "Helper" : "helper"; + if(State == IServer::AUTHED_MOD) + return IsFirstWord ? "Moderator" : "moderator"; + if(State == IServer::AUTHED_NO) + return IsFirstWord ? "Admin" : "admin"; + + return IsFirstWord ? "User" : "user"; +} diff --git a/src/game/server/player.h b/src/game/server/player.h index 60ce2fce6..7141640bd 100644 --- a/src/game/server/player.h +++ b/src/game/server/player.h @@ -160,6 +160,8 @@ public: int Pause(int State, bool Force); int ForcePause(int Time); int IsPaused(); + + const char* GetAuthStateName(bool IsFirstWord = false); bool IsPlaying(); int64 m_Last_KickVote;