mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Merge pull request #8209 from dobrykafe/pr-votes
Allow the vote creator to cancel the vote + sixup vote fix
This commit is contained in:
commit
1b77cbc821
|
@ -803,7 +803,7 @@ void CGameContext::SendVoteSet(int ClientId)
|
|||
Type = protocol7::VOTE_END_FAIL;
|
||||
else if(m_VoteEnforce == VOTE_ENFORCE_YES || m_VoteEnforce == VOTE_ENFORCE_YES_ADMIN)
|
||||
Type = protocol7::VOTE_END_PASS;
|
||||
else if(m_VoteEnforce == VOTE_ENFORCE_ABORT)
|
||||
else if(m_VoteEnforce == VOTE_ENFORCE_ABORT || m_VoteEnforce == VOTE_ENFORCE_CANCEL)
|
||||
Type = protocol7::VOTE_END_ABORT;
|
||||
|
||||
if(m_VoteEnforce == VOTE_ENFORCE_NO_ADMIN || m_VoteEnforce == VOTE_ENFORCE_YES_ADMIN)
|
||||
|
@ -1036,6 +1036,13 @@ void CGameContext::OnTick()
|
|||
SendChat(-1, CGameContext::CHAT_ALL, "Vote aborted");
|
||||
EndVote();
|
||||
}
|
||||
else if(m_VoteEnforce == VOTE_ENFORCE_CANCEL)
|
||||
{
|
||||
char aBuf[64];
|
||||
str_format(aBuf, sizeof(aBuf), "'%s' canceled their vote", Server()->ClientName(m_VoteCreator));
|
||||
SendChat(-1, CGameContext::CHAT_ALL, aBuf);
|
||||
EndVote();
|
||||
}
|
||||
else
|
||||
{
|
||||
int Total = 0, Yes = 0, No = 0;
|
||||
|
@ -2426,6 +2433,13 @@ void CGameContext::OnVoteNetMessage(const CNetMsg_Cl_Vote *pMsg, int ClientId)
|
|||
if(!pMsg->m_Vote)
|
||||
return;
|
||||
|
||||
// Allow the vote creator to cancel the vote
|
||||
if(pPlayer->GetCid() == m_VoteCreator && pMsg->m_Vote == -1)
|
||||
{
|
||||
m_VoteEnforce = VOTE_ENFORCE_CANCEL;
|
||||
return;
|
||||
}
|
||||
|
||||
pPlayer->m_Vote = pMsg->m_Vote;
|
||||
pPlayer->m_VotePos = ++m_VotePos;
|
||||
m_VoteUpdate = true;
|
||||
|
|
|
@ -224,7 +224,10 @@ public:
|
|||
VOTE_ENFORCE_UNKNOWN = 0,
|
||||
VOTE_ENFORCE_NO,
|
||||
VOTE_ENFORCE_YES,
|
||||
VOTE_ENFORCE_NO_ADMIN,
|
||||
VOTE_ENFORCE_YES_ADMIN,
|
||||
VOTE_ENFORCE_ABORT,
|
||||
VOTE_ENFORCE_CANCEL,
|
||||
};
|
||||
CHeap *m_pVoteOptionHeap;
|
||||
CVoteOptionServer *m_pVoteOptionFirst;
|
||||
|
@ -541,9 +544,6 @@ public:
|
|||
|
||||
enum
|
||||
{
|
||||
VOTE_ENFORCE_NO_ADMIN = VOTE_ENFORCE_YES + 1,
|
||||
VOTE_ENFORCE_YES_ADMIN,
|
||||
|
||||
VOTE_TYPE_UNKNOWN = 0,
|
||||
VOTE_TYPE_OPTION,
|
||||
VOTE_TYPE_KICK,
|
||||
|
|
Loading…
Reference in a new issue