Add ability to swap without a name when team only has 2 players.

This commit is contained in:
furo 2023-09-21 19:40:37 +02:00
parent cd37c2d5b3
commit 992a26c7ca

View file

@ -708,14 +708,31 @@ void CGameContext::ConSwap(IConsole::IResult *pResult, void *pUserData)
} }
int TargetClientId = -1; int TargetClientId = -1;
for(int i = 0; i < MAX_CLIENTS; i++) if(pResult->NumArguments() == 1)
{ {
if(pSelf->m_apPlayers[i] && !str_comp(pName, pSelf->Server()->ClientName(i))) for(int i = 0; i < MAX_CLIENTS; i++)
{ {
TargetClientId = i; if(pSelf->m_apPlayers[i] && !str_comp(pName, pSelf->Server()->ClientName(i)))
break; {
TargetClientId = i;
break;
}
} }
} }
else
{
int TeamSize = 0;
for(int i = 0; i < MAX_CLIENTS; i++)
{
if(pSelf->m_apPlayers[i] && Teams.m_Core.Team(i) == Team && i != pResult->m_ClientID)
{
TargetClientId = i;
TeamSize++;
}
}
if(TeamSize > 1)
TargetClientId = -1;
}
if(TargetClientId < 0) if(TargetClientId < 0)
{ {