From 2964c1b4c408599b48d656364e7c936f576070bb Mon Sep 17 00:00:00 2001 From: trml Date: Thu, 21 Oct 2021 01:02:44 +0200 Subject: [PATCH] Use network clipping for EntityEx --- src/game/server/entities/door.cpp | 6 +++--- src/game/server/entities/dragger.cpp | 16 ++++++++-------- src/game/server/entities/gun.cpp | 6 +++--- src/game/server/entities/light.cpp | 6 +++--- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/game/server/entities/door.cpp b/src/game/server/entities/door.cpp index 95ed2eafd..2dc1d1416 100644 --- a/src/game/server/entities/door.cpp +++ b/src/game/server/entities/door.cpp @@ -42,6 +42,9 @@ void CDoor::ResetCollision() void CDoor::Snap(int SnappingClient) { + if(NetworkClipped(SnappingClient, m_Pos) && NetworkClipped(SnappingClient, m_To)) + return; + CNetObj_EntityEx *pEntData = static_cast(Server()->SnapNewItem(NETOBJTYPE_ENTITYEX, GetID(), sizeof(CNetObj_EntityEx))); if(!pEntData) return; @@ -50,9 +53,6 @@ void CDoor::Snap(int SnappingClient) pEntData->m_Layer = m_Layer; pEntData->m_EntityClass = ENTITYCLASS_DOOR; - if(NetworkClipped(SnappingClient, m_Pos) && NetworkClipped(SnappingClient, m_To)) - return; - CNetObj_Laser *pObj = static_cast(Server()->SnapNewItem( NETOBJTYPE_LASER, GetID(), sizeof(CNetObj_Laser))); diff --git a/src/game/server/entities/dragger.cpp b/src/game/server/entities/dragger.cpp index aed4f80d6..00796a7cb 100644 --- a/src/game/server/entities/dragger.cpp +++ b/src/game/server/entities/dragger.cpp @@ -165,14 +165,6 @@ void CDragger::Snap(int SnappingClient) if(((CGameControllerDDRace *)GameServer()->m_pController)->m_Teams.GetTeamState(m_CaughtTeam) == CGameTeams::TEAMSTATE_EMPTY) return; - CNetObj_EntityEx *pEntData = static_cast(Server()->SnapNewItem(NETOBJTYPE_ENTITYEX, GetID(), sizeof(CNetObj_EntityEx))); - if(!pEntData) - return; - - pEntData->m_SwitchNumber = m_Number; - pEntData->m_Layer = m_Layer; - pEntData->m_EntityClass = clamp(ENTITYCLASS_DRAGGER_WEAK + round_to_int(m_Strength) - 1, (int)ENTITYCLASS_DRAGGER_WEAK, (int)ENTITYCLASS_DRAGGER_STRONG); - int SnappingClientVersion = SnappingClient >= 0 ? GameServer()->GetClientVersion(SnappingClient) : CLIENT_VERSIONNR; CCharacter *Target = m_Target; @@ -241,6 +233,14 @@ void CDragger::Snap(int SnappingClient) { obj = static_cast(Server()->SnapNewItem( NETOBJTYPE_LASER, GetID(), sizeof(CNetObj_Laser))); + + CNetObj_EntityEx *pEntData = static_cast(Server()->SnapNewItem(NETOBJTYPE_ENTITYEX, GetID(), sizeof(CNetObj_EntityEx))); + if(!pEntData) + return; + + pEntData->m_SwitchNumber = m_Number; + pEntData->m_Layer = m_Layer; + pEntData->m_EntityClass = clamp(ENTITYCLASS_DRAGGER_WEAK + round_to_int(m_Strength) - 1, (int)ENTITYCLASS_DRAGGER_WEAK, (int)ENTITYCLASS_DRAGGER_STRONG); } else { diff --git a/src/game/server/entities/gun.cpp b/src/game/server/entities/gun.cpp index 042e7f879..e8d09a1a5 100644 --- a/src/game/server/entities/gun.cpp +++ b/src/game/server/entities/gun.cpp @@ -112,6 +112,9 @@ void CGun::Tick() void CGun::Snap(int SnappingClient) { + if(NetworkClipped(SnappingClient)) + return; + CNetObj_EntityEx *pEntData = static_cast(Server()->SnapNewItem(NETOBJTYPE_ENTITYEX, GetID(), sizeof(CNetObj_EntityEx))); if(!pEntData) return; @@ -128,9 +131,6 @@ void CGun::Snap(int SnappingClient) else pEntData->m_EntityClass = ENTITYCLASS_GUN_UNFREEZE; - if(NetworkClipped(SnappingClient)) - return; - CCharacter *Char = GameServer()->GetPlayerChar(SnappingClient); if(SnappingClient > -1 && (GameServer()->m_apPlayers[SnappingClient]->GetTeam() == -1 || GameServer()->m_apPlayers[SnappingClient]->IsPaused()) && diff --git a/src/game/server/entities/light.cpp b/src/game/server/entities/light.cpp index bca643fbc..2856c8eae 100644 --- a/src/game/server/entities/light.cpp +++ b/src/game/server/entities/light.cpp @@ -102,6 +102,9 @@ void CLight::Tick() void CLight::Snap(int SnappingClient) { + if(NetworkClipped(SnappingClient, m_Pos) && NetworkClipped(SnappingClient, m_To)) + return; + CNetObj_EntityEx *pEntData = static_cast(Server()->SnapNewItem(NETOBJTYPE_ENTITYEX, GetID(), sizeof(CNetObj_EntityEx))); if(!pEntData) return; @@ -110,9 +113,6 @@ void CLight::Snap(int SnappingClient) pEntData->m_Layer = m_Layer; pEntData->m_EntityClass = ENTITYCLASS_LIGHT; - if(NetworkClipped(SnappingClient, m_Pos) && NetworkClipped(SnappingClient, m_To)) - return; - CCharacter *Char = GameServer()->GetPlayerChar(SnappingClient); if(SnappingClient > -1 && (GameServer()->m_apPlayers[SnappingClient]->GetTeam() == -1 || GameServer()->m_apPlayers[SnappingClient]->IsPaused()) && GameServer()->m_apPlayers[SnappingClient]->m_SpectatorID != SPEC_FREEVIEW)