#include "hud.h"
#include "cl_util.h"
#include "parsemsg.h"

DECLARE_MESSAGE(m_PowerLevel, PowerLevel);

int CHudPowerLevel::Init(void)
{	HOOK_MESSAGE(PowerLevel);
	m_iPowerLevel = 750000;

	gHUD.AddHudElem(this);
	m_iFlags |= HUD_ACTIVE;
	return 1;
}

int CHudPowerLevel::MsgFunc_PowerLevel(const char *pszName, int iSize, void *pbuf)
{	BEGIN_READ( pbuf, iSize );
	int iEnt = READ_BYTE();
	int iPowerLevel = READ_LONG();
	
	g_PlayerExtraInfo[iEnt].powerlevel = iPowerLevel;
	
	cl_entity_t *player;
	player = gEngfuncs.GetLocalPlayer();

	if (iEnt == player->index)
	{	m_iPowerLevel = iPowerLevel;
	}
	return 1;
}