about summary refs log tree commit diff
path: root/src/game/client/components
diff options
context:
space:
mode:
authorChoupom <andycootlapin@hotmail.fr>2011-04-02 16:24:08 +0200
committeroy <Tom_Adams@web.de>2011-04-02 18:11:43 +0200
commitb3cb33eec0109357cbeb56df0eedf167915f9eb0 (patch)
tree2e03481d9c8d21855b862d092a97e8dcfdc0ade9 /src/game/client/components
parentfa79602522587aa6bb62fb578e2e1bc8a8ca4461 (diff)
downloadzcatch-b3cb33eec0109357cbeb56df0eedf167915f9eb0.tar.gz
zcatch-b3cb33eec0109357cbeb56df0eedf167915f9eb0.zip
replace team name by clan name if possible
Diffstat (limited to 'src/game/client/components')
-rw-r--r--src/game/client/components/scoreboard.cpp64
-rw-r--r--src/game/client/components/scoreboard.h2
2 files changed, 56 insertions, 10 deletions
diff --git a/src/game/client/components/scoreboard.cpp b/src/game/client/components/scoreboard.cpp
index 863cae58..a8c9d93b 100644
--- a/src/game/client/components/scoreboard.cpp
+++ b/src/game/client/components/scoreboard.cpp
@@ -334,21 +334,35 @@ void CScoreboard::OnRender()
 			RenderScoreboard(Width/2-w/2, 150.0f, w, 0, 0);
 		else
 		{
-		
+			const char *pRedClanName = GetClanName(TEAM_RED);
+			const char *pBlueClanName = GetClanName(TEAM_BLUE);
+			
 			if(m_pClient->m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_GAMEOVER && m_pClient->m_Snap.m_pGameDataObj)
 			{
-				const char *pText = Localize("Draw!");
+				char aText[256];
+				str_copy(aText, Localize("Draw!"), sizeof(aText));
+				
 				if(m_pClient->m_Snap.m_pGameDataObj->m_TeamscoreRed > m_pClient->m_Snap.m_pGameDataObj->m_TeamscoreBlue)
-					pText = Localize("Red team wins!");
+				{
+					if(pRedClanName)
+						str_format(aText, sizeof(aText), Localize("%s wins!"), pRedClanName);
+					else
+						str_copy(aText, Localize("Red team wins!"), sizeof(aText));
+				}
 				else if(m_pClient->m_Snap.m_pGameDataObj->m_TeamscoreBlue > m_pClient->m_Snap.m_pGameDataObj->m_TeamscoreRed)
-					pText = Localize("Blue team wins!");
-			
-				float w = TextRender()->TextWidth(0, 86.0f, pText, -1);
-				TextRender()->Text(0, Width/2-w/2, 39, 86.0f, pText, -1);
+				{
+					if(pBlueClanName)
+						str_format(aText, sizeof(aText), Localize("%s wins!"), pBlueClanName);
+					else
+						str_copy(aText, Localize("Blue team wins!"), sizeof(aText));
+				}
+				
+				float w = TextRender()->TextWidth(0, 86.0f, aText, -1);
+				TextRender()->Text(0, Width/2-w/2, 39, 86.0f, aText, -1);
 			}
-		
-			RenderScoreboard(Width/2-w-5.0f, 150.0f, w, TEAM_RED, Localize("Red team"));
-			RenderScoreboard(Width/2+5.0f, 150.0f, w, TEAM_BLUE, Localize("Blue team"));
+			
+			RenderScoreboard(Width/2-w-5.0f, 150.0f, w, TEAM_RED, pRedClanName ? pRedClanName : Localize("Red team"));
+			RenderScoreboard(Width/2+5.0f, 150.0f, w, TEAM_BLUE, pBlueClanName ? pBlueClanName : Localize("Blue team"));
 		}
 	}
 
@@ -376,3 +390,33 @@ bool CScoreboard::Active()
 
 	return false;
 }
+
+const char *CScoreboard::GetClanName(int Team)
+{
+	int ClanPlayers = 0;
+	const char *pClanName = 0;
+	for(int i = 0; i < MAX_CLIENTS; i++)
+	{
+		const CNetObj_PlayerInfo *pInfo = m_pClient->m_Snap.m_paInfoByScore[i];
+		if(!pInfo || pInfo->m_Team != Team)
+			continue;
+		
+		if(!pClanName)
+		{
+			pClanName = m_pClient->m_aClients[pInfo->m_ClientID].m_aClan;
+			ClanPlayers++;
+		}
+		else
+		{
+			if(str_comp(m_pClient->m_aClients[pInfo->m_ClientID].m_aClan, pClanName) == 0)
+				ClanPlayers++;
+			else
+				return 0;
+		}
+	}
+	
+	if(ClanPlayers > 1 && pClanName[0])
+		return pClanName;
+	else
+		return 0;
+}
diff --git a/src/game/client/components/scoreboard.h b/src/game/client/components/scoreboard.h
index 64d6ad0e..5ac43a49 100644
--- a/src/game/client/components/scoreboard.h
+++ b/src/game/client/components/scoreboard.h
@@ -13,6 +13,8 @@ class CScoreboard : public CComponent
 
 	static void ConKeyScoreboard(IConsole::IResult *pResult, void *pUserData);
 	
+	const char *GetClanName(int Team);
+	
 	bool m_Active;
 	
 public: