mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Merge #1088
1088: Only count distinct client IP addresses for minimum player vote count r=heinrich5991 a=heinrich5991
This commit is contained in:
commit
1e15b97543
|
@ -1419,12 +1419,36 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
|
|||
|
||||
if(g_Config.m_SvVoteKickMin)
|
||||
{
|
||||
int PlayerNum = 0;
|
||||
char aaAddresses[MAX_CLIENTS][NETADDR_MAXSTRSIZE] = {{0}};
|
||||
for(int i = 0; i < MAX_CLIENTS; i++)
|
||||
{
|
||||
if(m_apPlayers[i])
|
||||
{
|
||||
Server()->GetClientAddr(i, aaAddresses[i], NETADDR_MAXSTRSIZE);
|
||||
}
|
||||
}
|
||||
int NumPlayers = 0;
|
||||
for(int i = 0; i < MAX_CLIENTS; ++i)
|
||||
{
|
||||
if(m_apPlayers[i] && m_apPlayers[i]->GetTeam() != TEAM_SPECTATORS)
|
||||
++PlayerNum;
|
||||
{
|
||||
NumPlayers++;
|
||||
for(int j = 0; j < i; j++)
|
||||
{
|
||||
|
||||
if(PlayerNum < g_Config.m_SvVoteKickMin)
|
||||
if(m_apPlayers[j] && m_apPlayers[j]->GetTeam() != TEAM_SPECTATORS)
|
||||
{
|
||||
if(str_comp(aaAddresses[i], aaAddresses[j]) == 0)
|
||||
{
|
||||
NumPlayers--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(NumPlayers < g_Config.m_SvVoteKickMin)
|
||||
{
|
||||
str_format(aChatmsg, sizeof(aChatmsg), "Kick voting requires %d players on the server", g_Config.m_SvVoteKickMin);
|
||||
SendChatTarget(ClientID, aChatmsg);
|
||||
|
|
Loading…
Reference in a new issue