// DWBS ------------------------------------------------------------------ DWBS
//
// PLATFORM		: ALL
// PRODUCT		: BIT_DEMON
// VISIBILITY	: PUBLIC
//
// DWBS ------------------------------------------------------------------ DWBS

#include <bdLobby/bdTeams/bdCheckTeamMembershipResult.h>

bdCheckTeamMembershipResult::bdTeam::bdTeam()
: m_teamID(BD_NULL),
  m_memberStatus(BD_NULL)
{
	bdMemset(m_teamName, BD_NULL, BD_MAX_TEAMNAME_LENGTH);
}

bdCheckTeamMembershipResult::bdCheckTeamMembershipResult()
{
}

bdCheckTeamMembershipResult::~bdCheckTeamMembershipResult()
{
	m_teams.clear();
}

bdBool bdCheckTeamMembershipResult::handleResult(const bdUInt numResults, 
												 bdBitBufferRef buffer)
{
	bdBool ok = true;

	for(bdUInt i=0; ok && (i < numResults); i++)
	{
		bdCheckTeamMembershipResult::bdTeam team;

		ok = buffer->readUInt64(team.m_teamID);
		ok = ok && buffer->readString(team.m_teamName, BD_MAX_TEAMNAME_LENGTH);
		ok = ok && buffer->readUByte8(team.m_memberStatus);

		if(ok)
		{
			m_teams.pushBack(team);
		}
	}

	m_numResults = m_teams.getSize();

	return ok;
}
