From 2f5ca88b4d5ce10807b21ab0c58af8d24b603ccc Mon Sep 17 00:00:00 2001 From: Jordy Ruiz Date: Sat, 16 Feb 2019 13:12:12 +0100 Subject: [PATCH] Adjust spectator notification to show up for non-empty servers only --- src/game/client/components/hud.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/game/client/components/hud.cpp b/src/game/client/components/hud.cpp index a92008bda..6cba31d46 100644 --- a/src/game/client/components/hud.cpp +++ b/src/game/client/components/hud.cpp @@ -674,10 +674,19 @@ void CHud::RenderSpectatorNotification() if(m_pClient->m_aClients[m_pClient->m_LocalClientID].m_Team == TEAM_SPECTATORS && m_pClient->m_TeamChangeTime + 5.0f >= Client()->LocalTime()) { - const char *pText = Localize("Click on a player or a flag to follow it"); - float FontSize = 16.0f; - float w = TextRender()->TextWidth(0, FontSize, pText, -1); - TextRender()->Text(0, 150 * Graphics()->ScreenAspect() + -w / 2, 30, FontSize, pText, -1); + // count non spectators + int NumPlayers = 0; + for(int i = 0; i < MAX_CLIENTS; i++) + if(m_pClient->m_aClients[i].m_Active && m_pClient->m_aClients[i].m_Team != TEAM_SPECTATORS) + NumPlayers++; + + if(NumPlayers > 0) + { + const char *pText = Localize("Click on a player or a flag to follow it"); + float FontSize = 16.0f; + float w = TextRender()->TextWidth(0, FontSize, pText, -1); + TextRender()->Text(0, 150 * Graphics()->ScreenAspect() + -w / 2, 30, FontSize, pText, -1); + } } }