//----------------------------------------------------------------------------- // Purpose: Updates information about teams //----------------------------------------------------------------------------- void CTFDeathMatchScoreBoardDialog::UpdateTeamInfo() { // update the team sections in the scoreboard for (int teamIndex = TF_TEAM_RED; teamIndex <= TF_TEAM_YELLOW; teamIndex++) { wchar_t *teamName = NULL; C_Team *team = GetGlobalTeam( teamIndex ); if ( team ) { // choose dialog variables to set depending on team const char *pDialogVarTeamScore = NULL; const char *pDialogVarTeamPlayerCount = NULL; const char *pDialogVarTeamName = NULL; switch ( teamIndex ) { case TF_TEAM_RED: pDialogVarTeamScore = "redteamscore"; pDialogVarTeamPlayerCount = "redteamplayercount"; pDialogVarTeamName = "redteamname"; break; default: Assert( false ); break; } // update # of players on each team wchar_t name[64]; wchar_t string1[1024]; wchar_t wNumPlayers[6]; _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( "#TF_ScoreBoard_Player" ), 1, wNumPlayers ); } else { g_pVGuiLocalize->ConstructString( string1, sizeof(string1), g_pVGuiLocalize->Find( "#TF_ScoreBoard_Players" ), 1, wNumPlayers ); } // set # of players for team in dialog SetDialogVariable( pDialogVarTeamPlayerCount, string1 ); // set team score in dialog SetDialogVariable( pDialogVarTeamScore, team->Get_Score() ); // set team name SetDialogVariable( pDialogVarTeamName, team->Get_Name() ); } } }
//----------------------------------------------------------------------------- // Purpose: Updates information about teams //----------------------------------------------------------------------------- void CHL2MPClientScoreBoardDialog::UpdateTeamInfo() { // update the team sections in the scoreboard int startTeam = TEAM_UNASSIGNED; if ( HL2MPRules()->IsTeamplay() ) startTeam = TEAM_COMBINE; for ( int teamIndex = startTeam; teamIndex <= TEAM_REBELS; teamIndex++ ) { // Make sure spectator is always skipped here. if ( teamIndex == TEAM_SPECTATOR ) continue; wchar_t *teamName = NULL; C_Team *team = GetGlobalTeam( teamIndex ); if ( team ) { // choose dialog variables to set depending on team const char *pDialogVarTeamScore = NULL; const char *pDialogVarTeamPlayerCount = NULL; const char *pDialogVarTeamPing = NULL; switch ( teamIndex ) { case TEAM_REBELS: teamName = g_pVGuiLocalize->Find( "#HL2MP_ScoreBoard_Rebels" ); pDialogVarTeamScore = "r_teamscore"; pDialogVarTeamPlayerCount = "r_teamplayercount"; pDialogVarTeamPing = "r_teamping"; break; case TEAM_COMBINE: teamName = g_pVGuiLocalize->Find( "#HL2MP_ScoreBoard_Combine" ); pDialogVarTeamScore = "c_teamscore"; pDialogVarTeamPlayerCount = "c_teamplayercount"; pDialogVarTeamPing = "c_teamping"; break; case TEAM_UNASSIGNED: teamName = g_pVGuiLocalize->Find( "#HL2MP_ScoreBoard_DM" ); pDialogVarTeamPlayerCount = "dm_playercount"; pDialogVarTeamPing = "dm_ping"; break; default: Assert( false ); break; } // update # of players on each team wchar_t name[64]; wchar_t string1[1024]; wchar_t wNumPlayers[6]; _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 ); } // set # of players for team in dialog SetDialogVariable( pDialogVarTeamPlayerCount, string1 ); // set team score in dialog if ( teamIndex != TEAM_UNASSIGNED ) // Don't accumulate deathmatch scores. SetDialogVariable( pDialogVarTeamScore, team->Get_Score() ); int pingsum = 0; int numcounted = 0; for( int playerIndex = 1 ; playerIndex <= MAX_PLAYERS; playerIndex++ ) { if( g_PR->IsConnected( playerIndex ) && g_PR->GetTeam( playerIndex ) == teamIndex ) { int ping = g_PR->GetPing( playerIndex ); if ( ping >= 1 ) { pingsum += ping; numcounted++; } } } if ( numcounted > 0 ) { int ping = (int)( (float)pingsum / (float)numcounted ); SetDialogVariable( pDialogVarTeamPing, ping ); } else { SetDialogVariable( pDialogVarTeamPing, "" ); } } } }
//----------------------------------------------------------------------------- // 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); } } }
//----------------------------------------------------------------------------- // 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; } } } } }
//----------------------------------------------------------------------------- // Purpose: Updates information about teams //----------------------------------------------------------------------------- void CCSClientScoreBoardDialog::UpdateTeamInfo() { // update the team sections in the scoreboard for ( int teamIndex = TEAM_TERRORIST; teamIndex <= TEAM_CT; teamIndex++ ) { wchar_t *teamName = NULL; C_Team *team = GetGlobalTeam( teamIndex ); if ( team ) { // choose dialog variables to set depending on team const char *pDialogVarTeamScore = NULL; const char *pDialogVarTeamPlayerCount = NULL; const char *pDialogVarTeamPing = NULL; switch ( teamIndex ) { case TEAM_TERRORIST: teamName = g_pVGuiLocalize->Find( "#Cstrike_ScoreBoard_Ter" ); pDialogVarTeamScore = "t_teamscore"; pDialogVarTeamPlayerCount = "t_teamplayercount"; pDialogVarTeamPing = "t_teamping"; break; case TEAM_CT: teamName = g_pVGuiLocalize->Find( "#Cstrike_ScoreBoard_CT" ); pDialogVarTeamScore = "ct_teamscore"; pDialogVarTeamPlayerCount = "ct_teamplayercount"; pDialogVarTeamPing = "ct_teamping"; break; default: Assert( false ); break; } // update # of players on each team wchar_t name[64]; wchar_t string1[1024]; wchar_t wNumPlayers[6]; _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( "#Cstrike_ScoreBoard_Player" ), 2, teamName, wNumPlayers ); } else { g_pVGuiLocalize->ConstructString( string1, sizeof(string1), g_pVGuiLocalize->Find( "#Cstrike_ScoreBoard_Players" ), 2, teamName, wNumPlayers ); } // set # of players for team in dialog SetDialogVariable( pDialogVarTeamPlayerCount, string1 ); // set team score in dialog SetDialogVariable( pDialogVarTeamScore, team->Get_Score() ); int pingsum = 0; int numcounted = 0; for( int playerIndex = 1 ; playerIndex <= MAX_PLAYERS; playerIndex++ ) { if( g_PR->IsConnected( playerIndex ) && g_PR->GetTeam( playerIndex ) == teamIndex ) { int ping = g_PR->GetPing( playerIndex ); if ( ping >= 1 ) { pingsum += ping; numcounted++; } } } if ( numcounted > 0 ) { int ping = (int)( (float)pingsum / (float)numcounted ); SetDialogVariable( pDialogVarTeamPing, ping ); } else { SetDialogVariable( pDialogVarTeamPing, "" ); } } } }
//----------------------------------------------------------------------------- // Frame-based update //----------------------------------------------------------------------------- void CTFFourTeamMenu::OnTick() { if (TFGameRules() && !TFGameRules()->IsFourTeamGame()) return; // How did you even get here? // update the number of players on each team C_Team *pRed = GetGlobalTeam(TF_TEAM_RED); C_Team *pBlue = GetGlobalTeam(TF_TEAM_BLUE); C_Team *pGreen = GetGlobalTeam(TF_TEAM_GREEN); C_Team *pYellow = GetGlobalTeam(TF_TEAM_YELLOW); if (!pRed || !pBlue || !pGreen || !pYellow) return; // set our team counts SetDialogVariable("redcount", pRed->Get_Number_Players()); SetDialogVariable("bluecount", pBlue->Get_Number_Players()); SetDialogVariable("greencount", pGreen->Get_Number_Players()); SetDialogVariable("yellowcount", pYellow->Get_Number_Players()); C_TFPlayer *pLocalPlayer = C_TFPlayer::GetLocalTFPlayer(); if (!pLocalPlayer) return; CTFGameRules *pRules = TFGameRules(); if (!pRules) return; // check if teams are unbalanced m_bRedDisabled = m_bBlueDisabled = false; int iHeavyTeam, iLightTeam; bool bUnbalanced = pRules->AreTeamsUnbalanced(iHeavyTeam, iLightTeam); int iCurrentTeam = pLocalPlayer->GetTeamNumber(); if ((bUnbalanced && iHeavyTeam == TF_TEAM_RED) || (pRules->WouldChangeUnbalanceTeams(TF_TEAM_RED, iCurrentTeam))) { m_bRedDisabled = true; } if ((bUnbalanced && iHeavyTeam == TF_TEAM_BLUE) || (pRules->WouldChangeUnbalanceTeams(TF_TEAM_BLUE, iCurrentTeam))) { m_bBlueDisabled = true; } if (m_pSpecTeamButton && m_pSpecLabel) { ConVarRef mp_allowspectators("mp_allowspectators"); if (mp_allowspectators.IsValid()) { if (mp_allowspectators.GetBool()) { if (!m_pSpecTeamButton->IsVisible()) { m_pSpecTeamButton->SetVisible(true); m_pSpecLabel->SetVisible(true); } } else { if (m_pSpecTeamButton->IsVisible()) { m_pSpecTeamButton->SetVisible(false); m_pSpecLabel->SetVisible(false); } } } } }
//----------------------------------------------------------------------------- // Frame-based update //----------------------------------------------------------------------------- void CTFTeamMenu::OnTick() { // update the number of players on each team // enable or disable buttons based on team limit C_Team *pRed = GetGlobalTeam( TF_TEAM_RED ); C_Team *pBlue = GetGlobalTeam( TF_TEAM_BLUE ); if ( !pRed || !pBlue ) return; // set our team counts SetDialogVariable( "bluecount", pBlue->Get_Number_Players() ); SetDialogVariable( "redcount", pRed->Get_Number_Players() ); C_TFPlayer *pLocalPlayer = C_TFPlayer::GetLocalTFPlayer(); if ( !pLocalPlayer ) return; CTFGameRules *pRules = TFGameRules(); if ( !pRules ) return; // check if teams are unbalanced m_bRedDisabled = m_bBlueDisabled = false; int iHeavyTeam, iLightTeam; bool bUnbalanced = pRules->AreTeamsUnbalanced( iHeavyTeam, iLightTeam ); int iCurrentTeam = pLocalPlayer->GetTeamNumber(); if ( ( bUnbalanced && iHeavyTeam == TF_TEAM_RED ) || ( pRules->WouldChangeUnbalanceTeams( TF_TEAM_RED, iCurrentTeam ) ) ) { m_bRedDisabled = true; } if ( ( bUnbalanced && iHeavyTeam == TF_TEAM_BLUE ) || ( pRules->WouldChangeUnbalanceTeams( TF_TEAM_BLUE, iCurrentTeam ) ) ) { m_bBlueDisabled = true; } if ( m_pSpecTeamButton && m_pSpecLabel ) { ConVarRef mp_allowspectators( "mp_allowspectators" ); if ( mp_allowspectators.IsValid() ) { if ( mp_allowspectators.GetBool() ) { if ( !m_pSpecTeamButton->IsVisible() ) { m_pSpecTeamButton->SetVisible( true ); m_pSpecLabel->SetVisible( true ); } } else { if ( m_pSpecTeamButton->IsVisible() ) { m_pSpecTeamButton->SetVisible( false ); m_pSpecLabel->SetVisible( false ); } } } } }
//----------------------------------------------------------------------------- // 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); } } }