mirror of
https://github.com/nillerusr/source-engine.git
synced 2025-04-02 13:32:37 +00:00
77 lines
2.4 KiB
C++
77 lines
2.4 KiB
C++
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
|
//
|
|
// Purpose: TF's custom C_PlayerResource
|
|
//
|
|
// $NoKeywords: $
|
|
//=============================================================================//
|
|
#include "cbase.h"
|
|
#include "c_tf_playerresource.h"
|
|
#include <shareddefs.h>
|
|
#include <tf_shareddefs.h>
|
|
#include "hud.h"
|
|
|
|
// memdbgon must be the last include file in a .cpp file!!!
|
|
#include "tier0/memdbgon.h"
|
|
|
|
|
|
IMPLEMENT_CLIENTCLASS_DT( C_TF_PlayerResource, DT_TFPlayerResource, CTFPlayerResource )
|
|
RecvPropArray3( RECVINFO_ARRAY( m_iTotalScore ), RecvPropInt( RECVINFO( m_iTotalScore[0] ) ) ),
|
|
RecvPropArray3( RECVINFO_ARRAY( m_iMaxHealth ), RecvPropInt( RECVINFO( m_iMaxHealth[0] ) ) ),
|
|
RecvPropArray3( RECVINFO_ARRAY( m_iPlayerClass ), RecvPropInt( RECVINFO( m_iPlayerClass[0] ) ) ),
|
|
END_RECV_TABLE()
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Purpose:
|
|
//-----------------------------------------------------------------------------
|
|
C_TF_PlayerResource::C_TF_PlayerResource()
|
|
{
|
|
m_Colors[TEAM_UNASSIGNED] = COLOR_TF_SPECTATOR;
|
|
m_Colors[TEAM_SPECTATOR] = COLOR_TF_SPECTATOR;
|
|
m_Colors[TF_TEAM_RED] = COLOR_RED;
|
|
m_Colors[TF_TEAM_BLUE] = COLOR_BLUE;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Purpose:
|
|
//-----------------------------------------------------------------------------
|
|
C_TF_PlayerResource::~C_TF_PlayerResource()
|
|
{
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Purpose: Gets a value from an array member
|
|
//-----------------------------------------------------------------------------
|
|
int C_TF_PlayerResource::GetArrayValue( int iIndex, int *pArray, int iDefaultVal )
|
|
{
|
|
if ( !IsConnected( iIndex ) )
|
|
{
|
|
return iDefaultVal;
|
|
}
|
|
return pArray[iIndex];
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Purpose:
|
|
//-----------------------------------------------------------------------------
|
|
int C_TF_PlayerResource::GetCountForPlayerClass( int iTeam, int iClass, bool bExcludeLocalPlayer /*=false*/ )
|
|
{
|
|
int count = 0;
|
|
int iLocalPlayerIndex = GetLocalPlayerIndex();
|
|
|
|
for ( int i = 1 ; i <= MAX_PLAYERS ; i++ )
|
|
{
|
|
if ( bExcludeLocalPlayer && ( i == iLocalPlayerIndex ) )
|
|
{
|
|
continue;
|
|
}
|
|
|
|
if ( ( GetTeam( i ) == iTeam ) && ( GetPlayerClass( i ) == iClass ) )
|
|
{
|
|
count++;
|
|
}
|
|
}
|
|
|
|
return count;
|
|
}
|