mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Fix votes for sixup
This commit is contained in:
parent
c5c2587607
commit
95d363b42c
|
@ -328,7 +328,7 @@ void ToggleSpecPauseVoted(IConsole::IResult *pResult, void *pUserData, int Pause
|
|||
}
|
||||
|
||||
bool IsPlayerBeingVoted = pSelf->m_VoteCloseTime &&
|
||||
(pSelf->m_VoteKick || pSelf->m_VoteSpec) &&
|
||||
(pSelf->IsKickVote() || pSelf->IsSpecVote()) &&
|
||||
pResult->m_ClientID != pSelf->m_VoteVictim;
|
||||
if((!IsPlayerBeingVoted && -PauseState == PauseType) ||
|
||||
(IsPlayerBeingVoted && PauseState && pPlayer->m_SpectatorID == pSelf->m_VoteVictim))
|
||||
|
@ -910,7 +910,7 @@ void CGameContext::ConJoinTeam(IConsole::IResult *pResult, void *pUserData)
|
|||
if (!pPlayer)
|
||||
return;
|
||||
|
||||
if (pSelf->m_VoteCloseTime && pSelf->m_VoteCreator == pResult->m_ClientID && (pSelf->m_VoteKick || pSelf->m_VoteSpec))
|
||||
if (pSelf->m_VoteCloseTime && pSelf->m_VoteCreator == pResult->m_ClientID && (pSelf->IsKickVote() || pSelf->IsSpecVote()))
|
||||
{
|
||||
pSelf->Console()->Print(
|
||||
IConsole::OUTPUT_LEVEL_STANDARD,
|
||||
|
|
|
@ -44,6 +44,7 @@ void CGameContext::Construct(int Resetting)
|
|||
m_apPlayers[i] = 0;
|
||||
|
||||
m_pController = 0;
|
||||
m_VoteType = VOTE_TYPE_UNKNOWN;
|
||||
m_VoteCloseTime = 0;
|
||||
m_pVoteOptionFirst = 0;
|
||||
m_pVoteOptionLast = 0;
|
||||
|
@ -524,20 +525,61 @@ void CGameContext::EndVote()
|
|||
|
||||
void CGameContext::SendVoteSet(int ClientID)
|
||||
{
|
||||
CNetMsg_Sv_VoteSet Msg;
|
||||
::CNetMsg_Sv_VoteSet Msg6;
|
||||
protocol7::CNetMsg_Sv_VoteSet Msg7;
|
||||
|
||||
Msg7.m_ClientID = m_VoteCreator;
|
||||
if(m_VoteCloseTime)
|
||||
{
|
||||
Msg.m_Timeout = (m_VoteCloseTime-time_get())/time_freq();
|
||||
Msg.m_pDescription = m_aVoteDescription;
|
||||
Msg.m_pReason = m_aVoteReason;
|
||||
Msg6.m_Timeout = Msg7.m_Timeout = (m_VoteCloseTime-time_get())/time_freq();
|
||||
Msg6.m_pDescription = Msg7.m_pDescription = m_aVoteDescription;
|
||||
Msg6.m_pReason = Msg7.m_pReason = m_aVoteReason;
|
||||
|
||||
int &Type = (Msg7.m_Type = protocol7::VOTE_UNKNOWN);
|
||||
if(IsKickVote())
|
||||
Type = protocol7::VOTE_START_KICK;
|
||||
else if(IsSpecVote())
|
||||
Type = protocol7::VOTE_START_SPEC;
|
||||
else if(IsOptionVote())
|
||||
Type = protocol7::VOTE_START_OP;
|
||||
}
|
||||
else
|
||||
{
|
||||
Msg.m_Timeout = 0;
|
||||
Msg.m_pDescription = "";
|
||||
Msg.m_pReason = "";
|
||||
Msg6.m_Timeout = Msg7.m_Timeout = 0;
|
||||
Msg6.m_pDescription = Msg7.m_pDescription = "";
|
||||
Msg6.m_pReason = Msg7.m_pReason = "";
|
||||
|
||||
int &Type = (Msg7.m_Type = protocol7::VOTE_UNKNOWN);
|
||||
if(m_VoteEnforce == VOTE_ENFORCE_NO || m_VoteEnforce == VOTE_ENFORCE_NO_ADMIN)
|
||||
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)
|
||||
Type = protocol7::VOTE_END_ABORT;
|
||||
|
||||
if(m_VoteEnforce == VOTE_ENFORCE_NO_ADMIN || m_VoteEnforce == VOTE_ENFORCE_YES_ADMIN)
|
||||
Msg7.m_ClientID = -1;
|
||||
}
|
||||
|
||||
if(ClientID == -1)
|
||||
{
|
||||
for(int i = 0; i < MAX_CLIENTS; i++)
|
||||
{
|
||||
if(!m_apPlayers[i])
|
||||
continue;
|
||||
if(!Server()->IsSixup(i))
|
||||
Server()->SendPackMsg(&Msg6, MSGFLAG_VITAL, i);
|
||||
else
|
||||
Server()->SendPackMsg(&Msg7, MSGFLAG_VITAL, i);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!Server()->IsSixup(ClientID))
|
||||
Server()->SendPackMsg(&Msg6, MSGFLAG_VITAL, ClientID);
|
||||
else
|
||||
Server()->SendPackMsg(&Msg7, MSGFLAG_VITAL, ClientID);
|
||||
}
|
||||
Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, ClientID);
|
||||
}
|
||||
|
||||
void CGameContext::SendVoteStatus(int ClientID, int Total, int Yes, int No)
|
||||
|
@ -563,7 +605,7 @@ void CGameContext::AbortVoteKickOnDisconnect(int ClientID)
|
|||
{
|
||||
if(m_VoteCloseTime && ((str_startswith(m_aVoteCommand, "kick ") && str_toint(&m_aVoteCommand[5]) == ClientID) ||
|
||||
(str_startswith(m_aVoteCommand, "set_team ") && str_toint(&m_aVoteCommand[9]) == ClientID)))
|
||||
m_VoteCloseTime = -1;
|
||||
m_VoteEnforce = VOTE_ENFORCE_ABORT;
|
||||
}
|
||||
|
||||
|
||||
|
@ -742,7 +784,7 @@ void CGameContext::OnTick()
|
|||
if(m_VoteCloseTime)
|
||||
{
|
||||
// abort the kick-vote on player-leave
|
||||
if(m_VoteCloseTime == -1)
|
||||
if(m_VoteEnforce == VOTE_ENFORCE_ABORT)
|
||||
{
|
||||
SendChat(-1, CGameContext::CHAT_ALL, "Vote aborted");
|
||||
EndVote();
|
||||
|
@ -775,7 +817,7 @@ void CGameContext::OnTick()
|
|||
if(!m_apPlayers[i] || aVoteChecked[i])
|
||||
continue;
|
||||
|
||||
if((m_VoteKick || m_VoteSpec) && (m_apPlayers[i]->GetTeam() == TEAM_SPECTATORS ||
|
||||
if((IsKickVote() || IsSpecVote()) && (m_apPlayers[i]->GetTeam() == TEAM_SPECTATORS ||
|
||||
(GetPlayerChar(m_VoteCreator) && GetPlayerChar(i) &&
|
||||
GetPlayerChar(m_VoteCreator)->Team() != GetPlayerChar(i)->Team())))
|
||||
continue;
|
||||
|
@ -784,7 +826,7 @@ void CGameContext::OnTick()
|
|||
continue;
|
||||
|
||||
// can't vote in kick and spec votes in the beginning after joining
|
||||
if((m_VoteKick || m_VoteSpec) && Now < m_apPlayers[i]->m_FirstVoteTick)
|
||||
if((IsKickVote() || IsSpecVote()) && Now < m_apPlayers[i]->m_FirstVoteTick)
|
||||
continue;
|
||||
|
||||
// connecting clients with spoofed ips can clog slots without being ingame
|
||||
|
@ -819,7 +861,7 @@ void CGameContext::OnTick()
|
|||
No++;
|
||||
|
||||
// veto right for players who have been active on server for long and who're not afk
|
||||
if(!m_VoteKick && !m_VoteSpec && m_apPlayers[i] &&
|
||||
if(!IsKickVote() && !IsSpecVote() && m_apPlayers[i] &&
|
||||
!m_apPlayers[i]->m_Afk && m_apPlayers[i]->GetTeam() != TEAM_SPECTATORS &&
|
||||
g_Config.m_SvVoteVetoTime &&
|
||||
((Server()->Tick() - m_apPlayers[i]->m_JoinTick) / (Server()->TickSpeed() * 60) > g_Config.m_SvVoteVetoTime ||
|
||||
|
@ -834,7 +876,7 @@ void CGameContext::OnTick()
|
|||
}
|
||||
|
||||
if(g_Config.m_SvVoteMaxTotal && Total > g_Config.m_SvVoteMaxTotal &&
|
||||
(m_VoteKick || m_VoteSpec))
|
||||
(IsKickVote() || IsSpecVote()))
|
||||
Total = g_Config.m_SvVoteMaxTotal;
|
||||
|
||||
if((Yes > Total / (100.0f / g_Config.m_SvVoteYesPercentage)) && !Veto)
|
||||
|
@ -853,7 +895,7 @@ void CGameContext::OnTick()
|
|||
|
||||
// / Ensure minimum time for vote to end when moderating.
|
||||
if(m_VoteEnforce == VOTE_ENFORCE_YES && !(PlayerModerating() &&
|
||||
(m_VoteKick || m_VoteSpec) && time_get() < m_VoteCloseTime))
|
||||
(IsKickVote() || IsSpecVote()) && time_get() < m_VoteCloseTime))
|
||||
{
|
||||
Server()->SetRconCID(IServer::RCON_CID_VOTE);
|
||||
Console()->ExecuteLine(m_aVoteCommand);
|
||||
|
@ -861,7 +903,7 @@ void CGameContext::OnTick()
|
|||
EndVote();
|
||||
SendChat(-1, CGameContext::CHAT_ALL, "Vote passed");
|
||||
|
||||
if(m_apPlayers[m_VoteCreator] && !m_VoteKick && !m_VoteSpec)
|
||||
if(m_apPlayers[m_VoteCreator] && !IsKickVote() && !IsSpecVote())
|
||||
m_apPlayers[m_VoteCreator]->m_LastVoteCall = 0;
|
||||
}
|
||||
else if(m_VoteEnforce == VOTE_ENFORCE_YES_ADMIN)
|
||||
|
@ -1689,9 +1731,10 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
|
|||
}
|
||||
else if(MsgID == NETMSGTYPE_CL_CALLVOTE)
|
||||
{
|
||||
if(RateLimitPlayerVote(ClientID))
|
||||
if(RateLimitPlayerVote(ClientID) || m_VoteCloseTime)
|
||||
return;
|
||||
|
||||
m_VoteType = VOTE_TYPE_UNKNOWN;
|
||||
char aChatmsg[512] = {0};
|
||||
char aDesc[VOTE_DESC_LENGTH] = {0};
|
||||
char aCmd[VOTE_CMD_LENGTH] = {0};
|
||||
|
@ -1767,8 +1810,7 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
|
|||
}
|
||||
}
|
||||
|
||||
m_VoteKick = false;
|
||||
m_VoteSpec = false;
|
||||
m_VoteType = VOTE_TYPE_OPTION;
|
||||
}
|
||||
else if(str_comp_nocase(pMsg->m_Type, "kick") == 0)
|
||||
{
|
||||
|
@ -1889,8 +1931,7 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
|
|||
str_format(aDesc, sizeof(aDesc), "Move '%s' to team 0", Server()->ClientName(KickID));
|
||||
}
|
||||
m_apPlayers[ClientID]->m_Last_KickVote = time_get();
|
||||
m_VoteKick = true;
|
||||
m_VoteSpec = false;
|
||||
m_VoteType = VOTE_TYPE_KICK;
|
||||
m_VoteVictim = KickID;
|
||||
}
|
||||
else if(str_comp_nocase(pMsg->m_Type, "spectate") == 0)
|
||||
|
@ -1936,8 +1977,7 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
|
|||
str_format(aDesc, sizeof(aDesc), "Move '%s' to spectators", Server()->ClientName(SpectateID));
|
||||
str_format(aCmd, sizeof(aCmd), "uninvite %d %d; set_team %d -1 %d", SpectateID, GetDDRaceTeam(SpectateID), SpectateID, g_Config.m_SvVoteSpectateRejoindelay);
|
||||
}
|
||||
m_VoteKick = false;
|
||||
m_VoteSpec = true;
|
||||
m_VoteType = VOTE_TYPE_SPECTATE;
|
||||
m_VoteVictim = SpectateID;
|
||||
}
|
||||
|
||||
|
@ -2216,7 +2256,7 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
|
|||
}
|
||||
else if (MsgID == NETMSGTYPE_CL_KILL && !m_World.m_Paused)
|
||||
{
|
||||
if(m_VoteCloseTime && m_VoteCreator == ClientID && GetDDRaceTeam(ClientID) && (m_VoteKick || m_VoteSpec))
|
||||
if(m_VoteCloseTime && m_VoteCreator == ClientID && GetDDRaceTeam(ClientID) && (IsKickVote() || IsSpecVote()))
|
||||
{
|
||||
SendChatTarget(ClientID, "You are running a vote please try again after the vote is done!");
|
||||
return;
|
||||
|
|
|
@ -153,6 +153,7 @@ public:
|
|||
void AbortVoteKickOnDisconnect(int ClientID);
|
||||
|
||||
int m_VoteCreator;
|
||||
int m_VoteType;
|
||||
int64 m_VoteCloseTime;
|
||||
bool m_VoteUpdate;
|
||||
int m_VotePos;
|
||||
|
@ -172,6 +173,7 @@ public:
|
|||
VOTE_ENFORCE_UNKNOWN=0,
|
||||
VOTE_ENFORCE_NO,
|
||||
VOTE_ENFORCE_YES,
|
||||
VOTE_ENFORCE_ABORT,
|
||||
};
|
||||
CHeap *m_pVoteOptionHeap;
|
||||
CVoteOptionServer *m_pVoteOptionFirst;
|
||||
|
@ -410,15 +412,24 @@ private:
|
|||
public:
|
||||
CLayers *Layers() { return &m_Layers; }
|
||||
class IScore *Score() { return m_pScore; }
|
||||
bool m_VoteKick;
|
||||
bool m_VoteSpec;
|
||||
int m_VoteVictim;
|
||||
|
||||
enum
|
||||
{
|
||||
VOTE_ENFORCE_NO_ADMIN = VOTE_ENFORCE_YES + 1,
|
||||
VOTE_ENFORCE_YES_ADMIN
|
||||
VOTE_ENFORCE_YES_ADMIN,
|
||||
|
||||
VOTE_TYPE_UNKNOWN=0,
|
||||
VOTE_TYPE_OPTION,
|
||||
VOTE_TYPE_KICK,
|
||||
VOTE_TYPE_SPECTATE,
|
||||
};
|
||||
int m_VoteVictim;
|
||||
int m_VoteEnforcer;
|
||||
|
||||
inline bool IsOptionVote() const { return m_VoteType == VOTE_TYPE_OPTION; };
|
||||
inline bool IsKickVote() const { return m_VoteType == VOTE_TYPE_KICK; };
|
||||
inline bool IsSpecVote() const { return m_VoteType == VOTE_TYPE_SPECTATE; };
|
||||
|
||||
void SendRecord(int ClientID);
|
||||
static void SendChatResponse(const char *pLine, void *pUser, bool Highlighted = false);
|
||||
static void SendChatResponseAll(const char *pLine, void *pUser);
|
||||
|
|
|
@ -941,8 +941,7 @@ void CPlayer::ProcessScoreResult(CScorePlayerResult &Result)
|
|||
GameServer()->SendBroadcast(Result.m_Data.m_Broadcast, -1);
|
||||
break;
|
||||
case CScorePlayerResult::MAP_VOTE:
|
||||
GameServer()->m_VoteKick = false;
|
||||
GameServer()->m_VoteSpec = false;
|
||||
GameServer()->m_VoteType = CGameContext::VOTE_TYPE_OPTION;
|
||||
GameServer()->m_LastMapVote = time_get();
|
||||
|
||||
char aCmd[256];
|
||||
|
|
Loading…
Reference in a new issue