5183: render allways the nameplate of a specchar (or the real player) r=def- a=C0D3D3V

fokkonaut uses spec chars in addition to normal players in his mod, so the names should also be displayed in addition to the player name

## Checklist

- [x] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [x] Considered possible null pointers and out of bounds array indexing
- [x] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: c0d3d3v <c0d3d3v@mag-keinen-spam.de>
This commit is contained in:
bors[bot] 2022-05-26 21:06:19 +00:00 committed by GitHub
commit e63b8e2bb5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -318,30 +318,31 @@ void CNamePlates::OnRender()
continue; continue;
} }
// don't render offscreen vec2 *pRenderPos;
vec2 *pRenderPos = &m_pClient->m_aClients[i].m_RenderPos;
if(m_pClient->m_aClients[i].m_SpecCharPresent) if(m_pClient->m_aClients[i].m_SpecCharPresent)
{ {
// Each player can also have a spec char whose nameplate is displayed independently
pRenderPos = &m_pClient->m_aClients[i].m_SpecChar; pRenderPos = &m_pClient->m_aClients[i].m_SpecChar;
} // 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))
{
continue;
}
if(m_pClient->m_aClients[i].m_SpecCharPresent)
{ {
RenderNameplatePos(m_pClient->m_aClients[i].m_SpecChar, pInfo, 0.4f, true); RenderNameplatePos(m_pClient->m_aClients[i].m_SpecChar, pInfo, 0.4f, true);
} }
else if(m_pClient->m_Snap.m_aCharacters[i].m_Active) }
if(m_pClient->m_Snap.m_aCharacters[i].m_Active)
{
// Only render nameplates for active characters
pRenderPos = &m_pClient->m_aClients[i].m_RenderPos;
// don't render offscreen
if(!(pRenderPos->x < ScreenX0) && !(pRenderPos->x > ScreenX1) && !(pRenderPos->y < ScreenY0) && !(pRenderPos->y > ScreenY1))
{ {
// only render nameplates for active characters
RenderNameplate( RenderNameplate(
&m_pClient->m_Snap.m_aCharacters[i].m_Prev, &m_pClient->m_Snap.m_aCharacters[i].m_Prev,
&m_pClient->m_Snap.m_aCharacters[i].m_Cur, &m_pClient->m_Snap.m_aCharacters[i].m_Cur,
pInfo); pInfo);
} }
} }
}
} }
void CNamePlates::SetPlayers(CPlayers *pPlayers) void CNamePlates::SetPlayers(CPlayers *pPlayers)