Skip to content

Commit

Permalink
Avoid string-based address comparison for sv_vote_kick_min
Browse files Browse the repository at this point in the history
Compare client addresses directly to determine the distinct client count excluding spectators. This is consistent with the `IServer::DistinctClientCount` function though this does not check for spectators.
  • Loading branch information
Robyt3 committed Dec 20, 2024
1 parent 85e246e commit b8af61d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/game/server/gamecontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2326,12 +2326,12 @@ void CGameContext::OnCallVoteNetMessage(const CNetMsg_Cl_CallVote *pMsg, int Cli

if(g_Config.m_SvVoteKickMin && !GetDDRaceTeam(ClientId))
{
char aaAddresses[MAX_CLIENTS][NETADDR_MAXSTRSIZE] = {{0}};
NETADDR aAddresses[MAX_CLIENTS];
for(int i = 0; i < MAX_CLIENTS; i++)
{
if(m_apPlayers[i])
{
Server()->GetClientAddr(i, aaAddresses[i], NETADDR_MAXSTRSIZE);
Server()->GetClientAddr(i, &aAddresses[i]);
}
}
int NumPlayers = 0;
Expand All @@ -2344,7 +2344,7 @@ void CGameContext::OnCallVoteNetMessage(const CNetMsg_Cl_CallVote *pMsg, int Cli
{
if(m_apPlayers[j] && m_apPlayers[j]->GetTeam() != TEAM_SPECTATORS && !GetDDRaceTeam(j))
{
if(str_comp(aaAddresses[i], aaAddresses[j]) == 0)
if(!net_addr_comp_noport(&aAddresses[i], &aAddresses[j]))
{
NumPlayers--;
break;
Expand Down

0 comments on commit b8af61d

Please sign in to comment.