From 992a26c7ca2440170659be3bd0b7784eb27fc20c Mon Sep 17 00:00:00 2001 From: furo Date: Thu, 21 Sep 2023 19:40:37 +0200 Subject: [PATCH] Add ability to swap without a name when team only has 2 players. --- src/game/server/ddracechat.cpp | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/game/server/ddracechat.cpp b/src/game/server/ddracechat.cpp index 629adf951..a1cdd3fe4 100644 --- a/src/game/server/ddracechat.cpp +++ b/src/game/server/ddracechat.cpp @@ -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 = 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) {