Merge pull request #7227 from furo321/swap-without-name

Add ability to swap without a name when team only has 2 players.
This commit is contained in:
Robert Müller 2023-09-22 14:33:48 +00:00 committed by GitHub
commit 774d32713d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -708,14 +708,31 @@ void CGameContext::ConSwap(IConsole::IResult *pResult, void *pUserData)
}
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;
break;
if(pSelf->m_apPlayers[i] && !str_comp(pName, pSelf->Server()->ClientName(i)))
{
TargetClientId = i;
break;
}
}
}
else
{
int TeamSize = 1;
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 != 2)
TargetClientId = -1;
}
if(TargetClientId < 0)
{