Merge pull request #8209 from dobrykafe/pr-votes

Allow the vote creator to cancel the vote + sixup vote fix
This commit is contained in:
Dennis Felsing 2024-04-14 03:58:29 +00:00 committed by GitHub
commit 1b77cbc821
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 4 deletions

View file

@ -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;

View file

@ -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,