diff options
| author | oy <Tom_Adams@web.de> | 2011-03-25 12:06:45 +0100 |
|---|---|---|
| committer | oy <Tom_Adams@web.de> | 2011-03-25 12:06:45 +0100 |
| commit | 6ece07ee74b8b179d0a66c781a57344bcd75d3d5 (patch) | |
| tree | a6b6f2512a871814cb6b96013311371e84e47cef /src/game/client | |
| parent | 359b806e959fbdced610c2d84d1e12dfe7b58a7e (diff) | |
| download | zcatch-6ece07ee74b8b179d0a66c781a57344bcd75d3d5.tar.gz zcatch-6ece07ee74b8b179d0a66c781a57344bcd75d3d5.zip | |
added force_vote command
Diffstat (limited to 'src/game/client')
| -rw-r--r-- | src/game/client/components/menus_ingame.cpp | 8 | ||||
| -rw-r--r-- | src/game/client/components/voting.cpp | 49 | ||||
| -rw-r--r-- | src/game/client/components/voting.h | 6 | ||||
| -rw-r--r-- | src/game/client/gameclient.cpp | 1 |
4 files changed, 26 insertions, 38 deletions
diff --git a/src/game/client/components/menus_ingame.cpp b/src/game/client/components/menus_ingame.cpp index ad43fc20..06da001a 100644 --- a/src/game/client/components/menus_ingame.cpp +++ b/src/game/client/components/menus_ingame.cpp @@ -442,10 +442,10 @@ void CMenus::RenderServerControl(CUIRect MainView) m_pClient->m_Snap.m_paPlayerInfos[m_CallvoteSelectedPlayer]) { m_pClient->m_pVoting->CallvoteKick(m_CallvoteSelectedPlayer, m_aCallvoteReason); - m_aCallvoteReason[0] = 0; SetActive(false); } } + m_aCallvoteReason[0] = 0; } // render kick reason @@ -469,17 +469,17 @@ void CMenus::RenderServerControl(CUIRect MainView) if(DoButton_Menu(&s_ForceVoteButton, Localize("Force vote"), 0, &Button)) { if(s_ControlPage == 0) - m_pClient->m_pVoting->ForcevoteOption(m_CallvoteSelectedOption, m_aCallvoteReason); + m_pClient->m_pVoting->CallvoteOption(m_CallvoteSelectedOption, m_aCallvoteReason, true); else if(s_ControlPage == 1) { if(m_CallvoteSelectedPlayer >= 0 && m_CallvoteSelectedPlayer < MAX_CLIENTS && m_pClient->m_Snap.m_paPlayerInfos[m_CallvoteSelectedPlayer]) { - m_pClient->m_pVoting->ForcevoteKick(m_CallvoteSelectedPlayer, m_aCallvoteReason); - m_aCallvoteReason[0] = 0; + m_pClient->m_pVoting->CallvoteKick(m_CallvoteSelectedPlayer, m_aCallvoteReason, true); SetActive(false); } } + m_aCallvoteReason[0] = 0; } } } diff --git a/src/game/client/components/voting.cpp b/src/game/client/components/voting.cpp index 808b6669..6e00a5d5 100644 --- a/src/game/client/components/voting.cpp +++ b/src/game/client/components/voting.cpp @@ -31,48 +31,37 @@ void CVoting::Callvote(const char *pType, const char *pValue, const char *pReaso Client()->SendPackMsg(&Msg, MSGFLAG_VITAL); } -void CVoting::CallvoteKick(int ClientID, const char *pReason) +void CVoting::CallvoteKick(int ClientID, const char *pReason, bool ForceVote) { - char aBuf[32]; - str_format(aBuf, sizeof(aBuf), "%d", ClientID); - Callvote("kick", aBuf, pReason); -} - -void CVoting::CallvoteOption(int OptionId, const char *pReason) -{ - CVoteOption *pOption = m_pFirst; - while(pOption && OptionId >= 0) + if(ForceVote) { - if(OptionId == 0) - { - Callvote("option", pOption->m_aDescription, pReason); - break; - } - - OptionId--; - pOption = pOption->m_pNext; + char aBuf[128]; + str_format(aBuf, sizeof(aBuf), "force_vote kick %d %s", ClientID, pReason); + Client()->Rcon(aBuf); } -} - -// TODO: fix these two -void CVoting::ForcevoteKick(int ClientID, const char *pReason) -{ - char aBuf[32]; - if(pReason[0]) - str_format(aBuf, sizeof(aBuf), "kick %d %s", ClientID, pReason); else - str_format(aBuf, sizeof(aBuf), "kick %d", ClientID); - Client()->Rcon(aBuf); + { + char aBuf[32]; + str_format(aBuf, sizeof(aBuf), "%d", ClientID); + Callvote("kick", aBuf, pReason); + } } -void CVoting::ForcevoteOption(int OptionId, const char *pReason) +void CVoting::CallvoteOption(int OptionId, const char *pReason, bool ForceVote) { CVoteOption *pOption = m_pFirst; while(pOption && OptionId >= 0) { if(OptionId == 0) { - Client()->Rcon(pOption->m_aDescription); + if(ForceVote) + { + char aBuf[128]; + str_format(aBuf, sizeof(aBuf), "force_vote option \"%s\" %s", pOption->m_aDescription, pReason); + Client()->Rcon(aBuf); + } + else + Callvote("option", pOption->m_aDescription, pReason); break; } diff --git a/src/game/client/components/voting.h b/src/game/client/components/voting.h index 9687d895..92e4b395 100644 --- a/src/game/client/components/voting.h +++ b/src/game/client/components/voting.h @@ -45,10 +45,8 @@ public: void RenderBars(CUIRect Bars, bool Text); - void CallvoteKick(int ClientID, const char *pReason); - void CallvoteOption(int Option, const char *pReason); - void ForcevoteKick(int ClientID, const char *pReason); - void ForcevoteOption(int Option, const char *pReason); + void CallvoteKick(int ClientID, const char *pReason, bool ForceVote = false); + void CallvoteOption(int Option, const char *pReason, bool ForceVote = false); void Vote(int v); // -1 = no, 1 = yes diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index 4d80e0f1..76b51831 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -199,6 +199,7 @@ void CGameClient::OnConsoleInit() Console()->Register("set_team_all", "i", CFGFLAG_SERVER, 0, 0, "Set team of all players to team"); Console()->Register("add_vote", "sr", CFGFLAG_SERVER, 0, 0, "Add a voting option"); Console()->Register("remove_vote", "s", CFGFLAG_SERVER, 0, 0, "remove a voting option"); + Console()->Register("force_vote", "ss?r", CFGFLAG_SERVER, 0, 0, "Force a voting option"); Console()->Register("clear_votes", "", CFGFLAG_SERVER, 0, 0, "Clears the voting options"); Console()->Register("vote", "r", CFGFLAG_SERVER, 0, 0, "Force a vote to yes/no"); |