本文整理汇总了C++中SubGroup类的典型用法代码示例。如果您正苦于以下问题:C++ SubGroup类的具体用法?C++ SubGroup怎么用?C++ SubGroup使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SubGroup类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SpellTargetPartyMember
/// Spell Target Handling for type 37: all Members of the targets party
void Spell::SpellTargetPartyMember(uint32 i, uint32 j)
{
if(!m_caster->IsInWorld())
return;
TargetsList* tmpMap=&m_targetUnits[i];
// if no group target self
Player * Target = m_caster->GetMapMgr()->GetPlayer((uint32)m_targets.m_unitTarget);
if(!Target)
return;
SubGroup * subgroup = Target->GetGroup() ?
Target->GetGroup()->GetSubGroup(Target->GetSubGroup()) : 0;
float rsqr = GetRadius( i );
if( rsqr == 0 )
rsqr = 40*40;//kinda like a bug. 0 range to target a party member ? Highly impossible
else rsqr *= rsqr;
if(subgroup)
{
Target->GetGroup()->Lock();
for(GroupMembersSet::iterator itr = subgroup->GetGroupMembersBegin(); itr != subgroup->GetGroupMembersEnd(); ++itr)
//if you are picky you could also check if on same map. Let's face it you won't similar positions on different maps
if((*itr)->m_loggedInPlayer && IsInrange(Target,(*itr)->m_loggedInPlayer, rsqr) )
SafeAddTarget(tmpMap,(*itr)->m_loggedInPlayer->GetGUID());
Target->GetGroup()->Unlock();
}
else
{
SafeAddTarget(tmpMap,Target->GetGUID());
}
}
示例2: SpellTargetPartyMember
// Spell Target Handling for type 37: all Members of the targets party
void Spell::SpellTargetPartyMember(uint32 i, uint32 j)
{
if(!m_caster->IsInWorld())
return;
// if no group target self
Player* Target = m_caster->GetMapMgr()->GetPlayer((uint32)m_targets.m_unitTarget);
if(!Target)
return;
SubGroup * subgroup = Target->GetGroup() ?
Target->GetGroup()->GetSubGroup(Target->GetSubGroup()) : 0;
if(subgroup)
{
Target->GetGroup()->Lock();
for(GroupMembersSet::iterator itr = subgroup->GetGroupMembersBegin(); itr != subgroup->GetGroupMembersEnd(); itr++)
{
if((*itr)->m_loggedInPlayer)
_AddTargetForced( (*itr)->m_loggedInPlayer->GetGUID(), i );
}
Target->GetGroup()->Unlock();
}
else
_AddTargetForced(Target->GetGUID(), i);
}
示例3: FindFreeSubGroup
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;
}
}
示例4: SendPacketToAll
void Group::Disband()
{
m_groupLock.Acquire();
m_updateblock = true;
if(m_isqueued)
{
m_isqueued=false;
WorldPacket * data = sChatHandler.FillSystemMessageData("A change was made to your group. Removing the arena queue.");
SendPacketToAll(data);
delete data;
BattlegroundManager.RemoveGroupFromQueues(this);
}
uint32 i = 0;
for(i = 0; i < m_SubGroupCount; i++)
{
SubGroup *sg = m_SubGroups[i];
sg->Disband();
}
m_groupLock.Release();
CharacterDatabase.Execute("DELETE FROM groups WHERE group_id = %u", m_Id);
sInstanceMgr.OnGroupDestruction(this);
delete this; // destroy ourselves, the destructor removes from eventmgr and objectmgr.
}
示例5: SafeAddTarget
// Spell Target Handling for type 56: Target all raid members. (WotLK)
void Spell::SpellTargetAllRaid( uint32 i, uint32 j )
{
if( !m_caster->IsInWorld() || !m_caster->IsUnit() )
return;
TargetsList* tmpMap = &m_targetUnits[i];
SafeAddTarget( tmpMap, m_caster->GetGUID() );
Group * group = static_cast< Unit* >( m_caster )->GetGroup();
if( group == NULL )
return;
uint32 count = group->GetSubGroupCount();
// Loop through each raid group.
group->Lock();
for( uint8 k = 0; k < count; k++ )
{
SubGroup * subgroup = group->GetSubGroup( k );
if( subgroup )
{
for( GroupMembersSet::iterator itr = subgroup->GetGroupMembersBegin(); itr != subgroup->GetGroupMembersEnd(); ++itr )
{
if( (*itr)->m_loggedInPlayer && (*itr)->m_loggedInPlayer != m_caster)
SafeAddTarget( tmpMap,(*itr)->m_loggedInPlayer->GetGUID() );
}
}
}
group->Unlock();
}
示例6: SpellTargetSameGroupSameClass
/// Spell Target Handling for type 61: targets with the same group/raid and the same class
void Spell::SpellTargetSameGroupSameClass(uint32 i, uint32 j)
{
TargetsList* tmpMap=&m_targetUnits[i];
if(!m_caster->IsInWorld())
return;
Player * Target = m_caster->GetMapMgr()->GetPlayer((uint32)m_targets.m_unitTarget);
if(!Target)
return;
SubGroup * subgroup = Target->GetGroup() ?
Target->GetGroup()->GetSubGroup(Target->GetSubGroup()) : 0;
if(subgroup)
{
Target->GetGroup()->Lock();
for(GroupMembersSet::iterator itr = subgroup->GetGroupMembersBegin(); itr != subgroup->GetGroupMembersEnd(); ++itr)
{
if(!(*itr)->m_loggedInPlayer || Target->getClass() != (*itr)->m_loggedInPlayer->getClass())
continue;
SafeAddTarget(tmpMap,(*itr)->m_loggedInPlayer->GetGUID());
}
Target->GetGroup()->Unlock();
}
}
示例7: FindFreeSubGroup
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;
}
}
示例8: buf
void Group::SendLootUpdates( Object *o ){
// Build the actual update.
ByteBuffer buf( 500 );
uint32 Flags = o->GetUInt32Value( UNIT_DYNAMIC_FLAGS );
Flags |= U_DYN_FLAG_LOOTABLE;
Flags |= U_DYN_FLAG_TAPPED_BY_PLAYER;
o->BuildFieldUpdatePacket( &buf, UNIT_DYNAMIC_FLAGS, Flags );
Lock();
switch( m_LootMethod ){
case PARTY_LOOT_RR:
case PARTY_LOOT_FFA:
case PARTY_LOOT_GROUP:
case PARTY_LOOT_NBG:{
SubGroup *sGrp = NULL;
GroupMembersSet::iterator itr2;
for( uint32 Index = 0; Index < GetSubGroupCount(); ++Index ){
sGrp = GetSubGroup( Index );
itr2 = sGrp->GetGroupMembersBegin();
for( ; itr2 != sGrp->GetGroupMembersEnd(); ++itr2 ){
PlayerInfo *p = *itr2;
if( p->m_loggedInPlayer != NULL && p->m_loggedInPlayer->IsVisible( o->GetGUID() ) ) // Save updates for non-existent creatures
p->m_loggedInPlayer->PushUpdateData( &buf, 1 );
}
}
break;}
case PARTY_LOOT_MASTER:{
Player * pLooter = GetLooter() ? GetLooter()->m_loggedInPlayer : NULL;
if( pLooter == NULL )
pLooter = GetLeader()->m_loggedInPlayer;
if( pLooter->IsVisible( o->GetGUID() ) ){
Unit *victim = static_cast< Unit* >( o );
victim->Tag( pLooter->GetGUID() );
pLooter->PushUpdateData( &buf, 1 );
}
break;}
}
Unlock();
}
示例9: Disband
void Group::Disband()
{
uint32 i = 0;
for(i = 0; i < m_SubGroupCount; i++)
{
SubGroup *sg = m_SubGroups[i];
sg->Disband(true);
}
delete this; // destroy ourselves, the destructor removes from eventmgr and objectmgr.
}
示例10: data
void WorldSession::HandleLootOpcode( WorldPacket & recv_data )
{
if(!_player->IsInWorld())
return;
uint64 guid;
recv_data >> guid;
if(_player->isCasting())
_player->InterruptSpell();
if(_player->InGroup() && !_player->m_bgInBattleground)
{
Group * party = _player->GetGroup();
if(party)
{
if(party->GetMethod() == PARTY_LOOT_MASTER)
{
WorldPacket data(SMSG_LOOT_MASTER_LIST, 330); // wont be any larger
data << (uint8)party->MemberCount();
uint32 real_count = 0;
SubGroup *s;
GroupMembersSet::iterator itr;
for(uint32 i = 0; i < party->GetSubGroupCount(); ++i)
{
s = party->GetSubGroup(i);
for(itr = s->GetGroupMembersBegin(); itr != s->GetGroupMembersEnd(); ++itr)
{
if(_player->GetZoneId() == (*itr)->GetZoneId())
{
data << (*itr)->GetGUID();
++real_count;
}
}
}
*(uint8*)&data.contents()[0] = real_count;
party->SendPacketToAll(&data);
}
/* //this commented code is not used because it was never tested and finished !
else if(party->GetMethod() == PARTY_LOOT_RR)
{
Creature *target=GetPlayer()->GetMapMgr()->GetCreature(guid); //maybe we should extend this to other object types too
if(target)
{
if(target->TaggerGuid==GetPlayer()->GetGUID())
GetPlayer()->SendLoot(guid,1);
else return;
}
}*/
}
}
GetPlayer()->SendLoot(guid,1);
}
示例11: ASSERT
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();
}
示例12: MovePlayer
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();
}
示例13: Lock
void Group::SendPacketToAllInRange(Player* plr, WorldPacket* packet)
{
Lock();
for(uint8 i = 0; i < GetSubGroupCount(); ++i)
{
SubGroup* sg = GetSubGroup(i);
for(GroupMembersSet::iterator itr = sg->GetGroupMembersBegin(); itr != sg->GetGroupMembersEnd(); ++itr)
{
if((*itr)->m_loggedInPlayer && (*itr)->m_loggedInPlayer->GetDistance2dSq(plr) < 80.0f)
(*itr)->m_loggedInPlayer->GetSession()->SendPacket(packet);
}
}
Unlock();
}
示例14: OnKillPlayer
void GenericBattleground::OnKillPlayer(Player * pPlayer, Player * pVictim)
{
if( pPlayer == NULL || pVictim == NULL || pPlayer != pVictim )
return;
Group * pGroup = pPlayer->GetGroup();
if( pGroup == NULL )
{
pPlayer->BroadcastMessage("You've been awarded 10 gold for slaying %s", pVictim->GetName());
pPlayer->ModUnsigned32Value(PLAYER_FIELD_COINAGE, 100000);
}
else
{
std::vector<Player*> GroupMembers;
std::set<Player*> PotentialHealers;
pPlayer->GetGroup()->Lock();
for(uint8 i = 0; i < pPlayer->GetGroup()->GetSubGroupCount(); i++)
{
SubGroup * pSubGroup = pPlayer->GetGroup()->GetSubGroup(i);
if(!pSubGroup) continue;
GroupMembersSet::iterator itr = pSubGroup->GetGroupMembersBegin();
for(; itr != pSubGroup->GetGroupMembersEnd(); itr++)
{
PlayerInfo * pi = *itr;
if(!pi) continue;
Player * tPlr = pi->m_loggedInPlayer;
if(!tPlr)
continue;
// Ineligible due to distance.
if(tPlr->GetDistance2dSq(pPlayer) > 80.0f && tPlr != pPlayer)
continue;
GroupMembers.push_back(pi->m_loggedInPlayer);
}
}
// Pick a number, any number!
if(GroupMembers.size() > 0)
{
uint32 reward = RandomUInt(GroupMembers.size() - 1);
GroupMembers[reward]->ModUnsigned32Value(PLAYER_FIELD_COINAGE, 100000);
GroupMembers[reward]->BroadcastMessage("You've been awarded 10 gold for slaying %s.", pVictim->GetName());
}
pPlayer->GetGroup()->Unlock();
}
}
示例15: if
/// Spell Target Handling for type 18: All Party Members around the Caster in given range NOT RAID
void Spell::SpellTargetAllPartyMembersRangeNR(uint32 i, uint32 j)
{
TargetsList* tmpMap = &m_targetUnits[i];
Player* p = p_caster;
if( p == NULL )
{
if( static_cast< Creature* >( u_caster)->IsTotem() )
p = static_cast< Player* >( static_cast< Creature* >( u_caster )->GetTotemOwner() );
else if( u_caster->IsPet() && static_cast< Pet* >( u_caster )->GetPetOwner() )
p = static_cast< Pet* >( u_caster )->GetPetOwner();
else if( u_caster->GetUInt64Value( UNIT_FIELD_CREATEDBY ) )
{
Unit *t = u_caster->GetMapMgr()->GetUnit( u_caster->GetUInt64Value( UNIT_FIELD_CREATEDBY ) );
if ( t && t->IsPlayer() )
p = static_cast< Player* >( t );
}
}
if( p == NULL )
return;
float r = GetRadius(i);
r *= r;
if( IsInrange( m_caster->GetPositionX(), m_caster->GetPositionY(), m_caster->GetPositionZ(), p, r ) )
SafeAddTarget( tmpMap, p->GetGUID() );
SubGroup* subgroup = p->GetGroup() ? p->GetGroup()->GetSubGroup( p->GetSubGroup() ) : 0;
if( subgroup != NULL )
{
p->GetGroup()->Lock();
for(GroupMembersSet::iterator itr = subgroup->GetGroupMembersBegin(); itr != subgroup->GetGroupMembersEnd(); ++itr)
{
if(!(*itr)->m_loggedInPlayer || m_caster == (*itr)->m_loggedInPlayer)
continue;
if(IsInrange(m_caster->GetPositionX(),m_caster->GetPositionY(),m_caster->GetPositionZ(),(*itr)->m_loggedInPlayer,r))
SafeAddTarget(tmpMap,(*itr)->m_loggedInPlayer->GetGUID());
}
p->GetGroup()->Unlock();
}
}