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,6 +708,8 @@ void CGameContext::ConSwap(IConsole::IResult *pResult, void *pUserData)
} }
int TargetClientId = -1; int TargetClientId = -1;
if(pResult->NumArguments() == 1)
{
for(int i = 0; i < MAX_CLIENTS; i++) for(int i = 0; i < MAX_CLIENTS; i++)
{ {
if(pSelf->m_apPlayers[i] && !str_comp(pName, pSelf->Server()->ClientName(i))) if(pSelf->m_apPlayers[i] && !str_comp(pName, pSelf->Server()->ClientName(i)))
@ -716,6 +718,21 @@ void CGameContext::ConSwap(IConsole::IResult *pResult, void *pUserData)
break; 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)
{ {