Exemplo n.º 1
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();
}
Exemplo n.º 2
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();
}
Exemplo n.º 3
0
void Group::RemovePlayer(Player* pPlayer)
{
	WorldPacket data;
	
	SubGroup *sg = GetSubGroup(pPlayer->GetSubGroup());
	ASSERT(sg); // something wrong here if that isn't right

	sg->RemovePlayer(pPlayer);
	pPlayer->SetGroup(NULL);
	if(pPlayer->GetSession() != NULL)
	{
		SendNullUpdate(pPlayer);

		//pPlayer->RemoveAllAreaAuras();

		data.SetOpcode(SMSG_GROUP_DESTROYED);
		pPlayer->GetSession()->SendPacket(&data);

		data.Initialize(SMSG_PARTY_COMMAND_RESULT);
		data << uint32(2) << uint8(0) << uint32(0);  // you leave the group
		pPlayer->GetSession()->SendPacket(&data);
	}

	if(m_MemberCount < 2)
	{
		Disband();
		return;
	}

	Player *newPlayer = FindFirstPlayer();

	if(m_Looter == pPlayer)
		m_Looter = newPlayer;

	if(m_Leader == pPlayer)
		SetLeader(newPlayer);
	else
		Update();
}
Exemplo n.º 4
0
void Group::RemovePlayer(PlayerInfo * info)
{
	WorldPacket data(50);
	Player * pPlayer = info->m_loggedInPlayer;

	m_groupLock.Acquire();
	if(m_isqueued)
	{
		m_isqueued = false;
		BattlegroundManager.RemoveGroupFromQueues(this);
	}
	
	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;
				}
			}
		}
	}

	info->m_Group = NULL;
	info->subGroup = -1;

	if(sg == NULL)
	{
		m_groupLock.Release();
		return;
	}

	m_dirty = true;
	sg->RemovePlayer( info );
	--m_MemberCount;

	// remove team member from the instance
	if( info->m_loggedInPlayer != NULL )
	{
		sInstanceMgr.PlayerLeftGroup( this, info->m_loggedInPlayer );
	}

	if( pPlayer != NULL )
	{
		if( pPlayer->GetSession() != NULL )
		{
			SendNullUpdate( pPlayer );

			data.SetOpcode( SMSG_GROUP_DESTROYED );
			pPlayer->GetSession()->SendPacket( &data );

			data.Initialize( SMSG_PARTY_COMMAND_RESULT );
			data << uint32(2) << uint8(0) << uint32(0);  // you leave the group
			pPlayer->GetSession()->SendPacket( &data );
		}

		//Remove some party auras.
		for (uint32 i=MAX_POSITIVE_AURAS_EXTEDED_START;i<MAX_POSITIVE_AURAS_EXTEDED_END;i++)
		{
			if (pPlayer->m_auras[i] && pPlayer->m_auras[i]->m_areaAura)
			{
				Player * caster = pPlayer->m_auras[i]->GetPlayerCaster();
				if( caster != NULL && pPlayer->GetLowGUID() != caster->GetLowGUID() )
					pPlayer->m_auras[i]->Remove();
			}
		}
	}

	if( m_MemberCount < 2 )
	{
		if( m_disbandOnNoMembers )
		{
			m_groupLock.Release();
			Disband();
			return;
		}
	}

	/* eek! ;P */
	Player *newPlayer = NULL;
	if(m_Looter == info)
	{
		newPlayer = FindFirstPlayer();
		if( newPlayer != NULL )
            m_Looter = newPlayer->getPlayerInfo();
		else
			m_Looter = NULL;
	}

	if(m_Leader == info)
	{
		if( newPlayer== NULL )
			newPlayer=FindFirstPlayer();

		if( newPlayer != NULL )
			SetLeader(newPlayer, false);
		else
			m_Leader = NULL;
	}

	Update();
	m_groupLock.Release();
}