Fix SpectateClosest switching to random player

This commit is contained in:
KebsCS 2024-09-27 01:26:42 +02:00 committed by Dennis Felsing
parent de8639c6f7
commit 2646de0a7a

View file

@ -135,7 +135,7 @@ void CSpectator::ConSpectateClosest(IConsole::IResult *pResult, void *pUserData)
int ClosestDistance = std::numeric_limits<int>::max(); int ClosestDistance = std::numeric_limits<int>::max();
for(int i = 0; i < MAX_CLIENTS; i++) for(int i = 0; i < MAX_CLIENTS; i++)
{ {
if(i == SpectatorId || !Snap.m_apPlayerInfos[i] || Snap.m_apPlayerInfos[i]->m_Team == TEAM_SPECTATORS || (SpectatorId == SPEC_FREEVIEW && i == Snap.m_LocalClientId)) if(i == SpectatorId || !Snap.m_aCharacters[i].m_Active || !Snap.m_apPlayerInfos[i] || Snap.m_apPlayerInfos[i]->m_Team == TEAM_SPECTATORS || (SpectatorId == SPEC_FREEVIEW && i == Snap.m_LocalClientId))
continue; continue;
const CNetObj_Character &MaybeClosestCharacter = Snap.m_aCharacters[i].m_Cur; const CNetObj_Character &MaybeClosestCharacter = Snap.m_aCharacters[i].m_Cur;
int Distance = distance(CurPosition, vec2(MaybeClosestCharacter.m_X, MaybeClosestCharacter.m_Y)); int Distance = distance(CurPosition, vec2(MaybeClosestCharacter.m_X, MaybeClosestCharacter.m_Y));