Merge pull request #9048 from KebsCS/pr-fix-spectate-closest

Fix SpectateClosest switching to random player
This commit is contained in:
Dennis Felsing 2024-09-27 11:11:00 +00:00 committed by GitHub
commit 205a7084a5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -135,7 +135,7 @@ void CSpectator::ConSpectateClosest(IConsole::IResult *pResult, void *pUserData)
int ClosestDistance = std::numeric_limits<int>::max();
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;
const CNetObj_Character &MaybeClosestCharacter = Snap.m_aCharacters[i].m_Cur;
int Distance = distance(CurPosition, vec2(MaybeClosestCharacter.m_X, MaybeClosestCharacter.m_Y));