From 5c45f0876bc2b147235f89362c93b4966c12cbe2 Mon Sep 17 00:00:00 2001 From: Edgar Date: Tue, 30 Jun 2020 14:17:27 +0200 Subject: [PATCH] Clean and fix style on character snap --- src/game/server/entities/character.cpp | 30 ++++++++++++-------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index c5bb34f34..715f25ea6 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -1191,9 +1191,9 @@ void CCharacter::SnapCharacter(int SnappingClient, int ID) void CCharacter::Snap(int SnappingClient) { - int id = m_pPlayer->GetCID(); + int ID = m_pPlayer->GetCID(); - if(SnappingClient > -1 && !Server()->Translate(id, SnappingClient)) + if(SnappingClient > -1 && !Server()->Translate(ID, SnappingClient)) return; if(NetworkClipped(SnappingClient)) @@ -1201,28 +1201,26 @@ void CCharacter::Snap(int SnappingClient) if(SnappingClient > -1) { - CCharacter* SnapChar = GameServer()->GetPlayerChar(SnappingClient); - CPlayer* SnapPlayer = GameServer()->m_apPlayers[SnappingClient]; + CCharacter *pSnapChar = GameServer()->GetPlayerChar(SnappingClient); + CPlayer *pSnapPlayer = GameServer()->m_apPlayers[SnappingClient]; - if((SnapPlayer->GetTeam() == TEAM_SPECTATORS || SnapPlayer->IsPaused()) && SnapPlayer->m_SpectatorID != -1 - && !CanCollide(SnapPlayer->m_SpectatorID) && !SnapPlayer->m_ShowOthers) - return; - - if( SnapPlayer->GetTeam() != TEAM_SPECTATORS && !SnapPlayer->IsPaused() && SnapChar && !SnapChar->m_Super - && !CanCollide(SnappingClient) && !SnapPlayer->m_ShowOthers) - return; - - if((SnapPlayer->GetTeam() == TEAM_SPECTATORS || SnapPlayer->IsPaused()) && SnapPlayer->m_SpectatorID == -1 - && !CanCollide(SnappingClient) && SnapPlayer->m_SpecTeam) + if(pSnapPlayer->GetTeam() == TEAM_SPECTATORS || pSnapPlayer->IsPaused()) + { + if(pSnapPlayer->m_SpectatorID != -1 && !CanCollide(pSnapPlayer->m_SpectatorID) && !pSnapPlayer->m_ShowOthers) + return; + else if(pSnapPlayer->m_SpectatorID == -1 && !CanCollide(SnappingClient) && pSnapPlayer->m_SpecTeam) + return; + } + else if(pSnapChar && !pSnapChar->m_Super && !CanCollide(SnappingClient) && !pSnapPlayer->m_ShowOthers) return; } if (m_Paused) return; - SnapCharacter(SnappingClient, id); + SnapCharacter(SnappingClient, ID); - CNetObj_DDNetCharacter *pDDNetCharacter = static_cast(Server()->SnapNewItem(NETOBJTYPE_DDNETCHARACTER, id, sizeof(CNetObj_DDNetCharacter))); + CNetObj_DDNetCharacter *pDDNetCharacter = static_cast(Server()->SnapNewItem(NETOBJTYPE_DDNETCHARACTER, ID, sizeof(CNetObj_DDNetCharacter))); if(!pDDNetCharacter) return;