Remove unnecessary CNamePlates::RenderNameplate function

The client ID of `CNetObj_PlayerInfo` objects is validated prior to calling the `CNamePlates::RenderNameplate` function, so the additional checks and arguments to handle the client ID not being valid where never used.

Rename existing `RenderNameplatePos` function to `RenderNameplate`.
This commit is contained in:
Robert Müller 2024-06-26 20:05:20 +02:00
parent cb9521d29f
commit c24d0c0ace
2 changed files with 4 additions and 27 deletions

View file

@ -14,23 +14,7 @@
#include "controls.h" #include "controls.h"
#include "nameplates.h" #include "nameplates.h"
void CNamePlates::RenderNameplate( void CNamePlates::RenderNameplate(vec2 Position, const CNetObj_PlayerInfo *pPlayerInfo, float Alpha, bool ForceAlpha)
const CNetObj_Character *pPrevChar,
const CNetObj_Character *pPlayerChar,
const CNetObj_PlayerInfo *pPlayerInfo)
{
int ClientId = pPlayerInfo->m_ClientId;
vec2 Position;
if(ClientId >= 0 && ClientId < MAX_CLIENTS)
Position = m_pClient->m_aClients[ClientId].m_RenderPos;
else
Position = mix(vec2(pPrevChar->m_X, pPrevChar->m_Y), vec2(pPlayerChar->m_X, pPlayerChar->m_Y), Client()->IntraGameTick(g_Config.m_ClDummy));
RenderNameplatePos(Position, pPlayerInfo, 1.0f);
}
void CNamePlates::RenderNameplatePos(vec2 Position, const CNetObj_PlayerInfo *pPlayerInfo, float Alpha, bool ForceAlpha)
{ {
int ClientId = pPlayerInfo->m_ClientId; int ClientId = pPlayerInfo->m_ClientId;
@ -328,7 +312,7 @@ void CNamePlates::OnRender()
// don't render offscreen // don't render offscreen
if(!(pRenderPos->x < ScreenX0) && !(pRenderPos->x > ScreenX1) && !(pRenderPos->y < ScreenY0) && !(pRenderPos->y > ScreenY1)) if(!(pRenderPos->x < ScreenX0) && !(pRenderPos->x > ScreenX1) && !(pRenderPos->y < ScreenY0) && !(pRenderPos->y > ScreenY1))
{ {
RenderNameplatePos(m_pClient->m_aClients[i].m_SpecChar, pInfo, 0.4f, true); RenderNameplate(m_pClient->m_aClients[i].m_SpecChar, pInfo, 0.4f, true);
} }
} }
if(m_pClient->m_Snap.m_aCharacters[i].m_Active) if(m_pClient->m_Snap.m_aCharacters[i].m_Active)
@ -338,10 +322,7 @@ void CNamePlates::OnRender()
// don't render offscreen // don't render offscreen
if(!(pRenderPos->x < ScreenX0) && !(pRenderPos->x > ScreenX1) && !(pRenderPos->y < ScreenY0) && !(pRenderPos->y > ScreenY1)) if(!(pRenderPos->x < ScreenX0) && !(pRenderPos->x > ScreenX1) && !(pRenderPos->y < ScreenY0) && !(pRenderPos->y > ScreenY1))
{ {
RenderNameplate( RenderNameplate(m_pClient->m_aClients[i].m_RenderPos, pInfo, 1.0f, false);
&m_pClient->m_Snap.m_aCharacters[i].m_Prev,
&m_pClient->m_Snap.m_aCharacters[i].m_Cur,
pInfo);
} }
} }
} }

View file

@ -42,11 +42,7 @@ struct SPlayerNamePlate
class CNamePlates : public CComponent class CNamePlates : public CComponent
{ {
void RenderNameplate( void RenderNameplate(vec2 Position, const CNetObj_PlayerInfo *pPlayerInfo, float Alpha, bool ForceAlpha);
const CNetObj_Character *pPrevChar,
const CNetObj_Character *pPlayerChar,
const CNetObj_PlayerInfo *pPlayerInfo);
void RenderNameplatePos(vec2 Position, const CNetObj_PlayerInfo *pPlayerInfo, float Alpha, bool ForceAlpha = false);
SPlayerNamePlate m_aNamePlates[MAX_CLIENTS]; SPlayerNamePlate m_aNamePlates[MAX_CLIENTS];