Skip to content

Commit fc45c80

Browse files
authored
Merge pull request ddnet#9598 from Pioooooo/spec-pos
Show position of paused character currently spectating
2 parents f9156d5 + 32cad0f commit fc45c80

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

src/game/client/components/hud.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,7 +1320,7 @@ inline int CHud::GetDigitsIndex(int Value, int Max)
13201320

13211321
inline float CHud::GetMovementInformationBoxHeight()
13221322
{
1323-
if(m_pClient->m_Snap.m_SpecInfo.m_Active && m_pClient->m_Snap.m_SpecInfo.m_SpectatorId == SPEC_FREEVIEW)
1323+
if(m_pClient->m_Snap.m_SpecInfo.m_Active && (m_pClient->m_Snap.m_SpecInfo.m_SpectatorId == SPEC_FREEVIEW || m_pClient->m_aClients[m_pClient->m_Snap.m_SpecInfo.m_SpectatorId].m_SpecCharPresent))
13241324
return g_Config.m_ClShowhudPlayerPosition ? 3 * MOVEMENT_INFORMATION_LINE_HEIGHT + 2 : 0;
13251325
float BoxHeight = 3 * MOVEMENT_INFORMATION_LINE_HEIGHT * (g_Config.m_ClShowhudPlayerPosition + g_Config.m_ClShowhudPlayerSpeed) + 2 * MOVEMENT_INFORMATION_LINE_HEIGHT * g_Config.m_ClShowhudPlayerAngle;
13261326
if(g_Config.m_ClShowhudPlayerPosition || g_Config.m_ClShowhudPlayerSpeed || g_Config.m_ClShowhudPlayerAngle)
@@ -1352,12 +1352,13 @@ void CHud::RenderMovementInformationTextContainer(STextContainerIndex &TextConta
13521352
}
13531353
}
13541354

1355-
void CHud::RenderMovementInformation(const int ClientId)
1355+
void CHud::RenderMovementInformation()
13561356
{
1357-
bool Freeview = ClientId == SPEC_FREEVIEW;
1357+
const int ClientId = m_pClient->m_Snap.m_SpecInfo.m_Active ? m_pClient->m_Snap.m_SpecInfo.m_SpectatorId : m_pClient->m_Snap.m_LocalClientId;
1358+
const bool PosOnly = ClientId == SPEC_FREEVIEW || (m_pClient->m_aClients[ClientId].m_SpecCharPresent);
13581359
// Draw the infomations depending on settings: Position, speed and target angle
13591360
// This display is only to present the available information from the last snapshot, not to interpolate or predict
1360-
if(!g_Config.m_ClShowhudPlayerPosition && (Freeview || (!g_Config.m_ClShowhudPlayerSpeed && !g_Config.m_ClShowhudPlayerAngle)))
1361+
if(!g_Config.m_ClShowhudPlayerPosition && (PosOnly || (!g_Config.m_ClShowhudPlayerSpeed && !g_Config.m_ClShowhudPlayerAngle)))
13611362
{
13621363
return;
13631364
}
@@ -1379,10 +1380,14 @@ void CHud::RenderMovementInformation(const int ClientId)
13791380
vec2 Pos;
13801381
float DisplaySpeedX{}, DisplaySpeedY{}, DisplayAngle{};
13811382

1382-
if(Freeview)
1383+
if(ClientId == SPEC_FREEVIEW)
13831384
{
13841385
Pos = m_pClient->m_Camera.m_Center / 32.f;
13851386
}
1387+
else if(m_pClient->m_aClients[ClientId].m_SpecCharPresent)
1388+
{
1389+
Pos = m_pClient->m_aClients[ClientId].m_SpecChar / 32.f;
1390+
}
13861391
else
13871392
{
13881393
const CNetObj_Character *pPrevChar = &m_pClient->m_Snap.m_aCharacters[ClientId].m_Prev;
@@ -1441,7 +1446,7 @@ void CHud::RenderMovementInformation(const int ClientId)
14411446
y += MOVEMENT_INFORMATION_LINE_HEIGHT;
14421447
}
14431448

1444-
if(Freeview)
1449+
if(PosOnly)
14451450
return;
14461451

14471452
if(g_Config.m_ClShowhudPlayerSpeed)
@@ -1607,7 +1612,7 @@ void CHud::OnRender()
16071612
{
16081613
RenderPlayerState(m_pClient->m_Snap.m_LocalClientId);
16091614
}
1610-
RenderMovementInformation(m_pClient->m_Snap.m_LocalClientId);
1615+
RenderMovementInformation();
16111616
RenderDDRaceEffects();
16121617
}
16131618
else if(m_pClient->m_Snap.m_SpecInfo.m_Active)
@@ -1625,7 +1630,7 @@ void CHud::OnRender()
16251630
{
16261631
RenderPlayerState(SpectatorId);
16271632
}
1628-
RenderMovementInformation(SpectatorId);
1633+
RenderMovementInformation();
16291634
RenderSpectatorHud();
16301635
}
16311636

src/game/client/components/hud.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class CHud : public CComponent
7777
void PreparePlayerStateQuads();
7878
void RenderPlayerState(const int ClientId);
7979
void RenderDummyActions();
80-
void RenderMovementInformation(const int ClientId);
80+
void RenderMovementInformation();
8181

8282
void UpdateMovementInformationTextContainer(STextContainerIndex &TextContainer, float FontSize, float Value, char *pPrevValue, size_t Size);
8383
void RenderMovementInformationTextContainer(STextContainerIndex &TextContainer, const ColorRGBA &Color, float X, float Y);

0 commit comments

Comments
 (0)