//-----------------------------------------------------------------------------
// Purpose: resets the scoreboard team info
//-----------------------------------------------------------------------------
void CHL2MPClientScoreBoardDialog::UpdateTeamInfo()
{
	if ( g_PR == NULL )
		return;

	int iNumPlayersInGame = 0;

	for ( int j = 1; j <= gpGlobals->maxClients; j++ )
	{	
		if ( g_PR->IsConnected( j ) )
		{
			iNumPlayersInGame++;
		}
	}

	//BG2 - Get the total team damage points. -HairyPotter
	iAmericanDmg = 0;
	iBritishDmg = 0;
	iSpecDmg = 0;

	for ( int j = 1; j <= gpGlobals->maxClients; j++ )
	{	
		C_BasePlayer *pPlayer = UTIL_PlayerByIndex( j );
		if ( pPlayer )
		{
			switch ( pPlayer->GetTeamNumber() )
			{
			case TEAM_AMERICANS:
				iAmericanDmg += g_PR->GetDeaths( j );
				break;
			case TEAM_BRITISH:
				iBritishDmg += g_PR->GetDeaths( j );
				break;
			case TEAM_SPECTATOR:
				iSpecDmg += g_PR->GetDeaths( j );
			break;
			}
		}
	}
	//

	// update the team sections in the scoreboard
	for ( int i = TEAM_SPECTATOR; i < TEAM_MAXCOUNT; i++ )
	{
		wchar_t *teamName = NULL;
		int sectionID = 0;
		C_Team *team = GetGlobalTeam(i);

		if ( team )
		{
			sectionID = GetSectionFromTeamNumber( i );

			// update team name
			wchar_t name[64];
			wchar_t string1[1024];
			wchar_t wNumPlayers[6];

			_snwprintf(wNumPlayers, 6, L"%i", team->Get_Number_Players());

			if (!teamName && team)
			{
				g_pVGuiLocalize->ConvertANSIToUnicode(team->Get_Name(), name, sizeof(name));
				teamName = name;
			}

			if (team->Get_Number_Players() == 1)
			{
				g_pVGuiLocalize->ConstructString( string1, sizeof(string1), g_pVGuiLocalize->Find("#ScoreBoard_Player"), 2, teamName, wNumPlayers );
			}
			else
			{
				g_pVGuiLocalize->ConstructString( string1, sizeof(string1), g_pVGuiLocalize->Find("#ScoreBoard_Players"), 2, teamName, wNumPlayers );
			}

			// update stats
			wchar_t deaths[8];
			wchar_t val[6];
			swprintf(val, L"%d", team->Get_Score());

			switch( i )
			{
				case TEAM_AMERICANS:	
					swprintf(deaths, L"%d", iAmericanDmg);
					break;
				case TEAM_BRITISH:	
					swprintf(deaths, L"%d", iBritishDmg);
					break;
				case TEAM_SPECTATOR:	
					swprintf(deaths, L"%d", iSpecDmg);
					break;
			}

			if ( cl_scoreboard.GetInt() == 1 ) //Old scoreboard.
			{
				m_pPlayerList->ModifyColumn(sectionID, "deaths", deaths);
				m_pPlayerList->ModifyColumn(sectionID, "frags", val);
				if (team->Get_Ping() < 1)
				{
					m_pPlayerList->ModifyColumn(sectionID, "ping", L"");
				}
				else
				{
					swprintf(val, L"%d", team->Get_Ping());
					m_pPlayerList->ModifyColumn(sectionID, "ping", val);
				}
				m_pPlayerList->ModifyColumn(sectionID, "name", string1);
			}
			else //New Scoreboard.
			{
				switch( i )
				{
					case TEAM_BRITISH:	//British is always "sectionID" 1 in new scoreboard, because the british team has their own section.
						//swprintf(deaths, L"%d", iBritishDmg);
						m_pBritishPlayerList->ModifyColumn(1, "deaths", deaths);
						m_pBritishPlayerList->ModifyColumn(1, "frags", val);
						if (team->Get_Ping() < 1)
						{
							m_pBritishPlayerList->ModifyColumn(1, "ping", L"");
						}
						else
						{
							swprintf(val, L"%d", team->Get_Ping());
							m_pBritishPlayerList->ModifyColumn(1, "ping", val);
						}
						m_pBritishPlayerList->ModifyColumn(1, "name", string1);
						break;
					default: //If it's not British just stick everything in the "default" (American) section.
						m_pPlayerList->ModifyColumn(sectionID, "deaths", deaths);
						m_pPlayerList->ModifyColumn(sectionID, "frags", val);
						if (team->Get_Ping() < 1)
						{
							m_pPlayerList->ModifyColumn(sectionID, "ping", L"");
						}
						else
						{
							swprintf(val, L"%d", team->Get_Ping());
							m_pPlayerList->ModifyColumn(sectionID, "ping", val);
						}
						m_pPlayerList->ModifyColumn(sectionID, "name", string1);
						break;
				}
			}
		}
	}
}
示例#2
0
//-----------------------------------------------------------------------------
// Purpose: resets the scoreboard team info
//-----------------------------------------------------------------------------
void CHL2MPClientScoreBoardDialog::UpdateTeamInfo()
{
	IGameResources *gr = GameResources();
	if ( !gr )
		return;

	int iNumPlayersInGame = 0;

	for ( int j = 1; j <= gpGlobals->maxClients; j++ )
	{	
		if ( g_PR->IsConnected( j ) )
		{
			iNumPlayersInGame++;
		}
	}

	// update the team sections in the scoreboard
	for ( int i = TEAM_SPECTATOR; i < TEAM_MAXCOUNT; i++ )
	{
		wchar_t *teamName = NULL;
		int sectionID = 0;
		C_Team *team = GetGlobalTeam(i);

		if ( team )
		{
			sectionID = GetSectionFromTeamNumber( i );
	
			// update team name
			wchar_t name[64];
			wchar_t string1[1024];
			wchar_t wNumPlayers[6];

			if ( HL2MPRules()->IsTeamplay() == false )
			{
				_snwprintf( wNumPlayers, ARRAYSIZE(wNumPlayers), L"%i", iNumPlayersInGame );
#ifdef WIN32
				_snwprintf( name, ARRAYSIZE(name), L"%s", g_pVGuiLocalize->Find("#ScoreBoard_Deathmatch") );
#else
				_snwprintf( name, ARRAYSIZE(name), L"%S", g_pVGuiLocalize->Find("#ScoreBoard_Deathmatch") );
#endif
				
				teamName = name;

				if ( iNumPlayersInGame == 1)
				{
					g_pVGuiLocalize->ConstructString( string1, sizeof(string1), g_pVGuiLocalize->Find("#ScoreBoard_Player"), 2, teamName, wNumPlayers );
				}
				else
				{
					g_pVGuiLocalize->ConstructString( string1, sizeof(string1), g_pVGuiLocalize->Find("#ScoreBoard_Players"), 2, teamName, wNumPlayers );
				}
			}
			else
			{
				_snwprintf(wNumPlayers, ARRAYSIZE(wNumPlayers), L"%i", team->Get_Number_Players());

				if (!teamName && team)
				{
					g_pVGuiLocalize->ConvertANSIToUnicode(team->Get_Name(), name, sizeof(name));
					teamName = name;
				}

				if (team->Get_Number_Players() == 1)
				{
					g_pVGuiLocalize->ConstructString( string1, sizeof(string1), g_pVGuiLocalize->Find("#ScoreBoard_Player"), 2, teamName, wNumPlayers );
				}
				else
				{
					g_pVGuiLocalize->ConstructString( string1, sizeof(string1), g_pVGuiLocalize->Find("#ScoreBoard_Players"), 2, teamName, wNumPlayers );
				}

				// update stats
				wchar_t val[6];
				V_snwprintf(val, ARRAYSIZE(val), L"%d", team->Get_Score());
				m_pPlayerList->ModifyColumn(sectionID, "frags", val);
				if (team->Get_Ping() < 1)
				{
					m_pPlayerList->ModifyColumn(sectionID, "ping", L"");
				}
				else
				{
					V_snwprintf(val, ARRAYSIZE(val), L"%d", team->Get_Ping());
					m_pPlayerList->ModifyColumn(sectionID, "ping", val);
				}

			}
		
			m_pPlayerList->ModifyColumn(sectionID, "name", string1);
		}
	}
}
示例#3
0
//-----------------------------------------------------------------------------
// Purpose: resets the scoreboard team info
//-----------------------------------------------------------------------------
void CHL2WarsScoreboard::UpdateTeamInfo()
{
	if ( GameResources() == NULL )
		return;

	int iNumPlayersInGame = 0;

	for ( int j = 1; j <= gpGlobals->maxClients; j++ )
	{	
		if ( GameResources()->IsConnected( j ) )
		{
			iNumPlayersInGame++;
		}
	}

	// update the team sections in the scoreboard
	for ( int i = TEAM_UNASSIGNED; i < TEAM_MAXCOUNT; i++ )
	{
		wchar_t *teamName = NULL;
		int sectionID = 0;
		C_Team *team = GetGlobalTeam(i);

		sectionID = GetSectionFromTeamNumber( i );
		if ( team && HL2WarsGameRules()->IsTeamplay() == true )
		{
			// update team name
			wchar_t name[64];
			wchar_t string1[1024];
			wchar_t wNumPlayers[6];

			_snwprintf(wNumPlayers, 6, L"%i", team->Get_Number_Players());

			if (!teamName && team)
			{
				g_pVGuiLocalize->ConvertANSIToUnicode(team->Get_Name(), name, sizeof(name));
				teamName = name;
			}

			if (team->Get_Number_Players() == 1)
			{
				g_pVGuiLocalize->ConstructString( string1, sizeof(string1), g_pVGuiLocalize->Find("#HL2Wars_ScoreBoard_Player"), 2, teamName, wNumPlayers );
			}
			else
			{
				g_pVGuiLocalize->ConstructString( string1, sizeof(string1), g_pVGuiLocalize->Find("#HL2Wars_ScoreBoard_Players"), 2, teamName, wNumPlayers );
			}

			// update stats
			wchar_t val[6];
			swprintf(val, L"%d", team->Get_Score());
			m_pPlayerList->ModifyColumn(sectionID, "frags", val);
			if (team->Get_Ping() < 1)
			{
				m_pPlayerList->ModifyColumn(sectionID, "ping", L"");
			}
			else
			{
				swprintf(val, L"%d", team->Get_Ping());
				m_pPlayerList->ModifyColumn(sectionID, "ping", val);
			}
		
			m_pPlayerList->ModifyColumn(sectionID, "name", string1);
		}
		else
		{
			// update team name
			//wchar_t name[64];
			wchar_t string1[1024];
			wchar_t wNumPlayers[6];

			_snwprintf(wNumPlayers, 6, L"%i", iNumPlayersInGame );
			//_snwprintf( name, sizeof(name), L"%s", g_pVGuiLocalize->Find("#HL2Wars_ScoreBoard_Player") );
			
			//teamName = name;

			if ( iNumPlayersInGame == 1)
			{
				g_pVGuiLocalize->ConstructString( string1, sizeof(string1), g_pVGuiLocalize->Find("#HL2Wars_ScoreBoard_Player"), 2, wNumPlayers );
			}
			else
			{
				g_pVGuiLocalize->ConstructString( string1, sizeof(string1), g_pVGuiLocalize->Find("#HL2Wars_ScoreBoard_Players"), 2, wNumPlayers );
			}

			m_pPlayerList->ModifyColumn(sectionID, "name", string1);
		}
	}
}