Skip to content

Commit

Permalink
CEntity: Add GetViewParams() helper
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaffeine committed Jul 2, 2024
1 parent 3e987c0 commit ab1cb6a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/game/server/entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ bool CEntity::GameLayerClipped(vec2 CheckPos)
round_to_int(CheckPos.y) / 32 < -200 || round_to_int(CheckPos.y) / 32 > GameServer()->Collision()->GetHeight() + 200;
}

std::optional<CViewParams> GetViewParams(const CGameContext *pGameServer, int SnappingClient)
{
if(SnappingClient == SERVER_DEMO_CLIENT || pGameServer->m_apPlayers[SnappingClient]->m_ShowAll)
return {};

const CPlayer *pPlayer = pGameServer->m_apPlayers[SnappingClient];
return CViewParams{pPlayer->m_ViewPos, pPlayer->m_ShowDistance};
}

bool NetworkClipped(const CGameContext *pGameServer, int SnappingClient, vec2 CheckPos)
{
if(SnappingClient == SERVER_DEMO_CLIENT || pGameServer->m_apPlayers[SnappingClient]->m_ShowAll)
Expand Down
8 changes: 8 additions & 0 deletions src/game/server/entity.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,14 @@ class CEntity
vec2 m_Pos;
};

struct CViewParams
{
vec2 ViewPos{};
vec2 ShowDistance{};
};

std::optional<CViewParams> GetViewParams(const CGameContext *pGameServer, int SnappingClient);

bool NetworkClipped(const CGameContext *pGameServer, int SnappingClient, vec2 CheckPos);
bool NetworkClippedLine(const CGameContext *pGameServer, int SnappingClient, vec2 StartPos, vec2 EndPos);

Expand Down

0 comments on commit ab1cb6a

Please sign in to comment.