Example #1
0
bool Group::AddMember(Player* pPlayer)
{
	if(!IsFull())
	{
		SubGroup* subgroup = FindFreeSubGroup();
		if(subgroup == NULL)
		{
			// weird shit..
			sLog.outDebug("GROUP: Tried to add member %s but FindFreeSubGroup returned NULL!", pPlayer->GetName());
			return false;
		}

		subgroup->AddPlayer(pPlayer);
		pPlayer->SetGroup(this);

		if(m_MemberCount == 1)
		{
			// We're the only member? Set us to the leader.
			SetLeader(pPlayer);
		}		

		UpdateAllOutOfRangePlayersFor(pPlayer);
		Update();	// Send group update

		return true;

	}
	else
	{
		return false;
	}
}
Example #2
0
bool Group::AddMember(PlayerInfo * info, int32 subgroupid/* =-1 */)
{
	m_groupLock.Acquire();
	Player * pPlayer = info->m_loggedInPlayer;

	if( m_isqueued )
	{
		m_isqueued = false;
		BattlegroundManager.RemoveGroupFromQueues(this);
	}

	if( !IsFull() )
	{
		SubGroup* subgroup = (subgroupid>0) ? m_SubGroups[subgroupid] : FindFreeSubGroup();
		if(subgroup == NULL)
		{
			m_groupLock.Release();
			return false;
		}

		if( subgroup->AddPlayer( info ) )
		{
			if( pPlayer != NULL )
				sEventMgr.AddEvent( pPlayer,&Player::EventGroupFullUpdate, EVENT_PLAYER_UPDATE, 1500, 1, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT );
            
			if( info->m_Group && info->m_Group != this )
				info->m_Group->RemovePlayer( info );

			if( m_Leader == NULL && info->m_loggedInPlayer )
				m_Leader = info;

			info->m_Group = this;
			info->subGroup = (int8)subgroup->GetID();

			++m_MemberCount;
			m_dirty = true;
			Update();	// Send group update

			m_groupLock.Release();
			return true;
		}
		else
		{
			m_groupLock.Release();
			info->m_Group = NULL;
			info->subGroup = -1;
			return false;
		}

	}
	else
	{
		info->m_Group = NULL;
		info->subGroup = -1;
		m_groupLock.Release();
		return false;
	}
}
Example #3
0
void Group::MovePlayer(Player *pPlayer, uint8 subgroup)
{
	ASSERT(subgroup < m_SubGroupCount);
	SubGroup *sgr = GetSubGroup(pPlayer->GetSubGroup());
	
	sgr->RemovePlayer(pPlayer);

	// Grab the new group, and insert
	sgr = m_SubGroups[subgroup];
	sgr->AddPlayer(pPlayer);

	Update();
}
Example #4
0
void Group::MovePlayer(PlayerInfo *info, uint8 subgroup)
{
	if( subgroup >= m_SubGroupCount )
		return;

	if( m_SubGroups[subgroup]->IsFull() )
		return;

	m_groupLock.Acquire();
	SubGroup *sg = NULL;

	if( info->subGroup > 0 && info->subGroup <= 8 )
		sg = m_SubGroups[info->subGroup];

	if( sg == NULL || sg->m_GroupMembers.find(info) == sg->m_GroupMembers.end() )
	{
		for( uint8 i = 0; i < m_SubGroupCount; ++i )
		{
			if( m_SubGroups[i] != NULL )
			{
				if( m_SubGroups[i]->m_GroupMembers.find(info) != m_SubGroups[i]->m_GroupMembers.end() )
				{
					sg = m_SubGroups[i];
					break;
				}
			}
		}
	}

	if( sg == NULL )
	{
		m_groupLock.Release();
		return;
	}
	
	sg->RemovePlayer( info );
    
	// Grab the new group, and insert
	sg = m_SubGroups[subgroup];
	if( !sg->AddPlayer( info ) )
	{
		RemovePlayer( info );
	}
	else
	{
		info->subGroup = (int8)sg->GetID();
	}
	
	Update();
	m_groupLock.Release();
}