AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
Group Class Reference

#include "Group.h"

Classes

struct  MemberSlot
 

Public Types

typedef std::list< MemberSlotMemberSlotList
 
typedef MemberSlotList::const_iterator member_citerator
 

Public Member Functions

 Group ()
 
 ~Group ()
 
bool Create (Player *leader)
 
bool LoadGroupFromDB (Field *field)
 
void LoadMemberFromDB (ObjectGuid::LowType guidLow, uint8 memberFlags, uint8 subgroup, uint8 roles)
 
bool AddInvite (Player *player)
 
void RemoveInvite (Player *player)
 
void RemoveAllInvites ()
 
bool AddLeaderInvite (Player *player)
 
bool AddMember (Player *player, uint8 roles=0)
 
bool RemoveMember (ObjectGuid guid, const RemoveMethod &method=GROUP_REMOVEMETHOD_DEFAULT, ObjectGuid kicker=ObjectGuid::Empty, const char *reason=nullptr)
 
void ChangeLeader (ObjectGuid guid)
 
void SetLootMethod (LootMethod method)
 
void SetLooterGuid (ObjectGuid guid)
 
void SetMasterLooterGuid (ObjectGuid guid)
 
void UpdateLooterGuid (WorldObject *pLootedObject, bool ifneed=false)
 
void SetLootThreshold (ItemQualities threshold)
 
void Disband (bool hideDestroy=false)
 
void SetLfgRoles (ObjectGuid guid, const uint8 roles)
 
bool IsFull () const
 
bool isLFGGroup (bool restricted=false) const
 
bool isRaidGroup () const
 
bool isBFGroup () const
 
bool isBGGroup () const
 
bool IsCreated () const
 
GroupType GetGroupType () const
 
ObjectGuid GetLeaderGUID () const
 
PlayerGetLeader ()
 
ObjectGuid GetGUID () const
 
const char * GetLeaderName () const
 
LootMethod GetLootMethod () const
 
ObjectGuid GetLooterGuid () const
 
ObjectGuid GetMasterLooterGuid () const
 
ItemQualities GetLootThreshold () const
 
bool IsMember (ObjectGuid guid) const
 
bool IsLeader (ObjectGuid guid) const
 
ObjectGuid GetMemberGUID (const std::string &name)
 
bool IsAssistant (ObjectGuid guid) const
 
PlayerGetInvited (ObjectGuid guid) const
 
PlayerGetInvited (const std::string &name) const
 
bool SameSubGroup (ObjectGuid guid1, ObjectGuid guid2) const
 
bool SameSubGroup (ObjectGuid guid1, MemberSlot const *slot2) const
 
bool SameSubGroup (Player const *member1, Player const *member2) const
 
bool HasFreeSlotSubGroup (uint8 subgroup) const
 
MemberSlotList const & GetMemberSlots () const
 
GroupReferenceGetFirstMember ()
 
GroupReference const * GetFirstMember () const
 
uint32 GetMembersCount () const
 
uint32 GetInviteeCount () const
 
uint8 GetMemberGroup (ObjectGuid guid) const
 
void ConvertToLFG (bool restricted=true)
 
bool CheckLevelForRaid ()
 
void ConvertToRaid ()
 
void SetBattlegroundGroup (Battleground *bg)
 
void SetBattlefieldGroup (Battlefield *bf)
 
GroupJoinBattlegroundResult CanJoinBattlegroundQueue (Battleground const *bgTemplate, BattlegroundQueueTypeId bgQueueTypeId, uint32 MinPlayerCount, uint32 MaxPlayerCount, bool isRated, uint32 arenaSlot)
 
void DoMinimapPing (ObjectGuid sourceGuid, float mapX, float mapY)
 
void ChangeMembersGroup (ObjectGuid guid, uint8 group)
 
void SetTargetIcon (uint8 id, ObjectGuid whoGuid, ObjectGuid targetGuid)
 
void SetGroupMemberFlag (ObjectGuid guid, bool apply, GroupMemberFlags flag)
 
void RemoveUniqueGroupMemberFlag (GroupMemberFlags flag)
 
Difficulty GetDifficulty (bool isRaid) const
 
Difficulty GetDungeonDifficulty () const
 
Difficulty GetRaidDifficulty () const
 
void SetDungeonDifficulty (Difficulty difficulty)
 
void SetRaidDifficulty (Difficulty difficulty)
 
uint16 InInstance ()
 
void ResetInstances (uint8 method, bool isRaid, Player *leader)
 
void SendTargetIconList (WorldSession *session)
 
void SendUpdate ()
 
void SendUpdateToPlayer (ObjectGuid playerGUID, MemberSlot *slot=nullptr)
 
void UpdatePlayerOutOfRange (Player *player)
 
void BroadcastPacket (WorldPacket const *packet, bool ignorePlayersInBGRaid, int group=-1, ObjectGuid ignore=ObjectGuid::Empty)
 
void BroadcastReadyCheck (WorldPacket const *packet)
 
void OfflineReadyCheck ()
 
bool isRollLootActive () const
 
void SendLootStartRoll (uint32 CountDown, uint32 mapid, const Roll &r)
 
void SendLootStartRollToPlayer (uint32 countDown, uint32 mapId, Player *p, bool canNeed, Roll const &r)
 
void SendLootRoll (ObjectGuid SourceGuid, ObjectGuid TargetGuid, uint8 RollNumber, uint8 RollType, const Roll &r, bool autoPass=false)
 
void SendLootRollWon (ObjectGuid SourceGuid, ObjectGuid TargetGuid, uint8 RollNumber, uint8 RollType, const Roll &r)
 
void SendLootAllPassed (Roll const &roll)
 
void SendLooter (Creature *creature, Player *pLooter)
 
void GroupLoot (Loot *loot, WorldObject *pLootedObject)
 
void NeedBeforeGreed (Loot *loot, WorldObject *pLootedObject)
 
void MasterLoot (Loot *loot, WorldObject *pLootedObject)
 
Rolls::iterator GetRoll (ObjectGuid Guid)
 
void CountTheRoll (Rolls::iterator roll)
 
bool CountRollVote (ObjectGuid playerGUID, ObjectGuid Guid, uint8 Choise)
 
void EndRoll (Loot *loot)
 
void RemovePlayerFromRolls (ObjectGuid guid)
 
void ResetMaxEnchantingLevel ()
 
void LinkMember (GroupReference *pRef)
 
void BroadcastGroupUpdate (void)
 
void AddLfgBuffFlag ()
 
void AddLfgRandomInstanceFlag ()
 
void AddLfgHeroicFlag ()
 
bool IsLfgWithBuff () const
 
bool IsLfgRandomInstance () const
 
bool IsLfgHeroic () const
 
uint32 GetDifficultyChangePreventionTime () const
 
DifficultyPreventionChangeType GetDifficultyChangePreventionReason () const
 
void SetDifficultyChangePrevention (DifficultyPreventionChangeType type)
 
void DoForAllMembers (std::function< void(Player *)> const &worker)
 

Public Attributes

DataMap CustomData
 

Protected Types

typedef MemberSlotList::iterator member_witerator
 
typedef std::set< Player * > InvitesList
 
typedef std::vector< Roll * > Rolls
 

Protected Member Functions

void _homebindIfInstance (Player *player)
 
void _cancelHomebindIfInstance (Player *player)
 
void _initRaidSubGroupsCounter ()
 
member_citerator _getMemberCSlot (ObjectGuid Guid) const
 
member_witerator _getMemberWSlot (ObjectGuid Guid)
 
void SubGroupCounterIncrease (uint8 subgroup)
 
void SubGroupCounterDecrease (uint8 subgroup)
 
void ToggleGroupMemberFlag (member_witerator slot, uint8 flag, bool apply)
 

Protected Attributes

MemberSlotList m_memberSlots
 
GroupRefMgr m_memberMgr
 
InvitesList m_invitees
 
ObjectGuid m_leaderGuid
 
std::string m_leaderName
 
GroupType m_groupType
 
Difficulty m_dungeonDifficulty
 
Difficulty m_raidDifficulty
 
Battlefieldm_bfGroup
 
Battlegroundm_bgGroup
 
ObjectGuid m_targetIcons [TARGETICONCOUNT]
 
LootMethod m_lootMethod
 
ItemQualities m_lootThreshold
 
ObjectGuid m_looterGuid
 
ObjectGuid m_masterLooterGuid
 
Rolls RollId
 
uint8m_subGroupsCounts
 
ObjectGuid m_guid
 
uint32 m_counter
 
uint32 m_maxEnchantingLevel
 
uint8 m_lfgGroupFlags
 
uint32 _difficultyChangePreventionTime
 
DifficultyPreventionChangeType _difficultyChangePreventionType
 

Detailed Description

request member stats checken todo: uninvite people that not accepted invite

Member Typedef Documentation

◆ InvitesList

typedef std::set<Player*> Group::InvitesList
protected

◆ member_citerator

typedef MemberSlotList::const_iterator Group::member_citerator

◆ member_witerator

typedef MemberSlotList::iterator Group::member_witerator
protected

◆ MemberSlotList

typedef std::list<MemberSlot> Group::MemberSlotList

◆ Rolls

typedef std::vector<Roll*> Group::Rolls
protected

Constructor & Destructor Documentation

◆ Group()

Group::Group ( )
105{
106 sScriptMgr->OnConstructGroup(this);
107}
@ RAID_DIFFICULTY_10MAN_NORMAL
Definition DBCEnums.h:273
@ DUNGEON_DIFFICULTY_NORMAL
Definition DBCEnums.h:269
@ GROUPTYPE_NORMAL
Definition Group.h:86
@ DIFFICULTY_PREVENTION_CHANGE_NONE
Definition Group.h:140
@ FREE_FOR_ALL
Definition LootMgr.h:58
#define sScriptMgr
Definition ScriptMgr.h:740
@ ITEM_QUALITY_UNCOMMON
Definition SharedDefines.h:319
uint32 m_counter
Definition Group.h:364
Battlefield * m_bfGroup
Definition Group.h:354
uint32 m_maxEnchantingLevel
Definition Group.h:365
DifficultyPreventionChangeType _difficultyChangePreventionType
Definition Group.h:370
std::string m_leaderName
Definition Group.h:350
Battleground * m_bgGroup
Definition Group.h:355
Difficulty m_raidDifficulty
Definition Group.h:353
LootMethod m_lootMethod
Definition Group.h:357
uint8 * m_subGroupsCounts
Definition Group.h:362
Difficulty m_dungeonDifficulty
Definition Group.h:352
ItemQualities m_lootThreshold
Definition Group.h:358
GroupType m_groupType
Definition Group.h:351
uint32 _difficultyChangePreventionTime
Definition Group.h:369

References sScriptMgr.

◆ ~Group()

Group::~Group ( )
110{
111 sScriptMgr->OnDestructGroup(this);
112
113 if (m_bgGroup)
114 {
115 LOG_DEBUG("bg.battleground", "Group::~Group: battleground group being deleted.");
116
117 if (m_bgGroup->GetBgRaid(TEAM_ALLIANCE) == this)
118 {
120 }
121 else if (m_bgGroup->GetBgRaid(TEAM_HORDE) == this)
122 {
123 m_bgGroup->SetBgRaid(TEAM_HORDE, nullptr);
124 }
125 else
126 LOG_ERROR("bg.battleground", "Group::~Group: battleground group is not linked to the correct battleground.");
127 }
128
129 Rolls::iterator itr;
130 while (!RollId.empty())
131 {
132 itr = RollId.begin();
133 Roll* r = *itr;
134 RollId.erase(itr);
135 delete(r);
136 }
137
138 // Sub group counters clean up
139 delete[] m_subGroupsCounts;
140}
#define LOG_ERROR(filterType__,...)
Definition Log.h:145
#define LOG_DEBUG(filterType__,...)
Definition Log.h:157
@ TEAM_ALLIANCE
Definition SharedDefines.h:748
@ TEAM_HORDE
Definition SharedDefines.h:749
Group * GetBgRaid(TeamId teamId) const
Definition Battleground.h:492
void SetBgRaid(TeamId teamId, Group *bg_raid)
Definition Battleground.cpp:1884
Rolls RollId
Definition Group.h:361
Definition Group.h:150

References Battleground::GetBgRaid(), LOG_DEBUG, LOG_ERROR, m_bgGroup, m_subGroupsCounts, RollId, Battleground::SetBgRaid(), sScriptMgr, TEAM_ALLIANCE, and TEAM_HORDE.

Member Function Documentation

◆ _cancelHomebindIfInstance()

void Group::_cancelHomebindIfInstance ( Player player)
protected
2265{
2266 // if player is reinvited to group and in the instance - cancel homebind timer
2267 if (!player->FindMap() || !player->FindMap()->IsDungeon())
2268 return;
2269 InstancePlayerBind* bind = sInstanceSaveMgr->PlayerGetBoundInstance(player->GetGUID(), player->FindMap()->GetId(), player->GetDifficulty(player->FindMap()->IsRaid()));
2270 if (bind && bind->save->GetInstanceId() == player->GetInstanceId())
2271 player->m_InstanceValid = true;
2272}
#define sInstanceSaveMgr
Definition InstanceSaveMgr.h:202
uint32 GetInstanceId() const
Definition InstanceSaveMgr.h:61
bool IsDungeon() const
Definition Map.h:297
bool IsRaid() const
Definition Map.h:299
uint32 GetId() const
Definition Map.h:232
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:114
bool m_InstanceValid
Definition Player.h:2477
Difficulty GetDifficulty(bool isRaid) const
Definition Player.h:1940
Map * FindMap() const
Definition Object.h:626
uint32 GetInstanceId() const
Definition Object.h:513
Definition InstanceSaveMgr.h:39
InstanceSave * save
Definition InstanceSaveMgr.h:40

References WorldObject::FindMap(), Player::GetDifficulty(), Object::GetGUID(), Map::GetId(), WorldObject::GetInstanceId(), InstanceSave::GetInstanceId(), Map::IsDungeon(), Map::IsRaid(), Player::m_InstanceValid, InstancePlayerBind::save, and sInstanceSaveMgr.

Referenced by AddMember().

◆ _getMemberCSlot()

Group::member_citerator Group::_getMemberCSlot ( ObjectGuid  Guid) const
protected
2565{
2566 for (member_citerator itr = m_memberSlots.begin(); itr != m_memberSlots.end(); ++itr)
2567 if (itr->guid == Guid)
2568 return itr;
2569 return m_memberSlots.end();
2570}
MemberSlotList m_memberSlots
Definition Group.h:346
MemberSlotList::const_iterator member_citerator
Definition Group.h:187

References m_memberSlots.

Referenced by GetMemberGroup(), IsAssistant(), IsMember(), SameSubGroup(), SameSubGroup(), and UpdateLooterGuid().

◆ _getMemberWSlot()

Group::member_witerator Group::_getMemberWSlot ( ObjectGuid  Guid)
protected
2573{
2574 for (member_witerator itr = m_memberSlots.begin(); itr != m_memberSlots.end(); ++itr)
2575 if (itr->guid == Guid)
2576 return itr;
2577 return m_memberSlots.end();
2578}
MemberSlotList::iterator member_witerator
Definition Group.h:190

References m_memberSlots.

Referenced by ChangeLeader(), ChangeMembersGroup(), RemoveMember(), SendUpdateToPlayer(), SetGroupMemberFlag(), and SetLfgRoles().

◆ _homebindIfInstance()

void Group::_homebindIfInstance ( Player player)
protected
2259{
2260 if (player && !player->IsGameMaster() && player->FindMap() && sMapStore.LookupEntry(player->GetMapId())->IsDungeon())
2261 player->m_InstanceValid = false;
2262}
DBCStorage< MapEntry > sMapStore(MapEntryfmt)
bool IsGameMaster() const
Definition Player.h:1174
uint32 GetMapId() const
Definition Position.h:281

References WorldObject::FindMap(), WorldLocation::GetMapId(), Map::IsDungeon(), Player::IsGameMaster(), Player::m_InstanceValid, and sMapStore.

Referenced by Disband(), and RemoveMember().

◆ _initRaidSubGroupsCounter()

void Group::_initRaidSubGroupsCounter ( )
protected
2553{
2554 // Sub group counters initialization
2555 if (!m_subGroupsCounts)
2557
2558 memset((void*)m_subGroupsCounts, 0, (MAX_RAID_SUBGROUPS)*sizeof(uint8));
2559
2560 for (member_citerator itr = m_memberSlots.begin(); itr != m_memberSlots.end(); ++itr)
2561 ++m_subGroupsCounts[itr->group];
2562}
std::uint8_t uint8
Definition Define.h:109
#define MAX_RAID_SUBGROUPS
Definition Group.h:45

References m_memberSlots, m_subGroupsCounts, and MAX_RAID_SUBGROUPS.

Referenced by ConvertToRaid(), Create(), and LoadGroupFromDB().

◆ AddInvite()

bool Group::AddInvite ( Player player)
355{
356 if (!player || player->GetGroupInvite())
357 return false;
358 Group* group = player->GetGroup();
359 if (group && (group->isBGGroup() || group->isBFGroup()))
360 group = player->GetOriginalGroup();
361 if (group)
362 return false;
363
364 RemoveInvite(player);
365
366 m_invitees.insert(player);
367
368 player->SetGroupInvite(this);
369
370 sScriptMgr->OnGroupInviteMember(this, player->GetGUID());
371
372 return true;
373}
Definition Group.h:176
InvitesList m_invitees
Definition Group.h:348
void RemoveInvite(Player *player)
Definition Group.cpp:385
bool isBGGroup() const
Definition Group.cpp:2351
bool isBFGroup() const
Definition Group.cpp:2356
void SetGroupInvite(Group *group)
Definition Player.h:2508
Group * GetGroup()
Definition Player.h:2509
Group * GetGroupInvite()
Definition Player.h:2507
Group * GetOriginalGroup()
Definition Player.h:2524

References Player::GetGroup(), Player::GetGroupInvite(), Object::GetGUID(), Player::GetOriginalGroup(), isBFGroup(), isBGGroup(), m_invitees, RemoveInvite(), Player::SetGroupInvite(), and sScriptMgr.

Referenced by AddLeaderInvite(), and WorldSession::HandleGroupInviteOpcode().

◆ AddLeaderInvite()

bool Group::AddLeaderInvite ( Player player)
376{
377 if (!AddInvite(player))
378 return false;
379
380 m_leaderGuid = player->GetGUID();
381 m_leaderName = player->GetName();
382 return true;
383}
ObjectGuid m_leaderGuid
Definition Group.h:349
bool AddInvite(Player *player)
Definition Group.cpp:354
std::string const & GetName() const
Definition Object.h:528

References AddInvite(), Object::GetGUID(), WorldObject::GetName(), m_leaderGuid, and m_leaderName.

Referenced by WorldSession::HandleGroupInviteOpcode().

◆ AddLfgBuffFlag()

void Group::AddLfgBuffFlag ( )
inline
@ GROUP_LFG_FLAG_APPLY_RANDOM_BUFF
Definition Group.h:126
uint8 m_lfgGroupFlags
Definition Group.h:366

References GROUP_LFG_FLAG_APPLY_RANDOM_BUFF, and m_lfgGroupFlags.

Referenced by lfg::LFGMgr::MakeNewGroup().

◆ AddLfgHeroicFlag()

void Group::AddLfgHeroicFlag ( )
inline
@ GROUP_LFG_FLAG_IS_HEROIC
Definition Group.h:128

References GROUP_LFG_FLAG_IS_HEROIC, and m_lfgGroupFlags.

Referenced by lfg::LFGMgr::MakeNewGroup().

◆ AddLfgRandomInstanceFlag()

void Group::AddLfgRandomInstanceFlag ( )
inline
@ GROUP_LFG_FLAG_IS_RANDOM_INSTANCE
Definition Group.h:127

References GROUP_LFG_FLAG_IS_RANDOM_INSTANCE, and m_lfgGroupFlags.

Referenced by lfg::LFGMgr::MakeNewGroup().

◆ AddMember()

bool Group::AddMember ( Player player,
uint8  roles = 0 
)
425{
426 if (!player)
427 return false;
428
429 // Get first not-full group
430 uint8 subGroup = 0;
432 {
433 bool groupFound = false;
434 for (; subGroup < MAX_RAID_SUBGROUPS; ++subGroup)
435 {
436 if (m_subGroupsCounts[subGroup] < MAXGROUPSIZE)
437 {
438 groupFound = true;
439 break;
440 }
441 }
442 // We are raid group and no one slot is free
443 if (!groupFound)
444 return false;
445 }
446
447 MemberSlot member;
448 member.guid = player->GetGUID();
449 member.name = player->GetName();
450 member.group = subGroup;
451 member.flags = 0;
452 member.roles = roles;
453 m_memberSlots.push_back(member);
454
455 if (!isBGGroup() && !isBFGroup())
456 {
457 sCharacterCache->UpdateCharacterGroup(player->GetGUID(), GetGUID());
458 }
459
460 SubGroupCounterIncrease(subGroup);
461
462 player->SetGroupInvite(nullptr);
463 if (player->GetGroup())
464 {
465 if (isBGGroup() || isBFGroup()) // if player is in group and he is being added to BG raid group, then call SetBattlegroundRaid()
466 player->SetBattlegroundOrBattlefieldRaid(this, subGroup);
467 else //if player is in bg raid and we are adding him to normal group, then call SetOriginalGroup()
468 player->SetOriginalGroup(this, subGroup);
469 }
470 else //if player is not in group, then call set group
471 player->SetGroup(this, subGroup);
472
473 // if the same group invites the player back, cancel the homebind timer
475
476 if (!isRaidGroup()) // reset targetIcons for non-raid-groups
477 {
478 for (uint8 i = 0; i < TARGETICONCOUNT; ++i)
479 m_targetIcons[i].Clear();
480 }
481
482 if (!isBGGroup() && !isBFGroup())
483 {
485 stmt->SetData(0, GetGUID().GetCounter());
486 stmt->SetData(1, member.guid.GetCounter());
487 stmt->SetData(2, member.flags);
488 stmt->SetData(3, member.group);
489 stmt->SetData(4, member.roles);
490 CharacterDatabase.Execute(stmt);
491 }
492
493 SendUpdate();
494
495 if (player)
496 {
497 sScriptMgr->OnGroupAddMember(this, player->GetGUID());
498
499 if (!IsLeader(player->GetGUID()) && !isBGGroup() && !isBFGroup())
500 {
502
504 {
506 player->SendDungeonDifficulty(true);
507 }
508 if (player->GetRaidDifficulty() != GetRaidDifficulty())
509 {
511 player->SendRaidDifficulty(true);
512 }
513 }
514 else if (IsLeader(player->GetGUID()) && isLFGGroup()) // pussywizard
515 {
517 }
518
521
522 // quest related GO state dependent from raid membership
523 if (isRaidGroup())
525
526 {
527 // Broadcast new player group member fields to rest of the group
529
530 UpdateData groupData;
531 WorldPacket groupDataPacket;
532
533 // Broadcast group members' fields to player
534 for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next())
535 {
536 if (itr->GetSource() == player) // pussywizard: no check same map, adding members is single threaded
537 {
538 continue;
539 }
540
541 if (Player* itrMember = itr->GetSource())
542 {
543 if (player->HaveAtClient(itrMember))
544 {
545 itrMember->SetFieldNotifyFlag(UF_FLAG_PARTY_MEMBER);
546 itrMember->BuildValuesUpdateBlockForPlayer(&groupData, player);
547 itrMember->RemoveFieldNotifyFlag(UF_FLAG_PARTY_MEMBER);
548 }
549
550 if (itrMember->HaveAtClient(player))
551 {
552 UpdateData newData;
553 WorldPacket newDataPacket;
554 player->BuildValuesUpdateBlockForPlayer(&newData, itrMember);
555 if (newData.HasData())
556 {
557 newData.BuildPacket(newDataPacket);
558 itrMember->SendDirectMessage(&newDataPacket);
559 }
560 }
561 }
562 }
563
564 if (groupData.HasData())
565 {
566 groupData.BuildPacket(groupDataPacket);
567 player->SendDirectMessage(&groupDataPacket);
568 }
569
571 }
572
573 if (m_maxEnchantingLevel < player->GetSkillValue(SKILL_ENCHANTING))
575 }
576
577 return true;
578}
#define sCharacterCache
Definition CharacterCache.h:83
@ CHAR_REP_GROUP_MEMBER
Definition CharacterDatabase.h:285
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition DatabaseEnv.cpp:21
#define TARGETICONCOUNT
Definition Group.h:46
#define MAXGROUPSIZE
Definition Group.h:43
@ GROUP_UPDATE_FULL
Definition Group.h:121
@ INSTANCE_RESET_GROUP_JOIN
Definition Map.h:703
@ SKILL_ENCHANTING
Definition SharedDefines.h:3187
@ UF_FLAG_PARTY_MEMBER
Definition UpdateFieldFlags.h:33
Definition GroupReference.h:27
GroupReference * next()
Definition GroupReference.h:36
bool isLFGGroup(bool restricted=false) const
Definition Group.cpp:2340
bool IsLeader(ObjectGuid guid) const
Definition Group.cpp:2416
void SendUpdate()
Definition Group.cpp:1730
ObjectGuid GetGUID() const
Definition Group.cpp:2381
void _cancelHomebindIfInstance(Player *player)
Definition Group.cpp:2264
Difficulty GetRaidDifficulty() const
Definition Group.cpp:2528
ObjectGuid m_targetIcons[TARGETICONCOUNT]
Definition Group.h:356
void UpdatePlayerOutOfRange(Player *player)
Definition Group.cpp:1806
GroupReference * GetFirstMember()
Definition Group.h:250
void SubGroupCounterIncrease(uint8 subgroup)
Definition Group.cpp:2580
Difficulty GetDungeonDifficulty() const
Definition Group.cpp:2523
bool isRaidGroup() const
Definition Group.cpp:2346
void BuildValuesUpdateBlockForPlayer(UpdateData *data, Player *target)
Definition Object.cpp:246
void RemoveFieldNotifyFlag(uint16 flag)
Definition Object.h:196
void SetFieldNotifyFlag(uint16 flag)
Definition Object.h:195
Definition Player.h:1084
Difficulty GetRaidDifficulty() const
Definition Player.h:1942
void SetOriginalGroup(Group *group, int8 subgroup=-1)
Definition Player.cpp:13240
void SetGroupUpdateFlag(uint32 flag)
Definition Player.h:2515
void SendDirectMessage(WorldPacket const *data) const
Definition Player.cpp:5701
uint16 GetSkillValue(uint32 skill) const
Definition Player.cpp:5459
void SetDungeonDifficulty(Difficulty dungeon_difficulty)
Definition Player.h:1944
void SetGroup(Group *group, int8 subgroup=-1)
Definition Player.cpp:11577
bool HaveAtClient(WorldObject const *u) const
Definition Player.cpp:11424
void UpdateForQuestWorldObjects()
Definition PlayerUpdates.cpp:1791
void SetRaidDifficulty(Difficulty raid_difficulty)
Definition Player.h:1945
void SendDungeonDifficulty(bool IsInGroup)
Definition PlayerMisc.cpp:169
static void ResetInstances(ObjectGuid guid, uint8 method, bool isRaid)
Reset all solo instances and optionally send a message on success for each.
Definition PlayerMisc.cpp:193
Difficulty GetDungeonDifficulty() const
Definition Player.h:1941
void SendRaidDifficulty(bool IsInGroup, int32 forcedDifficulty=-1)
Definition PlayerMisc.cpp:177
void SetBattlegroundOrBattlefieldRaid(Group *group, int8 subgroup=-1)
Definition Player.cpp:13212
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition PreparedStatement.h:77
Definition PreparedStatement.h:157
Definition UpdateData.h:52
bool HasData() const
Definition UpdateData.h:60
bool BuildPacket(WorldPacket &packet)
Definition UpdateData.cpp:48
Definition WorldPacket.h:26

References _cancelHomebindIfInstance(), UpdateData::BuildPacket(), Object::BuildValuesUpdateBlockForPlayer(), CHAR_REP_GROUP_MEMBER, CharacterDatabase, Group::MemberSlot::flags, ObjectGuid::GetCounter(), Player::GetDungeonDifficulty(), GetDungeonDifficulty(), GetFirstMember(), Player::GetGroup(), GetGUID(), Object::GetGUID(), WorldObject::GetName(), Player::GetRaidDifficulty(), GetRaidDifficulty(), Player::GetSkillValue(), Group::MemberSlot::group, GROUP_UPDATE_FULL, Group::MemberSlot::guid, UpdateData::HasData(), Player::HaveAtClient(), INSTANCE_RESET_GROUP_JOIN, isBFGroup(), isBGGroup(), IsLeader(), isLFGGroup(), isRaidGroup(), m_maxEnchantingLevel, m_memberSlots, m_subGroupsCounts, m_targetIcons, MAX_RAID_SUBGROUPS, MAXGROUPSIZE, Group::MemberSlot::name, GroupReference::next(), Object::RemoveFieldNotifyFlag(), Player::ResetInstances(), Group::MemberSlot::roles, sCharacterCache, Player::SendDirectMessage(), Player::SendDungeonDifficulty(), Player::SendRaidDifficulty(), SendUpdate(), Player::SetBattlegroundOrBattlefieldRaid(), PreparedStatementBase::SetData(), Player::SetDungeonDifficulty(), Object::SetFieldNotifyFlag(), Player::SetGroup(), Player::SetGroupInvite(), Player::SetGroupUpdateFlag(), Player::SetOriginalGroup(), Player::SetRaidDifficulty(), SKILL_ENCHANTING, sScriptMgr, SubGroupCounterIncrease(), TARGETICONCOUNT, UF_FLAG_PARTY_MEMBER, Player::UpdateForQuestWorldObjects(), and UpdatePlayerOutOfRange().

Referenced by Battlefield::AddOrSetPlayerToCorrectBfGroup(), Battleground::AddOrSetPlayerToCorrectBgGroup(), Arena::AddPlayer(), Create(), group_commandscript::HandleGroupJoinCommand(), and lfg::LFGMgr::MakeNewGroup().

◆ BroadcastGroupUpdate()

void Group::BroadcastGroupUpdate ( void  )
2275{
2276 // FG: HACK: force flags update on group leave - for values update hack
2277 // -- not very efficient but safe
2278 for (member_citerator citr = m_memberSlots.begin(); citr != m_memberSlots.end(); ++citr)
2279 {
2280 Player* pp = ObjectAccessor::FindPlayer(citr->guid);
2281 if (pp)
2282 {
2285 LOG_DEBUG("group", "-- Forced group value update for '{}'", pp->GetName());
2286 }
2287 }
2288}
@ UNIT_FIELD_FACTIONTEMPLATE
Definition UpdateFields.h:115
@ UNIT_FIELD_BYTES_2
Definition UpdateFields.h:161
void ForceValuesUpdateAtIndex(uint32)
Definition Object.cpp:2099
Player * FindPlayer(ObjectGuid const guid)
Definition ObjectAccessor.cpp:245

References ObjectAccessor::FindPlayer(), Object::ForceValuesUpdateAtIndex(), WorldObject::GetName(), LOG_DEBUG, m_memberSlots, UNIT_FIELD_BYTES_2, and UNIT_FIELD_FACTIONTEMPLATE.

Referenced by group_commandscript::HandleGroupJoinCommand(), and RemoveMember().

◆ BroadcastPacket()

void Group::BroadcastPacket ( WorldPacket const *  packet,
bool  ignorePlayersInBGRaid,
int  group = -1,
ObjectGuid  ignore = ObjectGuid::Empty 
)
1823{
1824 for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next())
1825 {
1826 Player* player = itr->GetSource();
1827 if (!player || (ignore && player->GetGUID() == ignore) || (ignorePlayersInBGRaid && player->GetGroup() != this))
1828 continue;
1829
1830 if (group == -1 || itr->getSubGroup() == group)
1831 player->SendDirectMessage(packet);
1832 }
1833}

References GetFirstMember(), Player::GetGroup(), Object::GetGUID(), GroupReference::next(), and Player::SendDirectMessage().

Referenced by ChangeLeader(), DoMinimapPing(), WorldSession::HandleMessagechatOpcode(), WorldSession::HandleRaidReadyCheckFinishedOpcode(), WorldSession::HandleRaidReadyCheckOpcode(), Unit::Kill(), SendLooter(), Player::SendNewItem(), and SetTargetIcon().

◆ BroadcastReadyCheck()

void Group::BroadcastReadyCheck ( WorldPacket const *  packet)
1836{
1837 for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next())
1838 {
1839 Player* player = itr->GetSource();
1840 if (player)
1841 if (IsLeader(player->GetGUID()) || IsAssistant(player->GetGUID()))
1842 player->SendDirectMessage(packet);
1843 }
1844}
bool IsAssistant(ObjectGuid guid) const
Definition Group.cpp:2430

References GetFirstMember(), Object::GetGUID(), IsAssistant(), IsLeader(), GroupReference::next(), and Player::SendDirectMessage().

Referenced by WorldSession::HandleRaidReadyCheckOpcode(), and OfflineReadyCheck().

◆ CanJoinBattlegroundQueue()

GroupJoinBattlegroundResult Group::CanJoinBattlegroundQueue ( Battleground const *  bgTemplate,
BattlegroundQueueTypeId  bgQueueTypeId,
uint32  MinPlayerCount,
uint32  MaxPlayerCount,
bool  isRated,
uint32  arenaSlot 
)
1996{
1997 // check if this group is LFG group
1998 if (isLFGGroup())
2000
2001 BattlemasterListEntry const* bgEntry = sBattlemasterListStore.LookupEntry(bgTemplate->GetBgTypeID());
2002 if (!bgEntry)
2004
2005 // too many players in the group
2006 if (GetMembersCount() > bgEntry->maxGroupSize)
2007 return ERR_BATTLEGROUND_NONE;
2008
2009 // get a player as reference, to compare other players' stats to (arena team id, level bracket, etc.)
2010 Player* reference = GetFirstMember()->GetSource();
2011 if (!reference)
2013
2014 PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bgTemplate->GetMapId(), reference->GetLevel());
2015 if (!bracketEntry)
2017
2018 uint32 arenaTeamId = reference->GetArenaTeamId(arenaSlot);
2019 TeamId teamId = reference->GetTeamId();
2020
2022
2023 // check every member of the group to be able to join
2024 uint32 memberscount = 0;
2025 for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next(), ++memberscount)
2026 {
2027 Player* member = itr->GetSource();
2028
2029 // don't let join with offline members
2030 if (!member)
2032
2033 if (!sScriptMgr->CanGroupJoinBattlegroundQueue(this, member, bgTemplate, MinPlayerCount, isRated, arenaSlot))
2035
2036 // don't allow cross-faction groups to join queue
2037 if (member->GetTeamId() != teamId && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP))
2039
2040 // don't let join rated matches if the arena team id doesn't match
2041 if (isRated && member->GetArenaTeamId(arenaSlot) != arenaTeamId)
2043
2044 // not in the same battleground level braket, don't let join
2045 PvPDifficultyEntry const* memberBracketEntry = GetBattlegroundBracketByLevel(bracketEntry->mapId, member->GetLevel());
2046 if (memberBracketEntry != bracketEntry)
2048
2049 // check for deserter debuff in case not arena queue
2050 if (bgTemplate->GetBgTypeID() != BATTLEGROUND_AA && !member->CanJoinToBattleground(bgTemplate))
2052
2053 // check if someone in party is using dungeon system
2054 lfg::LfgState lfgState = sLFGMgr->GetState(member->GetGUID());
2055 if (lfgState > lfg::LFG_STATE_NONE && (lfgState != lfg::LFG_STATE_QUEUED || !sWorld->getBoolConfig(CONFIG_ALLOW_JOIN_BG_AND_LFG)))
2056 {
2058 }
2059
2060 // pussywizard: prevent joining when any member is in bg/arena
2061 if (member->InBattleground())
2063
2064 // pussywizard: check for free slot, this is actually ensured before calling this function, but just in case
2065 if (!member->HasFreeBattlegroundQueueId())
2067
2068 // don't let join if someone from the group is already in that bg queue
2069 if (member->InBattlegroundQueueForBattlegroundQueueType(bgQueueTypeId))
2070 {
2072 }
2073
2074 // don't let join if someone from the group is in bg queue random
2075 if (member->InBattlegroundQueueForBattlegroundQueueType(bgQueueTypeIdRandom))
2076 return ERR_IN_RANDOM_BG;
2077
2078 // don't let join to bg queue random if someone from the group is already in bg queue
2079 if (bgTemplate->GetBgTypeID() == BATTLEGROUND_RB && member->InBattlegroundQueue())
2080 return ERR_IN_NON_RANDOM_BG;
2081
2082 // don't let Death Knights join BG queues when they are not allowed to be teleported yet
2083 if (member->IsClass(CLASS_DEATH_KNIGHT, CLASS_CONTEXT_TELEPORT) && member->GetMapId() == MAP_EBON_HOLD && !member->IsGameMaster() && !member->HasSpell(50977))
2085
2086 if (!member->GetBGAccessByLevel(bgTemplate->GetBgTypeID()))
2087 {
2089 }
2090 }
2091
2092 // for arenas: check party size is proper
2093 if (bgTemplate->isArena() && memberscount != MinPlayerCount)
2095
2096 //check against other arena team members
2097 if (isRated)
2098 {
2099 ArenaTeam* arenaTeam = sArenaTeamMgr->GetArenaTeamById(arenaTeamId);
2100 for (auto const& itr : arenaTeam->GetMembers())
2101 {
2102 Player* teamMember = ObjectAccessor::FindConnectedPlayer(itr.Guid);
2103 //are they online and not a member of this current group?
2104 if (teamMember && !IsMember(teamMember->GetGUID()))
2105 {
2106 //are they already in queue for a rated arena?
2107 if (teamMember->InBattlegroundQueueForBattlegroundQueueType(bgQueueTypeId))
2108 {
2109 GroupQueueInfo ginfo;
2110 BattlegroundQueue& queue = sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId);
2111 if (queue.GetPlayerGroupInfoData(teamMember->GetGUID(), &ginfo))
2112 {
2113 if (ginfo.IsRated)
2115 }
2116 }
2117 //are they currently in an arena match?
2118 Battleground* bg = teamMember->GetBattleground(false);
2119 if (bg && bg->isRated() && bg->GetMinPlayersPerTeam() == MinPlayerCount)
2121 }
2122 }
2123 }
2124
2125 return GroupJoinBattlegroundResult(bgTemplate->GetBgTypeID());
2126}
@ MAP_EBON_HOLD
Definition AreaDefines.h:259
#define sArenaTeamMgr
Definition ArenaTeamMgr.h:69
#define sBattlegroundMgr
Definition BattlegroundMgr.h:187
DBCStorage< BattlemasterListEntry > sBattlemasterListStore(BattlemasterListEntryfmt)
PvPDifficultyEntry const * GetBattlegroundBracketByLevel(uint32 mapid, uint32 level)
Definition DBCStores.cpp:793
std::uint32_t uint32
Definition Define.h:107
#define sLFGMgr
Definition LFGMgr.h:658
GroupJoinBattlegroundResult
Definition SharedDefines.h:3891
@ ERR_BATTLEGROUND_JOIN_TIMED_OUT
Definition SharedDefines.h:3904
@ ERR_BATTLEGROUND_JOIN_FAILED
Definition SharedDefines.h:3905
@ ERR_LFG_CANT_USE_BATTLEGROUND
Definition SharedDefines.h:3906
@ ERR_IN_NON_RANDOM_BG
Definition SharedDefines.h:3908
@ ERR_BATTLEGROUND_NONE
Definition SharedDefines.h:3894
@ ERR_GROUP_JOIN_BATTLEGROUND_DESERTERS
Definition SharedDefines.h:3895
@ ERR_ARENA_TEAM_PARTY_SIZE
Definition SharedDefines.h:3896
@ ERR_BATTLEGROUND_TOO_MANY_QUEUES
Definition SharedDefines.h:3897
@ ERR_GROUP_JOIN_BATTLEGROUND_FAIL
Definition SharedDefines.h:3893
@ ERR_BATTLEGROUND_JOIN_RANGE_INDEX
Definition SharedDefines.h:3903
@ ERR_IN_RANDOM_BG
Definition SharedDefines.h:3907
@ CLASS_DEATH_KNIGHT
Definition SharedDefines.h:131
@ BATTLEGROUND_AA
Definition SharedDefines.h:3742
@ BATTLEGROUND_RB
Definition SharedDefines.h:3749
BattlegroundQueueTypeId
Definition SharedDefines.h:3875
TeamId
Definition SharedDefines.h:747
@ CLASS_CONTEXT_TELEPORT
Definition UnitDefines.h:235
@ CONFIG_ALLOW_JOIN_BG_AND_LFG
Definition WorldConfig.h:130
@ CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP
Definition WorldConfig.h:34
Definition ArenaTeam.h:137
static BattlegroundQueueTypeId BGQueueTypeId(BattlegroundTypeId bgTypeId, uint8 arenaType)
Definition BattlegroundMgr.cpp:686
Definition BattlegroundQueue.h:68
bool GetPlayerGroupInfoData(ObjectGuid guid, GroupQueueInfo *ginfo)
Definition BattlegroundQueue.cpp:400
Definition Battleground.h:304
uint32 GetMinPlayersPerTeam() const
Definition Battleground.h:351
bool isRated() const
Definition Battleground.h:416
uint32 GetMembersCount() const
Definition Group.h:252
bool IsMember(ObjectGuid guid) const
Definition Group.cpp:2411
bool InBattlegroundQueueForBattlegroundQueueType(BattlegroundQueueTypeId bgQueueTypeId) const
Definition Player.cpp:12307
bool InBattleground() const
Definition Player.h:2291
TeamId GetTeamId(bool original=false) const
Definition Player.h:2131
Battleground * GetBattleground(bool create=false) const
Definition Player.cpp:12258
bool InBattlegroundQueue(bool ignoreArena=false) const
Definition Player.cpp:12273
uint32 GetArenaTeamId(uint8 slot) const
Definition Player.cpp:16352
bool HasFreeBattlegroundQueueId() const
Definition Player.cpp:12327
bool IsClass(Classes playerClass, ClassContext context=CLASS_CONTEXT_NONE) const override
Definition Player.cpp:1302
bool CanJoinToBattleground(Battleground const *bg) const
Definition Player.cpp:11367
bool HasSpell(uint32 spell) const override
Definition Player.cpp:3888
bool GetBGAccessByLevel(BattlegroundTypeId bgTypeId) const
Definition Player.cpp:12386
FROM * GetSource() const
Definition Reference.h:97
uint8 GetLevel() const
Definition Unit.h:1103
#define sWorld
Definition World.h:317
Player * FindConnectedPlayer(ObjectGuid const guid)
Definition ObjectAccessor.cpp:257
LfgState
Definition LFG.h:67
@ LFG_STATE_NONE
Definition LFG.h:68
@ LFG_STATE_QUEUED
Definition LFG.h:70
Definition DBCStructure.h:604
uint32 maxGroupSize
Definition DBCStructure.h:611
Definition BattlegroundQueue.h:35
bool IsRated
Definition BattlegroundQueue.h:40
Definition DBCStructure.h:1431
uint32 mapId
Definition DBCStructure.h:1433

References BATTLEGROUND_AA, BATTLEGROUND_RB, BattlegroundMgr::BGQueueTypeId(), Player::CanJoinToBattleground(), CLASS_CONTEXT_TELEPORT, CLASS_DEATH_KNIGHT, CONFIG_ALLOW_JOIN_BG_AND_LFG, CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP, ERR_ARENA_TEAM_PARTY_SIZE, ERR_BATTLEGROUND_JOIN_FAILED, ERR_BATTLEGROUND_JOIN_RANGE_INDEX, ERR_BATTLEGROUND_JOIN_TIMED_OUT, ERR_BATTLEGROUND_NONE, ERR_BATTLEGROUND_TOO_MANY_QUEUES, ERR_GROUP_JOIN_BATTLEGROUND_DESERTERS, ERR_GROUP_JOIN_BATTLEGROUND_FAIL, ERR_IN_NON_RANDOM_BG, ERR_IN_RANDOM_BG, ERR_LFG_CANT_USE_BATTLEGROUND, ObjectAccessor::FindConnectedPlayer(), Player::GetArenaTeamId(), Player::GetBattleground(), GetBattlegroundBracketByLevel(), Player::GetBGAccessByLevel(), Battleground::GetBgTypeID(), GetFirstMember(), Object::GetGUID(), Unit::GetLevel(), Battleground::GetMapId(), WorldLocation::GetMapId(), ArenaTeam::GetMembers(), GetMembersCount(), Battleground::GetMinPlayersPerTeam(), BattlegroundQueue::GetPlayerGroupInfoData(), Reference< TO, FROM >::GetSource(), Player::GetTeamId(), Player::HasFreeBattlegroundQueueId(), Player::HasSpell(), Player::InBattleground(), Player::InBattlegroundQueue(), Player::InBattlegroundQueueForBattlegroundQueueType(), Battleground::isArena(), Player::IsClass(), Player::IsGameMaster(), isLFGGroup(), IsMember(), Battleground::isRated(), GroupQueueInfo::IsRated, lfg::LFG_STATE_NONE, lfg::LFG_STATE_QUEUED, MAP_EBON_HOLD, PvPDifficultyEntry::mapId, BattlemasterListEntry::maxGroupSize, GroupReference::next(), sArenaTeamMgr, sBattlegroundMgr, sBattlemasterListStore, sLFGMgr, sScriptMgr, and sWorld.

Referenced by WorldSession::HandleBattlemasterJoinArena(), and WorldSession::HandleBattlemasterJoinOpcode().

◆ ChangeLeader()

void Group::ChangeLeader ( ObjectGuid  guid)
719{
720 member_witerator slot = _getMemberWSlot(newLeaderGuid);
721
722 if (slot == m_memberSlots.end())
723 return;
724
725 Player* newLeader = ObjectAccessor::FindConnectedPlayer(slot->guid);
726
727 // Don't allow switching leader to offline players
728 if (!newLeader)
729 return;
730
731 if (!isBGGroup() && !isBFGroup())
732 {
733 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
734 // Update the group leader
736 stmt->SetData(0, newLeader->GetGUID().GetCounter());
737 stmt->SetData(1, GetGUID().GetCounter());
738 trans->Append(stmt);
739 CharacterDatabase.CommitTransaction(trans);
740
741 sInstanceSaveMgr->CopyBinds(m_leaderGuid, newLeaderGuid, newLeader);
742 }
743
745 oldLeader->RemovePlayerFlag(PLAYER_FLAGS_GROUP_LEADER);
746
748 m_leaderGuid = newLeader->GetGUID();
749 m_leaderName = newLeader->GetName();
751
753 data << slot->name;
754 BroadcastPacket(&data, true);
755
756 sScriptMgr->OnGroupChangeLeader(this, newLeaderGuid, m_leaderGuid); // This hook should be executed at the end - Not used anywhere in the original core
757}
@ CHAR_UPD_GROUP_LEADER
Definition CharacterDatabase.h:287
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
Definition DatabaseEnvFwd.h:69
@ MEMBER_FLAG_ASSISTANT
Definition Group.h:73
@ PLAYER_FLAGS_GROUP_LEADER
Definition Player.h:459
void BroadcastPacket(WorldPacket const *packet, bool ignorePlayersInBGRaid, int group=-1, ObjectGuid ignore=ObjectGuid::Empty)
Definition Group.cpp:1822
void ToggleGroupMemberFlag(member_witerator slot, uint8 flag, bool apply)
Definition Group.cpp:2599
member_witerator _getMemberWSlot(ObjectGuid Guid)
Definition Group.cpp:2572
LowType GetCounter() const
Definition ObjectGuid.h:145
void SetPlayerFlag(PlayerFlags flags)
Definition Player.h:1124
@ SMSG_GROUP_SET_LEADER
Definition Opcodes.h:151

References _getMemberWSlot(), BroadcastPacket(), CHAR_UPD_GROUP_LEADER, CharacterDatabase, ObjectAccessor::FindConnectedPlayer(), ObjectGuid::GetCounter(), GetGUID(), Object::GetGUID(), WorldObject::GetName(), isBFGroup(), isBGGroup(), m_leaderGuid, m_leaderName, m_memberSlots, MEMBER_FLAG_ASSISTANT, PLAYER_FLAGS_GROUP_LEADER, PreparedStatementBase::SetData(), Player::SetPlayerFlag(), sInstanceSaveMgr, SMSG_GROUP_SET_LEADER, sScriptMgr, and ToggleGroupMemberFlag().

Referenced by Battleground::AddOrSetPlayerToCorrectBgGroup(), group_commandscript::HandleGroupLeaderCommand(), WorldSession::HandleGroupSetLeaderOpcode(), and RemoveMember().

◆ ChangeMembersGroup()

void Group::ChangeMembersGroup ( ObjectGuid  guid,
uint8  group 
)
1874{
1875 // Only raid groups have sub groups
1876 if (!isRaidGroup())
1877 return;
1878
1879 // Check if player is really in the raid
1880 member_witerator slot = _getMemberWSlot(guid);
1881 if (slot == m_memberSlots.end())
1882 return;
1883
1884 // Abort if the player is already in the target sub group
1885 uint8 prevSubGroup = GetMemberGroup(guid);
1886 if (prevSubGroup == group)
1887 return;
1888
1889 // Update the player slot with the new sub group setting
1890 slot->group = group;
1891
1892 // Increase the counter of the new sub group..
1894
1895 // ..and decrease the counter of the previous one
1896 SubGroupCounterDecrease(prevSubGroup);
1897
1898 // Preserve new sub group in database for non-raid groups
1899 if (!isBGGroup() && !isBFGroup())
1900 {
1902
1903 stmt->SetData(0, group);
1904 stmt->SetData(1, guid.GetCounter());
1905
1906 CharacterDatabase.Execute(stmt);
1907 }
1908
1909 // In case the moved player is online, update the player object with the new sub group references
1910 if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
1911 {
1912 if (player->GetGroup() == this)
1913 player->GetGroupRef().setSubGroup(group);
1914 else // If player is in BG raid, it is possible that he is also in normal raid - and that normal raid is stored in m_originalGroup reference
1915 player->GetOriginalGroupRef().setSubGroup(group);
1916 }
1917
1918 // Broadcast the changes to the group
1919 SendUpdate();
1920}
@ CHAR_UPD_GROUP_MEMBER_SUBGROUP
Definition CharacterDatabase.h:289
uint8 GetMemberGroup(ObjectGuid guid) const
Definition Group.cpp:2459
void SubGroupCounterDecrease(uint8 subgroup)
Definition Group.cpp:2586

References _getMemberWSlot(), CHAR_UPD_GROUP_MEMBER_SUBGROUP, CharacterDatabase, ObjectAccessor::FindConnectedPlayer(), ObjectGuid::GetCounter(), GetMemberGroup(), isBFGroup(), isBGGroup(), isRaidGroup(), m_memberSlots, SendUpdate(), PreparedStatementBase::SetData(), SubGroupCounterDecrease(), and SubGroupCounterIncrease().

Referenced by WorldSession::HandleGroupChangeSubGroupOpcode(), and WorldSession::HandleGroupSwapSubGroupOpcode().

◆ CheckLevelForRaid()

bool Group::CheckLevelForRaid ( )
317{
318 for (member_citerator citr = m_memberSlots.begin(); citr != m_memberSlots.end(); ++citr)
319 if (Player* player = ObjectAccessor::FindPlayer(citr->guid))
320 if (player->GetLevel() < sConfigMgr->GetOption<int32>("Group.Raid.LevelRestriction", 10))
321 return true;
322
323 return false;
324}
std::int32_t int32
Definition Define.h:103
#define sConfigMgr
Definition Config.h:93

References ObjectAccessor::FindPlayer(), m_memberSlots, and sConfigMgr.

Referenced by WorldSession::HandleGroupRaidConvertOpcode().

◆ ConvertToLFG()

void Group::ConvertToLFG ( bool  restricted = true)
295{
297 if (restricted)
298 {
301 }
302
303 if (!isBGGroup() && !isBFGroup())
304 {
306
307 stmt->SetData(0, uint8(m_groupType));
308 stmt->SetData(1, GetGUID().GetCounter());
309
310 CharacterDatabase.Execute(stmt);
311 }
312
313 SendUpdate();
314}
@ CHAR_UPD_GROUP_TYPE
Definition CharacterDatabase.h:288
GroupType
Definition Group.h:85
@ GROUPTYPE_LFG_RESTRICTED
Definition Group.h:90
@ GROUPTYPE_LFG
Definition Group.h:91
@ NEED_BEFORE_GREED
Definition LootMgr.h:62

References CHAR_UPD_GROUP_TYPE, CharacterDatabase, GetGUID(), GROUPTYPE_LFG, GROUPTYPE_LFG_RESTRICTED, isBFGroup(), isBGGroup(), m_groupType, m_lootMethod, NEED_BEFORE_GREED, SendUpdate(), and PreparedStatementBase::SetData().

Referenced by lfg::LFGMgr::MakeNewGroup().

◆ ConvertToRaid()

void Group::ConvertToRaid ( )
327{
329
331
332 if (!isBGGroup() && !isBFGroup())
333 {
335
336 stmt->SetData(0, uint8(m_groupType));
337 stmt->SetData(1, GetGUID().GetCounter());
338
339 CharacterDatabase.Execute(stmt);
340 }
341
342 SendUpdate();
343
344 // update quest related GO states (quest activity dependent from raid membership)
345 for (member_citerator citr = m_memberSlots.begin(); citr != m_memberSlots.end(); ++citr)
346 if (Player* player = ObjectAccessor::FindPlayer(citr->guid))
347 player->UpdateForQuestWorldObjects();
348
349 // pussywizard: client automatically clears df "eye" near minimap, so remove from raid browser
351 sLFGMgr->LeaveLfg(GetLeaderGUID());
352}
@ GROUPTYPE_RAID
Definition Group.h:88
void _initRaidSubGroupsCounter()
Definition Group.cpp:2552
ObjectGuid GetLeaderGUID() const
Definition Group.cpp:2371
@ LFG_STATE_RAIDBROWSER
Definition LFG.h:75

References _initRaidSubGroupsCounter(), CHAR_UPD_GROUP_TYPE, CharacterDatabase, ObjectAccessor::FindPlayer(), GetGUID(), GetLeaderGUID(), GROUPTYPE_RAID, isBFGroup(), isBGGroup(), lfg::LFG_STATE_RAIDBROWSER, m_groupType, m_memberSlots, SendUpdate(), PreparedStatementBase::SetData(), and sLFGMgr.

Referenced by WorldSession::HandleGroupRaidConvertOpcode().

◆ CountRollVote()

bool Group::CountRollVote ( ObjectGuid  playerGUID,
ObjectGuid  Guid,
uint8  Choise 
)
1367{
1368 Rolls::iterator rollI = GetRoll(Guid);
1369 if (rollI == RollId.end())
1370 return false;
1371 Roll* roll = *rollI;
1372
1373 Roll::PlayerVote::iterator itr = roll->playerVote.find(playerGUID);
1374 // this condition means that player joins to the party after roll begins
1375 // Xinef: if choice == MAX_ROLL_TYPE, player was removed from the map in removefromgroup
1376 // Xinef: itr can be invalid as it is not used below
1377 if (Choice < MAX_ROLL_TYPE && itr == roll->playerVote.end())
1378 return false;
1379
1380 if (roll->getLoot())
1381 if (roll->getLoot()->items.empty())
1382 return false;
1383
1384 switch (Choice)
1385 {
1386 case ROLL_PASS: // Player choose pass
1387 SendLootRoll(ObjectGuid::Empty, playerGUID, 128, ROLL_PASS, *roll);
1388 ++roll->totalPass;
1389 itr->second = PASS;
1390 break;
1391 case ROLL_NEED: // player choose Need
1392 SendLootRoll(ObjectGuid::Empty, playerGUID, 0, 0, *roll);
1393 ++roll->totalNeed;
1394 itr->second = NEED;
1395 break;
1396 case ROLL_GREED: // player choose Greed
1397 SendLootRoll(ObjectGuid::Empty, playerGUID, 128, ROLL_GREED, *roll);
1398 ++roll->totalGreed;
1399 itr->second = GREED;
1400 break;
1401 case ROLL_DISENCHANT: // player choose Disenchant
1402 SendLootRoll(ObjectGuid::Empty, playerGUID, 128, ROLL_DISENCHANT, *roll);
1403 ++roll->totalGreed;
1404 itr->second = DISENCHANT;
1405 break;
1406 }
1407
1408 if (roll->totalPass + roll->totalNeed + roll->totalGreed >= roll->totalPlayersRolling)
1409 {
1410 CountTheRoll(rollI);
1411 return true;
1412 }
1413 return false;
1414}
@ PASS
Definition Group.h:50
@ NEED
Definition Group.h:51
@ DISENCHANT
Definition Group.h:53
@ GREED
Definition Group.h:52
@ ROLL_PASS
Definition LootMgr.h:33
@ ROLL_GREED
Definition LootMgr.h:35
@ ROLL_NEED
Definition LootMgr.h:34
@ ROLL_DISENCHANT
Definition LootMgr.h:36
void SendLootRoll(ObjectGuid SourceGuid, ObjectGuid TargetGuid, uint8 RollNumber, uint8 RollType, const Roll &r, bool autoPass=false)
Definition Group.cpp:905
Rolls::iterator GetRoll(ObjectGuid Guid)
Definition Group.cpp:2538
void CountTheRoll(Rolls::iterator roll)
Definition Group.cpp:1462
static ObjectGuid const Empty
Definition ObjectGuid.h:120
uint8 totalGreed
Definition Group.h:167
uint8 totalPlayersRolling
Definition Group.h:165
uint8 totalNeed
Definition Group.h:166
uint8 totalPass
Definition Group.h:168
Loot * getLoot()
Definition Group.cpp:61
PlayerVote playerVote
Definition Group.h:164
std::vector< LootItem > items
Definition LootMgr.h:320

References CountTheRoll(), DISENCHANT, ObjectGuid::Empty, Roll::getLoot(), GetRoll(), GREED, Loot::items, NEED, PASS, Roll::playerVote, ROLL_DISENCHANT, ROLL_GREED, ROLL_NEED, ROLL_PASS, RollId, SendLootRoll(), Roll::totalGreed, Roll::totalNeed, Roll::totalPass, and Roll::totalPlayersRolling.

Referenced by WorldSession::HandleLootRoll(), and RemovePlayerFromRolls().

◆ CountTheRoll()

void Group::CountTheRoll ( Rolls::iterator  roll)
1463{
1464 Roll* roll = *rollI;
1465 if (!roll->isValid()) // is loot already deleted ?
1466 {
1467 RollId.erase(rollI);
1468 delete roll;
1469 return;
1470 }
1471
1472 //end of the roll
1473 if (roll->totalNeed > 0)
1474 {
1475 if (!roll->playerVote.empty())
1476 {
1477 uint8 maxresul = 0;
1478 ObjectGuid maxguid; // pussywizard: start with 0 >_>
1479 Player* player = nullptr;
1480
1481 for (Roll::PlayerVote::const_iterator itr = roll->playerVote.begin(); itr != roll->playerVote.end(); ++itr)
1482 {
1483 if (itr->second != NEED)
1484 continue;
1485
1486 player = ObjectAccessor::FindPlayer(itr->first);
1487 if (!player)
1488 {
1489 --roll->totalNeed;
1490 continue;
1491 }
1492
1493 uint8 randomN = urand(1, 100);
1494 SendLootRoll(ObjectGuid::Empty, itr->first, randomN, ROLL_NEED, *roll);
1495 if (maxresul < randomN)
1496 {
1497 maxguid = itr->first;
1498 maxresul = randomN;
1499 }
1500 }
1501
1502 if (maxguid) // pussywizard: added condition
1503 {
1504 SendLootRollWon(ObjectGuid::Empty, maxguid, maxresul, ROLL_NEED, *roll);
1505 player = ObjectAccessor::FindPlayer(maxguid);
1506
1507 if (player)
1508 {
1510
1511 ItemPosCountVec dest;
1512 LootItem* item = &(roll->itemSlot >= roll->getLoot()->items.size() ? roll->getLoot()->quest_items[roll->itemSlot - roll->getLoot()->items.size()] : roll->getLoot()->items[roll->itemSlot]);
1513 InventoryResult msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, roll->itemid, item->count);
1514 if (msg == EQUIP_ERR_OK)
1515 {
1516 item->is_looted = true;
1517 roll->getLoot()->NotifyItemRemoved(roll->itemSlot);
1518 roll->getLoot()->unlootedCount--;
1519 AllowedLooterSet looters = item->GetAllowedLooters();
1520 Item* _item = player->StoreNewItem(dest, roll->itemid, true, item->randomPropertyId, looters);
1521 if (_item)
1522 sScriptMgr->OnPlayerGroupRollRewardItem(player, _item, item->count, NEED, roll);
1523 player->UpdateLootAchievements(item, roll->getLoot());
1524 }
1525 else
1526 {
1527 uint32 mailOnFull = sWorld->getIntConfig(CONFIG_LFG_MAIL_ITEM_ON_FULL_INVENTORY);
1528 // Only mail when bags are genuinely full. Unique/max-count failures must
1529 // leave the item on the corpse so it can be re-rolled or freely looted.
1531 {
1532 item->is_looted = true;
1533 roll->getLoot()->NotifyItemRemoved(roll->itemSlot);
1534 roll->getLoot()->unlootedCount--;
1535 player->SendEquipError(msg, nullptr, nullptr, roll->itemid);
1536 SendRollWonItemViaMail(player, item, roll->itemid);
1537 }
1538 else
1539 {
1540 item->is_blocked = false;
1541 item->rollWinnerGUID = player->GetGUID();
1542 player->SendEquipError(msg, nullptr, nullptr, roll->itemid);
1543 }
1544 }
1545 }
1546 }
1547 else
1548 roll->totalNeed = 0;
1549 }
1550 }
1551 if (roll->totalNeed == 0 && roll->totalGreed > 0) // if (roll->totalNeed == 0 && ...), not else if, because totalNeed can be decremented above when a needing player is offline
1552 {
1553 if (!roll->playerVote.empty())
1554 {
1555 uint8 maxresul = 0;
1556 ObjectGuid maxguid; // pussywizard: start with 0
1557 Player* player = nullptr;
1558 RollVote rollvote = NOT_VALID;
1559
1560 Roll::PlayerVote::iterator itr;
1561 for (itr = roll->playerVote.begin(); itr != roll->playerVote.end(); ++itr)
1562 {
1563 if (itr->second != GREED && itr->second != DISENCHANT)
1564 continue;
1565
1566 player = ObjectAccessor::FindPlayer(itr->first);
1567 if (!player)
1568 {
1569 --roll->totalGreed;
1570 continue;
1571 }
1572
1573 uint8 randomN = urand(1, 100);
1574 SendLootRoll(ObjectGuid::Empty, itr->first, randomN, itr->second, *roll);
1575 if (maxresul < randomN)
1576 {
1577 maxguid = itr->first;
1578 maxresul = randomN;
1579 rollvote = itr->second;
1580 }
1581 }
1582
1583 if (maxguid) // pussywizard: added condition
1584 {
1585 SendLootRollWon(ObjectGuid::Empty, maxguid, maxresul, rollvote, *roll);
1586 player = ObjectAccessor::FindPlayer(maxguid);
1587
1588 if (player)
1589 {
1591
1592 LootItem* item = &(roll->itemSlot >= roll->getLoot()->items.size() ? roll->getLoot()->quest_items[roll->itemSlot - roll->getLoot()->items.size()] : roll->getLoot()->items[roll->itemSlot]);
1593
1594 if (rollvote == GREED)
1595 {
1596 ItemPosCountVec dest;
1597 InventoryResult msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, roll->itemid, item->count);
1598 if (msg == EQUIP_ERR_OK)
1599 {
1600 item->is_looted = true;
1601 roll->getLoot()->NotifyItemRemoved(roll->itemSlot);
1602 roll->getLoot()->unlootedCount--;
1603 AllowedLooterSet looters = item->GetAllowedLooters();
1604 Item* _item = player->StoreNewItem(dest, roll->itemid, true, item->randomPropertyId, looters);
1605 if (_item)
1606 sScriptMgr->OnPlayerGroupRollRewardItem(player, _item, item->count, GREED, roll);
1607 player->UpdateLootAchievements(item, roll->getLoot());
1608 }
1609 else
1610 {
1611 uint32 mailOnFull = sWorld->getIntConfig(CONFIG_LFG_MAIL_ITEM_ON_FULL_INVENTORY);
1612 // Only mail when bags are genuinely full. Unique/max-count failures must
1613 // leave the item on the corpse so it can be re-rolled or freely looted.
1615 {
1616 item->is_looted = true;
1617 roll->getLoot()->NotifyItemRemoved(roll->itemSlot);
1618 roll->getLoot()->unlootedCount--;
1619 player->SendEquipError(msg, nullptr, nullptr, roll->itemid);
1620 SendRollWonItemViaMail(player, item, roll->itemid);
1621 }
1622 else
1623 {
1624 item->is_blocked = false;
1625 item->rollWinnerGUID = player->GetGUID();
1626 player->SendEquipError(msg, nullptr, nullptr, roll->itemid);
1627 }
1628 }
1629 }
1630 else if (rollvote == DISENCHANT)
1631 {
1632 item->is_looted = true;
1633 roll->getLoot()->NotifyItemRemoved(roll->itemSlot);
1634 roll->getLoot()->unlootedCount--;
1635 ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(roll->itemid);
1637
1638 ItemPosCountVec dest;
1639 InventoryResult msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, roll->itemid, item->count);
1640
1641 if (msg == EQUIP_ERR_OK)
1642 {
1643 player->AutoStoreLoot(pProto->DisenchantID, LootTemplates_Disenchant, true);
1644 }
1645 else
1646 {
1647 Loot loot;
1648 loot.FillLoot(pProto->DisenchantID, LootTemplates_Disenchant, player, true);
1649
1650 uint32 max_slot = loot.GetMaxSlotInLootFor(player);
1651 for(uint32 i = 0; i < max_slot; i++)
1652 {
1653 LootItem* lootItem = loot.LootItemInSlot(i, player);
1654 player->SendEquipError(msg, nullptr, nullptr, lootItem->itemid);
1655 player->SendItemRetrievalMail(lootItem->itemid, lootItem->count);
1656 }
1657 }
1658 }
1659 }
1660 }
1661 else
1662 roll->totalGreed = 0;
1663 }
1664 }
1665 if (roll->totalNeed == 0 && roll->totalGreed == 0) // if, not else, because the totals can be decremented above when a rolling player is offline
1666 {
1667 SendLootAllPassed(*roll);
1668
1669 // remove is_blocked so that the item is lootable by all players
1670 LootItem* item = &(roll->itemSlot >= roll->getLoot()->items.size() ? roll->getLoot()->quest_items[roll->itemSlot - roll->getLoot()->items.size()] : roll->getLoot()->items[roll->itemSlot]);
1671 if (item)
1672 item->is_blocked = false;
1673 }
1674
1675 if (Loot* loot = roll->getLoot(); loot && loot->isLooted() && loot->sourceGameObject)
1676 {
1677 const GameObjectTemplate* goInfo = loot->sourceGameObject->GetGOInfo();
1678 if (goInfo && goInfo->type == GAMEOBJECT_TYPE_CHEST)
1679 {
1680 // Deactivate chest if the last item was rolled in group
1682 }
1683 }
1684
1685 RollId.erase(rollI);
1686 delete roll;
1687}
@ ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL
Definition DBCEnums.h:143
@ ACHIEVEMENT_CRITERIA_TYPE_ROLL_GREED_ON_LOOT
Definition DBCEnums.h:165
@ ACHIEVEMENT_CRITERIA_TYPE_ROLL_NEED_ON_LOOT
Definition DBCEnums.h:164
@ GO_JUST_DEACTIVATED
Definition GameObject.h:113
static void SendRollWonItemViaMail(Player *player, LootItem const *lootItem, uint32 itemId)
Definition Group.cpp:66
@ MAIL_ITEM_ON_FULL_INVENTORY_LFG_ONLY
Definition Group.h:134
@ MAIL_ITEM_ON_FULL_INVENTORY_EVERYWHERE
Definition Group.h:135
RollVote
Definition Group.h:49
@ NOT_VALID
Definition Group.h:55
InventoryResult
Definition Item.h:46
@ EQUIP_ERR_OK
Definition Item.h:47
@ EQUIP_ERR_INVENTORY_FULL
Definition Item.h:97
@ NULL_BAG
Definition Item.h:40
@ NULL_SLOT
Definition Item.h:41
LootStore LootTemplates_Disenchant("disenchant_loot_template", "item disenchant id", true)
GuidSet AllowedLooterSet
Definition LootMgr.h:151
#define sObjectMgr
Definition ObjectMgr.h:1732
std::vector< ItemPosCount > ItemPosCountVec
Definition Player.h:757
uint32 urand(uint32 min, uint32 max)
Definition Random.cpp:44
@ GAMEOBJECT_TYPE_CHEST
Definition SharedDefines.h:1567
@ CONFIG_LFG_MAIL_ITEM_ON_FULL_INVENTORY
Definition WorldConfig.h:384
GameObjectTemplate const * GetGOInfo() const
Definition GameObject.h:136
void SetLootState(LootState s, Unit *unit=nullptr)
Definition GameObject.cpp:2462
void SendLootAllPassed(Roll const &roll)
Definition Group.cpp:952
void SendLootRollWon(ObjectGuid SourceGuid, ObjectGuid TargetGuid, uint8 RollNumber, uint8 RollType, const Roll &r)
Definition Group.cpp:929
Definition Item.h:220
Definition ObjectGuid.h:118
void UpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscValue1=0, uint32 miscValue2=0, Unit *unit=nullptr)
Definition PlayerUpdates.cpp:2174
void AutoStoreLoot(uint8 bag, uint8 slot, uint32 loot_id, LootStore const &store, bool broadcast=false)
Definition Player.cpp:13625
void SendItemRetrievalMail(uint32 itemEntry, uint32 count)
Definition PlayerMisc.cpp:432
void UpdateLootAchievements(LootItem *item, Loot *loot)
Definition PlayerUpdates.cpp:2164
Item * StoreNewItem(ItemPosCountVec const &pos, uint32 item, bool update, int32 randomPropertyId=0, bool refund=false)
Definition PlayerStorage.cpp:2601
void SendEquipError(InventoryResult msg, Item *pItem, Item *pItem2=nullptr, uint32 itemid=0)
Definition PlayerStorage.cpp:4093
InventoryResult CanStoreNewItem(uint8 bag, uint8 slot, ItemPosCountVec &dest, uint32 item, uint32 count, uint32 *no_space_count=nullptr) const
Definition Player.h:1300
bool isValid() const
Definition Reference.h:79
uint8 itemSlot
Definition Group.h:169
uint32 itemid
Definition Group.h:159
Definition GameObjectData.h:32
uint32 type
Definition GameObjectData.h:34
Definition ItemTemplate.h:619
uint32 DisenchantID
Definition ItemTemplate.h:690
Definition LootMgr.h:154
uint32 itemid
Definition LootMgr.h:155
bool is_blocked
Definition LootMgr.h:164
ObjectGuid rollWinnerGUID
Definition LootMgr.h:161
int32 randomPropertyId
Definition LootMgr.h:158
uint8 count
Definition LootMgr.h:162
bool is_looted
Definition LootMgr.h:163
const AllowedLooterSet & GetAllowedLooters() const
Definition LootMgr.h:181
Definition LootMgr.h:313
uint32 GetMaxSlotInLootFor(Player *player) const
Definition LootMgr.cpp:886
LootItem * LootItemInSlot(uint32 lootslot, Player *player, QuestItem **qitem=nullptr, QuestItem **ffaitem=nullptr, QuestItem **conditem=nullptr)
Definition LootMgr.cpp:821
bool isLooted() const
Definition LootMgr.h:368
uint8 unlootedCount
Definition LootMgr.h:323
bool FillLoot(uint32 lootId, LootStore const &store, Player *lootOwner, bool personal, bool noEmptyError=false, uint16 lootMode=LOOT_MODE_DEFAULT, WorldObject *lootSource=nullptr)
Definition LootMgr.cpp:540
GameObject * sourceGameObject
Definition LootMgr.h:331
void NotifyItemRemoved(uint8 lootIndex)
Definition LootMgr.cpp:743
std::vector< LootItem > quest_items
Definition LootMgr.h:321

References ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL, ACHIEVEMENT_CRITERIA_TYPE_ROLL_GREED_ON_LOOT, ACHIEVEMENT_CRITERIA_TYPE_ROLL_NEED_ON_LOOT, Player::AutoStoreLoot(), Player::CanStoreNewItem(), CONFIG_LFG_MAIL_ITEM_ON_FULL_INVENTORY, LootItem::count, DISENCHANT, ItemTemplate::DisenchantID, ObjectGuid::Empty, EQUIP_ERR_INVENTORY_FULL, EQUIP_ERR_OK, Loot::FillLoot(), ObjectAccessor::FindPlayer(), GAMEOBJECT_TYPE_CHEST, LootItem::GetAllowedLooters(), Object::GetGUID(), Roll::getLoot(), Loot::GetMaxSlotInLootFor(), GO_JUST_DEACTIVATED, GREED, LootItem::is_blocked, LootItem::is_looted, isLFGGroup(), Loot::isLooted(), Reference< TO, FROM >::isValid(), Roll::itemid, LootItem::itemid, Loot::items, Roll::itemSlot, Loot::LootItemInSlot(), LootTemplates_Disenchant, MAIL_ITEM_ON_FULL_INVENTORY_EVERYWHERE, MAIL_ITEM_ON_FULL_INVENTORY_LFG_ONLY, NEED, NOT_VALID, Loot::NotifyItemRemoved(), NULL_BAG, NULL_SLOT, Roll::playerVote, Loot::quest_items, LootItem::randomPropertyId, ROLL_NEED, RollId, LootItem::rollWinnerGUID, Player::SendEquipError(), Player::SendItemRetrievalMail(), SendLootAllPassed(), SendLootRoll(), SendLootRollWon(), SendRollWonItemViaMail(), sObjectMgr, sScriptMgr, Player::StoreNewItem(), sWorld, Roll::totalGreed, Roll::totalNeed, GameObjectTemplate::type, Loot::unlootedCount, Player::UpdateAchievementCriteria(), Player::UpdateLootAchievements(), and urand().

Referenced by CountRollVote(), and EndRoll().

◆ Create()

bool Group::Create ( Player leader)
143{
144 ObjectGuid leaderGuid = leader->GetGUID();
145 ObjectGuid::LowType lowguid = sGroupMgr->GenerateGroupId();
146
147 m_guid = ObjectGuid::Create<HighGuid::Group>(lowguid);
148 m_leaderGuid = leaderGuid;
149 m_leaderName = leader->GetName();
151
152 if (isBGGroup() || isBFGroup())
154
157
158 if (!isLFGGroup())
160
162 m_looterGuid = leaderGuid;
164
167
168 if (!isBGGroup() && !isBFGroup())
169 {
172
173 // Store group in database
175
176 uint8 index = 0;
177
178 stmt->SetData(index++, lowguid);
179 stmt->SetData(index++, m_leaderGuid.GetCounter());
180 stmt->SetData(index++, uint8(m_lootMethod));
181 stmt->SetData(index++, m_looterGuid.GetCounter());
182 stmt->SetData(index++, uint8(m_lootThreshold));
183 stmt->SetData(index++, m_targetIcons[0].GetRawValue());
184 stmt->SetData(index++, m_targetIcons[1].GetRawValue());
185 stmt->SetData(index++, m_targetIcons[2].GetRawValue());
186 stmt->SetData(index++, m_targetIcons[3].GetRawValue());
187 stmt->SetData(index++, m_targetIcons[4].GetRawValue());
188 stmt->SetData(index++, m_targetIcons[5].GetRawValue());
189 stmt->SetData(index++, m_targetIcons[6].GetRawValue());
190 stmt->SetData(index++, m_targetIcons[7].GetRawValue());
191 stmt->SetData(index++, uint8(m_groupType));
192 stmt->SetData(index++, uint8(m_dungeonDifficulty));
193 stmt->SetData(index++, uint8(m_raidDifficulty));
194 stmt->SetData(index++, m_masterLooterGuid.GetCounter());
195
196 CharacterDatabase.Execute(stmt);
197
198 ASSERT(AddMember(leader)); // If the leader can't be added to a new group because it appears full, something is clearly wrong.
199
200 sScriptMgr->OnCreate(this, leader);
201 }
202 else if (!AddMember(leader))
203 return false;
204
205 return true;
206}
@ CHAR_INS_GROUP
Definition CharacterDatabase.h:284
#define ASSERT
Definition Errors.h:68
#define sGroupMgr
Definition GroupMgr.h:51
@ GROUPTYPE_BGRAID
Definition Group.h:89
@ GROUP_LOOT
Definition LootMgr.h:61
ObjectGuid m_looterGuid
Definition Group.h:359
ObjectGuid m_masterLooterGuid
Definition Group.h:360
bool AddMember(Player *player, uint8 roles=0)
Definition Group.cpp:424
ObjectGuid m_guid
Definition Group.h:363
uint32 LowType
Definition ObjectGuid.h:122
void Clear()
Definition ObjectGuid.h:138

References _initRaidSubGroupsCounter(), AddMember(), ASSERT, CHAR_INS_GROUP, CharacterDatabase, ObjectGuid::Clear(), DUNGEON_DIFFICULTY_NORMAL, ObjectGuid::GetCounter(), Player::GetDungeonDifficulty(), Object::GetGUID(), WorldObject::GetName(), Player::GetRaidDifficulty(), GROUP_LOOT, GROUPTYPE_BGRAID, GROUPTYPE_RAID, isBFGroup(), isBGGroup(), isLFGGroup(), ITEM_QUALITY_UNCOMMON, m_dungeonDifficulty, m_groupType, m_guid, m_leaderGuid, m_leaderName, m_looterGuid, m_lootMethod, m_lootThreshold, m_masterLooterGuid, m_raidDifficulty, m_targetIcons, PLAYER_FLAGS_GROUP_LEADER, RAID_DIFFICULTY_10MAN_NORMAL, PreparedStatementBase::SetData(), Player::SetPlayerFlag(), sGroupMgr, and sScriptMgr.

Referenced by Battlefield::AddOrSetPlayerToCorrectBfGroup(), Battleground::AddOrSetPlayerToCorrectBgGroup(), Arena::AddPlayer(), and lfg::LFGMgr::MakeNewGroup().

◆ Disband()

void Group::Disband ( bool  hideDestroy = false)
760{
761 sScriptMgr->OnGroupDisband(this);
762
763 Player* player;
764 uint32 instanceId = 0;
765
766 for (member_citerator citr = m_memberSlots.begin(); citr != m_memberSlots.end(); ++citr)
767 {
768 if (!isBGGroup() && !isBFGroup())
769 {
770 sCharacterCache->ClearCharacterGroup(citr->guid);
771 }
772
773 player = ObjectAccessor::FindConnectedPlayer(citr->guid);
774
775 if (player && !instanceId && !isBGGroup() && !isBFGroup())
776 {
777 instanceId = player->GetInstanceId();
778 }
779
780 _homebindIfInstance(player);
781 if (!isBGGroup() && !isBFGroup())
783
784 if (!player)
785 continue;
786
787 //we cannot call _removeMember because it would invalidate member iterator
788 //if we are removing player from battleground raid
789 if (isBGGroup() || isBFGroup())
791 else
792 {
793 //we can remove player who is in battleground from his original group
794 if (player->GetOriginalGroup() == this)
795 player->SetOriginalGroup(nullptr);
796 else
797 player->SetGroup(nullptr);
798 }
799
800 // quest related GO state dependent from raid membership
801 if (isRaidGroup())
803
804 WorldPacket data;
805 if (!hideDestroy)
806 {
808 player->SendDirectMessage(&data);
809 }
810
811 //we already removed player from group and in player->GetGroup() is his original group, send update
812 if (Group* group = player->GetGroup())
813 {
814 group->SendUpdate();
815 }
816 else
817 {
818 data.Initialize(SMSG_GROUP_LIST, 1 + 1 + 1 + 1 + 8 + 4 + 4 + 8);
819 data << uint8(0x10) << uint8(0) << uint8(0) << uint8(0);
820 data << m_guid << uint32(m_counter) << uint32(0) << uint64(0);
821 player->SendDirectMessage(&data);
822 }
823 }
824 RollId.clear();
825 m_memberSlots.clear();
826
828
829 if (!isBGGroup() && !isBFGroup())
830 {
831 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
832
834 stmt->SetData(0, GetGUID().GetCounter());
835 trans->Append(stmt);
836
837 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GROUP_MEMBER_ALL);
838 stmt->SetData(0, GetGUID().GetCounter());
839 trans->Append(stmt);
840
841 CharacterDatabase.CommitTransaction(trans);
842
843 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_LFG_DATA);
844 stmt->SetData(0, GetGUID().GetCounter());
845 CharacterDatabase.Execute(stmt);
846 }
847
848 // Cleaning up instance saved data for gameobjects when a group is disbanded
849 sInstanceSaveMgr->DeleteInstanceSavedData(instanceId);
850
851 sGroupMgr->RemoveGroup(this);
852 delete this;
853}
@ CHAR_DEL_GROUP_MEMBER_ALL
Definition CharacterDatabase.h:381
@ CHAR_DEL_GROUP
Definition CharacterDatabase.h:380
@ CHAR_DEL_LFG_DATA
Definition CharacterDatabase.h:328
std::uint64_t uint64
Definition Define.h:106
@ INSTANCE_RESET_GROUP_LEAVE
Definition Map.h:704
void RemoveAllInvites()
Definition Group.cpp:395
void _homebindIfInstance(Player *player)
Definition Group.cpp:2258
void RemoveFromBattlegroundOrBattlefieldRaid()
Definition Player.cpp:13228
void Initialize(uint16 opcode, std::size_t newres=200)
Definition WorldPacket.h:68
@ SMSG_GROUP_LIST
Definition Opcodes.h:155
@ SMSG_GROUP_DESTROYED
Definition Opcodes.h:154

References _homebindIfInstance(), CHAR_DEL_GROUP, CHAR_DEL_GROUP_MEMBER_ALL, CHAR_DEL_LFG_DATA, CharacterDatabase, ObjectAccessor::FindConnectedPlayer(), Player::GetGroup(), GetGUID(), WorldObject::GetInstanceId(), Player::GetOriginalGroup(), WorldPacket::Initialize(), INSTANCE_RESET_GROUP_LEAVE, isBFGroup(), isBGGroup(), isRaidGroup(), m_counter, m_guid, m_memberSlots, RemoveAllInvites(), Player::RemoveFromBattlegroundOrBattlefieldRaid(), Player::ResetInstances(), RollId, sCharacterCache, Player::SendDirectMessage(), PreparedStatementBase::SetData(), Player::SetGroup(), Player::SetOriginalGroup(), sGroupMgr, sInstanceSaveMgr, SMSG_GROUP_DESTROYED, SMSG_GROUP_LIST, sScriptMgr, and Player::UpdateForQuestWorldObjects().

Referenced by Arena::AddPlayer(), group_commandscript::HandleGroupDisbandCommand(), WorldSession::HandleGroupDisbandOpcode(), RemoveMember(), and Player::UninviteFromGroup().

◆ DoForAllMembers()

void Group::DoForAllMembers ( std::function< void(Player *)> const &  worker)
2619{
2620 for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next())
2621 {
2622 Player* member = itr->GetSource();
2623 if (!member)
2624 continue;
2625
2626 worker(member);
2627 }
2628}

References GetFirstMember(), and GroupReference::next().

Referenced by BattlegroundQueue::AddGroup(), WorldSession::HandleBattlemasterJoinArena(), and WorldSession::HandleBattlemasterJoinOpcode().

◆ DoMinimapPing()

void Group::DoMinimapPing ( ObjectGuid  sourceGuid,
float  mapX,
float  mapY 
)
2129{
2131 minimapPing.SourceGuid = sourceGuid;
2132 minimapPing.MapX = mapX;
2133 minimapPing.MapY = mapY;
2134
2135 BroadcastPacket(minimapPing.Write(), true, -1, sourceGuid);
2136}
Definition MiscPackets.h:108
float MapY
Definition MiscPackets.h:116
WorldPacket const * Write() override
Definition MiscPackets.cpp:76
float MapX
Definition MiscPackets.h:115
ObjectGuid SourceGuid
Definition MiscPackets.h:114

References BroadcastPacket(), WorldPackets::Misc::MinimapPing::MapX, WorldPackets::Misc::MinimapPing::MapY, WorldPackets::Misc::MinimapPing::SourceGuid, and WorldPackets::Misc::MinimapPing::Write().

Referenced by WorldSession::HandleMinimapPingOpcode().

◆ EndRoll()

void Group::EndRoll ( Loot loot)
1418{
1419 for (Rolls::iterator itr = RollId.begin(); itr != RollId.end();)
1420 {
1421 if ((*itr)->getLoot() == pLoot)
1422 {
1423 CountTheRoll(itr); //i don't have to edit player votes, who didn't vote ... he will pass
1424 itr = RollId.begin();
1425 }
1426 else
1427 ++itr;
1428 }
1429}

References CountTheRoll(), and RollId.

Referenced by GameObject::Update(), and Creature::Update().

◆ GetDifficulty()

Difficulty Group::GetDifficulty ( bool  isRaid) const
2519{
2520 return isRaid ? m_raidDifficulty : m_dungeonDifficulty;
2521}

References m_dungeonDifficulty, and m_raidDifficulty.

Referenced by MapInstanced::CreateInstanceForPlayer().

◆ GetDifficultyChangePreventionReason()

DifficultyPreventionChangeType Group::GetDifficultyChangePreventionReason ( ) const
inline

◆ GetDifficultyChangePreventionTime()

uint32 Group::GetDifficultyChangePreventionTime ( ) const

◆ GetDungeonDifficulty()

Difficulty Group::GetDungeonDifficulty ( ) const
2524{
2525 return m_dungeonDifficulty;
2526}

References m_dungeonDifficulty.

Referenced by AddMember().

◆ GetFirstMember() [1/2]

◆ GetFirstMember() [2/2]

GroupReference const * Group::GetFirstMember ( ) const
inline
251{ return m_memberMgr.getFirst(); }

References GroupRefMgr::getFirst(), and m_memberMgr.

◆ GetGroupType()

GroupType Group::GetGroupType ( ) const
2367{
2368 return m_groupType;
2369}

References m_groupType.

◆ GetGUID()

◆ GetInvited() [1/2]

Player * Group::GetInvited ( const std::string &  name) const
415{
416 for (InvitesList::const_iterator itr = m_invitees.begin(); itr != m_invitees.end(); ++itr)
417 {
418 if ((*itr) && (*itr)->GetName() == name)
419 return (*itr);
420 }
421 return nullptr;
422}

References m_invitees.

◆ GetInvited() [2/2]

Player * Group::GetInvited ( ObjectGuid  guid) const
405{
406 for (InvitesList::const_iterator itr = m_invitees.begin(); itr != m_invitees.end(); ++itr)
407 {
408 if ((*itr) && (*itr)->GetGUID() == guid)
409 return (*itr);
410 }
411 return nullptr;
412}

References m_invitees.

Referenced by WorldSession::HandleGroupUninviteGuidOpcode(), and WorldSession::HandleGroupUninviteOpcode().

◆ GetInviteeCount()

uint32 Group::GetInviteeCount ( ) const
inline
253{ return m_invitees.size(); }

References m_invitees.

Referenced by Player::UninviteFromGroup().

◆ GetLeader()

Player * Group::GetLeader ( )

◆ GetLeaderGUID()

◆ GetLeaderName()

const char * Group::GetLeaderName ( ) const
2387{
2388 return m_leaderName.c_str();
2389}

References m_leaderName.

Referenced by ChatLogScript::OnPlayerCanUseChat(), and Player::Satisfy().

◆ GetLooterGuid()

ObjectGuid Group::GetLooterGuid ( ) const
2397{
2398 return m_looterGuid;
2399}

References m_looterGuid.

Referenced by Unit::Kill(), and UpdateLooterGuid().

◆ GetLootMethod()

◆ GetLootThreshold()

ItemQualities Group::GetLootThreshold ( ) const
2407{
2408 return m_lootThreshold;
2409}

References m_lootThreshold.

Referenced by Loot::FillLoot().

◆ GetMasterLooterGuid()

ObjectGuid Group::GetMasterLooterGuid ( ) const

◆ GetMemberGroup()

uint8 Group::GetMemberGroup ( ObjectGuid  guid) const
2460{
2461 member_citerator mslot = _getMemberCSlot(guid);
2462 if (mslot == m_memberSlots.end())
2463 return (MAX_RAID_SUBGROUPS + 1);
2464 return mslot->group;
2465}
member_citerator _getMemberCSlot(ObjectGuid Guid) const
Definition Group.cpp:2564

References _getMemberCSlot(), m_memberSlots, and MAX_RAID_SUBGROUPS.

Referenced by Battlefield::AddOrSetPlayerToCorrectBfGroup(), Battleground::AddOrSetPlayerToCorrectBgGroup(), ChangeMembersGroup(), WorldSession::HandleGroupSwapSubGroupOpcode(), WorldSession::HandleMessagechatOpcode(), and Unit::Kill().

◆ GetMemberGUID()

ObjectGuid Group::GetMemberGUID ( const std::string &  name)
2422{
2423 for (member_citerator itr = m_memberSlots.begin(); itr != m_memberSlots.end(); ++itr)
2424 if (itr->name == name)
2425 return itr->guid;
2426
2427 return ObjectGuid::Empty;
2428}

References ObjectGuid::Empty, and m_memberSlots.

Referenced by WorldSession::HandleGroupSwapSubGroupOpcode(), and WorldSession::HandleGroupUninviteOpcode().

◆ GetMembersCount()

◆ GetMemberSlots()

MemberSlotList const & Group::GetMemberSlots ( ) const
inline

◆ GetRaidDifficulty()

Difficulty Group::GetRaidDifficulty ( ) const
2529{
2530 return m_raidDifficulty;
2531}

References m_raidDifficulty.

Referenced by AddMember().

◆ GetRoll()

Group::Rolls::iterator Group::GetRoll ( ObjectGuid  Guid)
2539{
2540 Rolls::iterator iter;
2541 for (iter = RollId.begin(); iter != RollId.end(); ++iter)
2542 if ((*iter)->itemGUID == Guid && (*iter)->isValid())
2543 return iter;
2544 return RollId.end();
2545}

References RollId.

Referenced by CountRollVote().

◆ GroupLoot()

void Group::GroupLoot ( Loot loot,
WorldObject pLootedObject 
)
1011{
1012 std::vector<LootItem>::iterator i;
1013 ItemTemplate const* item;
1014 uint8 itemSlot = 0;
1015
1016 for (i = loot->items.begin(); i != loot->items.end(); ++i, ++itemSlot)
1017 {
1018 if (i->freeforall)
1019 continue;
1020
1021 item = sObjectMgr->GetItemTemplate(i->itemid);
1022 if (!item)
1023 {
1024 continue;
1025 }
1026
1027 // roll for over-threshold item if it's one-player loot
1028 if (item->Quality >= uint32(m_lootThreshold))
1029 {
1030 ObjectGuid newitemGUID = ObjectGuid::Create<HighGuid::Item>(sObjectMgr->GetGenerator<HighGuid::Item>().Generate());
1031 Roll* r = new Roll(newitemGUID, *i);
1032
1033 //a vector is filled with only near party members
1034 for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next())
1035 {
1036 Player* member = itr->GetSource();
1037 if (!member || !member->GetSession())
1038 continue;
1039 if (member->IsAtLootRewardDistance(pLootedObject))
1040 {
1042
1043 RollVote vote = member->GetPassOnGroupLoot() ? PASS : NOT_EMITED_YET;
1044 if (!CanRollOnItem(*i, member, loot))
1045 {
1046 vote = PASS;
1047 ++r->totalPass;
1048 }
1049
1050 r->playerVote[member->GetGUID()] = vote;
1051 }
1052 }
1053
1054 if (r->totalPlayersRolling > 0)
1055 {
1056 r->setLoot(loot);
1057 r->itemSlot = itemSlot;
1060
1061 loot->items[itemSlot].is_blocked = true;
1062
1063 // If there is any "auto pass", broadcast the pass now.
1064 if (r->totalPass)
1065 {
1066 for (Roll::PlayerVote::const_iterator itr = r->playerVote.begin(); itr != r->playerVote.end(); ++itr)
1067 {
1068 Player* p = ObjectAccessor::FindPlayer(itr->first);
1069 if (!p)
1070 continue;
1071
1072 if (itr->second == PASS)
1073 SendLootRoll(newitemGUID, p->GetGUID(), 128, ROLL_PASS, *r, true);
1074 }
1075 }
1076
1077 if (r->totalPass == r->totalPlayersRolling)
1078 delete r;
1079 else
1080 {
1081 SendLootStartRoll(60000, pLootedObject->GetMapId(), *r);
1082
1083 RollId.push_back(r);
1084
1085 if (Creature* creature = pLootedObject->ToCreature())
1086 {
1087 creature->m_groupLootTimer = 60000;
1088 creature->lootingGroupLowGUID = GetGUID().GetCounter();
1089 }
1090 else if (GameObject* go = pLootedObject->ToGameObject())
1091 {
1092 go->m_groupLootTimer = 60000;
1093 go->lootingGroupLowGUID = GetGUID().GetCounter();
1094 }
1095 }
1096 }
1097 else
1098 delete r;
1099 }
1100 else
1101 i->is_underthreshold = true;
1102 }
1103
1104 for (i = loot->quest_items.begin(); i != loot->quest_items.end(); ++i, ++itemSlot)
1105 {
1106 if (!i->follow_loot_rules)
1107 continue;
1108
1109 item = sObjectMgr->GetItemTemplate(i->itemid);
1110 if (!item)
1111 {
1112 continue;
1113 }
1114
1115 ObjectGuid newitemGUID = ObjectGuid::Create<HighGuid::Item>(sObjectMgr->GetGenerator<HighGuid::Item>().Generate());
1116 Roll* r = new Roll(newitemGUID, *i);
1117
1118 //a vector is filled with only near party members
1119 for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next())
1120 {
1121 Player* member = itr->GetSource();
1122 if (!member || !member->GetSession())
1123 continue;
1124
1125 if (member->IsAtLootRewardDistance(pLootedObject))
1126 {
1128
1129 RollVote vote = NOT_EMITED_YET;
1130 if (!CanRollOnItem(*i, member, loot))
1131 {
1132 vote = PASS;
1133 ++r->totalPass;
1134 }
1135 r->playerVote[member->GetGUID()] = vote;
1136 }
1137 }
1138
1139 if (r->totalPlayersRolling > 0)
1140 {
1141 r->setLoot(loot);
1142 r->itemSlot = itemSlot;
1143
1144 loot->quest_items[itemSlot - loot->items.size()].is_blocked = true;
1145
1146 SendLootStartRoll(60000, pLootedObject->GetMapId(), *r);
1147
1148 RollId.push_back(r);
1149
1150 if (Creature* creature = pLootedObject->ToCreature())
1151 {
1152 creature->m_groupLootTimer = 60000;
1153 creature->lootingGroupLowGUID = GetGUID().GetCounter();
1154 }
1155 else if (GameObject* go = pLootedObject->ToGameObject())
1156 {
1157 go->m_groupLootTimer = 60000;
1158 go->lootingGroupLowGUID = GetGUID().GetCounter();
1159 }
1160 }
1161 else
1162 delete r;
1163 }
1164}
bool CanRollOnItem(LootItem const &item, Player const *player, Loot *loot)
Definition Group.cpp:993
@ NOT_EMITED_YET
Definition Group.h:54
@ ROLL_FLAG_TYPE_DISENCHANT
Definition LootMgr.h:45
Definition Creature.h:47
Definition GameObject.h:120
void SendLootStartRoll(uint32 CountDown, uint32 mapid, const Roll &r)
Definition Group.cpp:859
GameObject * ToGameObject()
Definition Object.h:214
Creature * ToCreature()
Definition Object.h:206
WorldSession * GetSession() const
Definition Player.h:2023
bool IsAtLootRewardDistance(WorldObject const *pRewardSource) const
Definition Player.cpp:12894
bool GetPassOnGroupLoot() const
Definition Player.h:2530
void setLoot(Loot *pLoot)
Definition Group.cpp:56
uint8 rollVoteMask
Definition Group.h:170
uint32 Quality
Definition ItemTemplate.h:626
uint32 RequiredDisenchantSkill
Definition ItemTemplate.h:684

References CanRollOnItem(), ItemTemplate::DisenchantID, ObjectAccessor::FindPlayer(), ObjectGuid::GetCounter(), GetFirstMember(), GetGUID(), Object::GetGUID(), WorldLocation::GetMapId(), Player::GetPassOnGroupLoot(), Player::GetSession(), Player::IsAtLootRewardDistance(), Item, Loot::items, Roll::itemSlot, m_lootThreshold, m_maxEnchantingLevel, GroupReference::next(), NOT_EMITED_YET, PASS, Roll::playerVote, ItemTemplate::Quality, Loot::quest_items, ItemTemplate::RequiredDisenchantSkill, ROLL_FLAG_TYPE_DISENCHANT, ROLL_PASS, RollId, Roll::rollVoteMask, SendLootRoll(), SendLootStartRoll(), Roll::setLoot(), sObjectMgr, Object::ToCreature(), Object::ToGameObject(), Roll::totalPass, and Roll::totalPlayersRolling.

Referenced by Player::SendLoot().

◆ HasFreeSlotSubGroup()

bool Group::HasFreeSlotSubGroup ( uint8  subgroup) const

◆ InInstance()

uint16 Group::InInstance ( )

◆ IsAssistant()

◆ isBFGroup()

◆ isBGGroup()

◆ IsCreated()

bool Group::IsCreated ( ) const
2362{
2363 return GetMembersCount() > 0;
2364}

References GetMembersCount().

Referenced by Player::UninviteFromGroup().

◆ IsFull()

bool Group::IsFull ( ) const

◆ IsLeader()

◆ isLFGGroup()

◆ IsLfgHeroic()

bool Group::IsLfgHeroic ( ) const
inline

◆ IsLfgRandomInstance()

◆ IsLfgWithBuff()

◆ IsMember()

◆ isRaidGroup()

◆ isRollLootActive()

bool Group::isRollLootActive ( ) const
2534{
2535 return !RollId.empty();
2536}

References RollId.

Referenced by Player::CanUninviteFromGroup().

◆ LinkMember()

void Group::LinkMember ( GroupReference pRef)
2548{
2550}
void insertFirst(LinkedListElement *pElem)
Definition LinkedList.h:105

References LinkedListHead::insertFirst(), and m_memberMgr.

Referenced by GroupReference::targetObjectBuildLink().

◆ LoadGroupFromDB()

bool Group::LoadGroupFromDB ( Field field)
209{
210 ObjectGuid::LowType groupLowGuid = fields[16].Get<uint32>();
211 m_guid = ObjectGuid::Create<HighGuid::Group>(groupLowGuid);
212
213 m_leaderGuid = ObjectGuid::Create<HighGuid::Player>(fields[0].Get<uint32>());
214
215 // group leader not exist
216 if (!sCharacterCache->GetCharacterNameByGuid(m_leaderGuid, m_leaderName))
217 {
218 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
220 stmt->SetData(0, groupLowGuid);
221 trans->Append(stmt);
222 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GROUP_MEMBER_ALL);
223 stmt->SetData(0, groupLowGuid);
224 trans->Append(stmt);
225 CharacterDatabase.CommitTransaction(trans);
226 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_LFG_DATA);
227 stmt->SetData(0, groupLowGuid);
228 CharacterDatabase.Execute(stmt);
229 return false;
230 }
231
232 m_lootMethod = LootMethod(fields[1].Get<uint8>());
233 m_looterGuid = ObjectGuid::Create<HighGuid::Player>(fields[2].Get<uint32>());
234 m_lootThreshold = ItemQualities(fields[3].Get<uint8>());
235
236 for (uint8 i = 0; i < TARGETICONCOUNT; ++i)
237 m_targetIcons[i].Set(fields[4 + i].Get<uint64>());
238
239 m_groupType = GroupType(fields[12].Get<uint8>());
242
243 uint32 diff = fields[13].Get<uint8>();
244 if (diff >= MAX_DUNGEON_DIFFICULTY)
246 else
248
249 uint32 r_diff = fields[14].Get<uint8>();
250 if (r_diff >= MAX_RAID_DIFFICULTY)
252 else
254
255 m_masterLooterGuid = ObjectGuid::Create<HighGuid::Player>(fields[15].Get<uint32>());
256
258 sLFGMgr->_LoadFromDB(fields, GetGUID());
259
260 return true;
261}
#define MAX_RAID_DIFFICULTY
Definition DBCEnums.h:282
Difficulty
Definition DBCEnums.h:266
#define MAX_DUNGEON_DIFFICULTY
Definition DBCEnums.h:281
LootMethod
Definition LootMgr.h:57
ItemQualities
Definition SharedDefines.h:316

References _initRaidSubGroupsCounter(), CHAR_DEL_GROUP, CHAR_DEL_GROUP_MEMBER_ALL, CHAR_DEL_LFG_DATA, CharacterDatabase, DUNGEON_DIFFICULTY_NORMAL, Field::Get(), GetGUID(), GROUPTYPE_LFG, GROUPTYPE_RAID, m_dungeonDifficulty, m_groupType, m_guid, m_leaderGuid, m_leaderName, m_looterGuid, m_lootMethod, m_lootThreshold, m_masterLooterGuid, m_raidDifficulty, m_targetIcons, MAX_DUNGEON_DIFFICULTY, MAX_RAID_DIFFICULTY, RAID_DIFFICULTY_10MAN_NORMAL, sCharacterCache, PreparedStatementBase::SetData(), sLFGMgr, and TARGETICONCOUNT.

Referenced by GroupMgr::LoadGroups().

◆ LoadMemberFromDB()

void Group::LoadMemberFromDB ( ObjectGuid::LowType  guidLow,
uint8  memberFlags,
uint8  subgroup,
uint8  roles 
)
264{
265 MemberSlot member;
266 member.guid = ObjectGuid::Create<HighGuid::Player>(guidLow);
267
268 // skip non-existed member
269 if (!sCharacterCache->GetCharacterNameByGuid(member.guid, member.name))
270 {
272 stmt->SetData(0, guidLow);
273 stmt->SetData(1, GetGUID().GetCounter());
274 CharacterDatabase.Execute(stmt);
275 return;
276 }
277
278 member.group = subgroup;
279 member.flags = memberFlags;
280 member.roles = roles;
281
282 m_memberSlots.push_back(member);
283
284 if (!isBGGroup() && !isBFGroup())
285 {
286 sCharacterCache->UpdateCharacterGroup(ObjectGuid(HighGuid::Player, guidLow), GetGUID());
287 }
288
289 SubGroupCounterIncrease(subgroup);
290
291 sLFGMgr->SetupGroupMember(member.guid, GetGUID());
292}
@ CHAR_DEL_GROUP_MEMBER
Definition CharacterDatabase.h:286

References CHAR_DEL_GROUP_MEMBER, CharacterDatabase, Group::MemberSlot::flags, GetGUID(), Group::MemberSlot::group, Group::MemberSlot::guid, isBFGroup(), isBGGroup(), m_memberSlots, Group::MemberSlot::name, Player, Group::MemberSlot::roles, sCharacterCache, PreparedStatementBase::SetData(), sLFGMgr, and SubGroupCounterIncrease().

Referenced by GroupMgr::LoadGroups().

◆ MasterLoot()

void Group::MasterLoot ( Loot loot,
WorldObject pLootedObject 
)
1318{
1319 LOG_DEBUG("network", "Group::MasterLoot (SMSG_LOOT_MASTER_LIST, 330)");
1320
1321 for (std::vector<LootItem>::iterator i = loot->items.begin(); i != loot->items.end(); ++i)
1322 {
1323 if (i->freeforall)
1324 continue;
1325
1326 i->is_blocked = !i->is_underthreshold;
1327 }
1328
1329 for (std::vector<LootItem>::iterator i = loot->quest_items.begin(); i != loot->quest_items.end(); ++i)
1330 {
1331 if (!i->follow_loot_rules)
1332 continue;
1333
1334 i->is_blocked = !i->is_underthreshold;
1335 }
1336
1337 std::vector<Player*> looters;
1338 for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next())
1339 {
1340 Player* looter = itr->GetSource();
1341 if (!looter->IsInWorld())
1342 {
1343 continue;
1344 }
1345
1346 if (looter->IsAtLootRewardDistance(pLootedObject))
1347 {
1348 looters.push_back(looter);
1349 }
1350 }
1351
1352 WorldPacket data(SMSG_LOOT_MASTER_LIST, 1 + looters.size() * (1 + 8));
1353 data << uint8(looters.size());
1354
1355 for (Player* looter : looters)
1356 {
1357 data << looter->GetGUID();
1358 }
1359
1360 for (Player* looter : looters)
1361 {
1362 looter->SendDirectMessage(&data);
1363 }
1364}
bool IsInWorld() const
Definition Object.h:109
@ SMSG_LOOT_MASTER_LIST
Definition Opcodes.h:706

References GetFirstMember(), Player::IsAtLootRewardDistance(), Object::IsInWorld(), Loot::items, LOG_DEBUG, GroupReference::next(), Loot::quest_items, and SMSG_LOOT_MASTER_LIST.

Referenced by Player::SendLoot().

◆ NeedBeforeGreed()

void Group::NeedBeforeGreed ( Loot loot,
WorldObject pLootedObject 
)
1167{
1168 ItemTemplate const* item;
1169 uint8 itemSlot = 0;
1170 for (std::vector<LootItem>::iterator i = loot->items.begin(); i != loot->items.end(); ++i, ++itemSlot)
1171 {
1172 if (i->freeforall)
1173 continue;
1174
1175 item = sObjectMgr->GetItemTemplate(i->itemid);
1176
1177 //roll for over-threshold item if it's one-player loot
1178 if (item->Quality >= uint32(m_lootThreshold))
1179 {
1180 ObjectGuid newitemGUID = ObjectGuid::Create<HighGuid::Item>(sObjectMgr->GetGenerator<HighGuid::Item>().Generate());
1181 Roll* r = new Roll(newitemGUID, *i);
1182
1183 for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next())
1184 {
1185 Player* playerToRoll = itr->GetSource();
1186 if (!playerToRoll || !playerToRoll->GetSession())
1187 continue;
1188
1189 if (playerToRoll->IsAtGroupRewardDistance(lootedObject))
1190 {
1192
1193 RollVote vote = playerToRoll->GetPassOnGroupLoot() ? PASS : NOT_EMITED_YET;
1194 if (!CanRollOnItem(*i, playerToRoll, loot))
1195 {
1196 vote = PASS;
1197 r->totalPass++; // Can't broadcast the pass now. need to wait until all rolling players are known
1198 }
1199
1200 r->playerVote[playerToRoll->GetGUID()] = vote;
1201 }
1202 }
1203
1204 if (r->totalPlayersRolling > 0)
1205 {
1206 r->setLoot(loot);
1207 r->itemSlot = itemSlot;
1210
1212 r->rollVoteMask &= ~ROLL_FLAG_TYPE_NEED;
1213
1214 loot->items[itemSlot].is_blocked = true;
1215
1216 //Broadcast Pass and Send Rollstart
1217 for (Roll::PlayerVote::const_iterator itr = r->playerVote.begin(); itr != r->playerVote.end(); ++itr)
1218 {
1219 Player* p = ObjectAccessor::FindPlayer(itr->first);
1220 if (!p)
1221 continue;
1222
1223 if (itr->second == PASS)
1224 SendLootRoll(newitemGUID, p->GetGUID(), 128, ROLL_PASS, *r);
1225 else
1226 SendLootStartRollToPlayer(60000, lootedObject->GetMapId(), p, p->CanRollForItemInLFG(item, lootedObject) == EQUIP_ERR_OK, *r);
1227 }
1228
1229 RollId.push_back(r);
1230
1231 if (Creature* creature = lootedObject->ToCreature())
1232 {
1233 creature->m_groupLootTimer = 60000;
1234 creature->lootingGroupLowGUID = GetGUID().GetCounter();
1235 }
1236 else if (GameObject* go = lootedObject->ToGameObject())
1237 {
1238 go->m_groupLootTimer = 60000;
1239 go->lootingGroupLowGUID = GetGUID().GetCounter();
1240 }
1241 }
1242 else
1243 delete r;
1244 }
1245 else
1246 i->is_underthreshold = true;
1247 }
1248
1249 for (std::vector<LootItem>::iterator i = loot->quest_items.begin(); i != loot->quest_items.end(); ++i, ++itemSlot)
1250 {
1251 if (!i->follow_loot_rules)
1252 continue;
1253
1254 item = sObjectMgr->GetItemTemplate(i->itemid);
1255 ObjectGuid newitemGUID = ObjectGuid::Create<HighGuid::Item>(sObjectMgr->GetGenerator<HighGuid::Item>().Generate());
1256 Roll* r = new Roll(newitemGUID, *i);
1257
1258 for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next())
1259 {
1260 Player* playerToRoll = itr->GetSource();
1261 if (!playerToRoll || !playerToRoll->GetSession())
1262 continue;
1263
1264 if (playerToRoll->IsAtGroupRewardDistance(lootedObject))
1265 {
1267
1268 RollVote vote = playerToRoll->GetPassOnGroupLoot() ? PASS : NOT_EMITED_YET;
1269 if (!CanRollOnItem(*i, playerToRoll, loot))
1270 {
1271 vote = PASS;
1272 r->totalPass++; // Can't broadcast the pass now. need to wait until all rolling players are known
1273 }
1274
1275 r->playerVote[playerToRoll->GetGUID()] = vote;
1276 }
1277 }
1278
1279 if (r->totalPlayersRolling > 0)
1280 {
1281 r->setLoot(loot);
1282 r->itemSlot = itemSlot;
1283
1284 loot->quest_items[itemSlot - loot->items.size()].is_blocked = true;
1285
1286 //Broadcast Pass and Send Rollstart
1287 for (Roll::PlayerVote::const_iterator itr = r->playerVote.begin(); itr != r->playerVote.end(); ++itr)
1288 {
1289 Player* p = ObjectAccessor::FindPlayer(itr->first);
1290 if (!p)
1291 continue;
1292
1293 if (itr->second == PASS)
1294 SendLootRoll(newitemGUID, p->GetGUID(), 128, ROLL_PASS, *r);
1295 else
1296 SendLootStartRollToPlayer(60000, lootedObject->GetMapId(), p, p->CanRollForItemInLFG(item, lootedObject) == EQUIP_ERR_OK, *r);
1297 }
1298
1299 RollId.push_back(r);
1300
1301 if (Creature* creature = lootedObject->ToCreature())
1302 {
1303 creature->m_groupLootTimer = 60000;
1304 creature->lootingGroupLowGUID = GetGUID().GetCounter();
1305 }
1306 else if (GameObject* go = lootedObject->ToGameObject())
1307 {
1308 go->m_groupLootTimer = 60000;
1309 go->lootingGroupLowGUID = GetGUID().GetCounter();
1310 }
1311 }
1312 else
1313 delete r;
1314 }
1315}
@ ITEM_FLAG2_CAN_ONLY_ROLL_GREED
Definition ItemTemplate.h:191
void SendLootStartRollToPlayer(uint32 countDown, uint32 mapId, Player *p, bool canNeed, Roll const &r)
Definition Group.cpp:883
InventoryResult CanRollForItemInLFG(ItemTemplate const *item, WorldObject const *lootedObject) const
Definition PlayerStorage.cpp:2410
bool IsAtGroupRewardDistance(WorldObject const *pRewardSource) const
Definition Player.cpp:12873
bool HasFlag2(ItemFlags2 flag) const
Definition ItemTemplate.h:826

References Player::CanRollForItemInLFG(), CanRollOnItem(), ItemTemplate::DisenchantID, EQUIP_ERR_OK, ObjectAccessor::FindPlayer(), ObjectGuid::GetCounter(), GetFirstMember(), GetGUID(), Object::GetGUID(), WorldLocation::GetMapId(), Player::GetPassOnGroupLoot(), Player::GetSession(), ItemTemplate::HasFlag2(), Player::IsAtGroupRewardDistance(), Item, ITEM_FLAG2_CAN_ONLY_ROLL_GREED, Loot::items, Roll::itemSlot, m_lootThreshold, m_maxEnchantingLevel, GroupReference::next(), NOT_EMITED_YET, PASS, Roll::playerVote, ItemTemplate::Quality, Loot::quest_items, ItemTemplate::RequiredDisenchantSkill, ROLL_FLAG_TYPE_DISENCHANT, ROLL_PASS, RollId, Roll::rollVoteMask, SendLootRoll(), SendLootStartRollToPlayer(), Roll::setLoot(), sObjectMgr, Object::ToCreature(), Object::ToGameObject(), Roll::totalPass, and Roll::totalPlayersRolling.

Referenced by Player::SendLoot().

◆ OfflineReadyCheck()

void Group::OfflineReadyCheck ( )
1847{
1848 for (member_citerator citr = m_memberSlots.begin(); citr != m_memberSlots.end(); ++citr)
1849 {
1850 Player* player = ObjectAccessor::FindConnectedPlayer(citr->guid);
1851 if (!player)
1852 {
1854 data << citr->guid;
1855 data << uint8(0);
1856 BroadcastReadyCheck(&data);
1857 }
1858 }
1859}
void BroadcastReadyCheck(WorldPacket const *packet)
Definition Group.cpp:1835
@ MSG_RAID_READY_CHECK_CONFIRM
Definition Opcodes.h:972

References BroadcastReadyCheck(), ObjectAccessor::FindConnectedPlayer(), m_memberSlots, and MSG_RAID_READY_CHECK_CONFIRM.

Referenced by WorldSession::HandleRaidReadyCheckOpcode().

◆ RemoveAllInvites()

void Group::RemoveAllInvites ( )
396{
397 for (InvitesList::iterator itr = m_invitees.begin(); itr != m_invitees.end(); ++itr)
398 if (*itr)
399 (*itr)->SetGroupInvite(nullptr);
400
401 m_invitees.clear();
402}

References m_invitees.

Referenced by Disband(), and Player::UninviteFromGroup().

◆ RemoveInvite()

void Group::RemoveInvite ( Player player)
386{
387 if (player)
388 {
389 if (!m_invitees.empty())
390 m_invitees.erase(player);
391 player->SetGroupInvite(nullptr);
392 }
393}

References m_invitees, and Player::SetGroupInvite().

Referenced by AddInvite(), WorldSession::HandleGroupAcceptOpcode(), and Player::UninviteFromGroup().

◆ RemoveMember()

bool Group::RemoveMember ( ObjectGuid  guid,
const RemoveMethod method = GROUP_REMOVEMETHOD_DEFAULT,
ObjectGuid  kicker = ObjectGuid::Empty,
const char *  reason = nullptr 
)
581{
583
584 // LFG group vote kick handled in scripts
585 if (isLFGGroup(true) && method == GROUP_REMOVEMETHOD_KICK)
586 {
587 sLFGMgr->InitBoot(GetGUID(), kicker, guid, std::string(reason ? reason : ""));
588 return m_memberSlots.size() > 0;
589 }
590
591 // remove member and change leader (if need) only if strong more 2 members _before_ member remove (BG/BF allow 1 member group)
592 if (GetMembersCount() > ((isBGGroup() || isLFGGroup() || isBFGroup()) ? 1u : 2u))
593 {
595 if (player)
596 {
597 // Battleground group handling
598 if (isBGGroup() || isBFGroup())
600 else
601 // Regular group
602 {
603 if (player->GetOriginalGroup() == this)
604 player->SetOriginalGroup(nullptr);
605 else
606 player->SetGroup(nullptr);
607
608 // quest related GO state dependent from raid membership
610 }
611
612 WorldPacket data;
613
614 if (method == GROUP_REMOVEMETHOD_KICK || method == GROUP_REMOVEMETHOD_KICK_LFG)
615 {
617 player->SendDirectMessage(&data);
618 }
619
620 // Do we really need to send this opcode?
621 data.Initialize(SMSG_GROUP_LIST, 1 + 1 + 1 + 1 + 8 + 4 + 4 + 8);
622 data << uint8(0x10) << uint8(0) << uint8(0) << uint8(0);
623 data << m_guid << uint32(m_counter) << uint32(0) << uint64(0);
624 player->SendDirectMessage(&data);
625 }
626
627 // Remove player from group in DB
628 if (!isBGGroup() && !isBFGroup())
629 {
631 stmt->SetData(0, guid.GetCounter());
632 stmt->SetData(1, GetGUID().GetCounter());
633 CharacterDatabase.Execute(stmt);
634 }
635
636 // Remove player from loot rolls
638
639 // Update subgroups
641 if (slot != m_memberSlots.end())
642 {
643 SubGroupCounterDecrease(slot->group);
644 m_memberSlots.erase(slot);
645
646 if (!isBGGroup() && !isBFGroup())
647 {
648 sCharacterCache->ClearCharacterGroup(guid);
649 }
650 }
651
652 // Reevaluate group enchanter if the leaving player had enchanting skill or the player is offline
653 if (!player || player->GetSkillValue(SKILL_ENCHANTING))
654 {
656 }
657
658 // Pick new leader if necessary
659 bool validLeader = true;
660 if (m_leaderGuid == guid)
661 {
662 validLeader = false;
663 for (member_witerator itr = m_memberSlots.begin(); itr != m_memberSlots.end(); ++itr)
664 {
666 {
667 ChangeLeader(itr->guid);
668 validLeader = true;
669 break;
670 }
671 }
672 }
673
674 _homebindIfInstance(player);
675 if (!isBGGroup() && !isBFGroup())
677
678 sScriptMgr->OnGroupRemoveMember(this, guid, method, kicker, reason);
679
680 SendUpdate();
681
682 if (!validLeader)
683 {
684 // pussywizard: temp do nothing, something causes crashes in MakeNewGroup
685 //Disband();
686 //return false;
687 }
688
689 if (isLFGGroup() && GetMembersCount() == 1)
690 {
692 uint32 mapId = sLFGMgr->GetDungeonMapId(GetGUID());
693 lfg::LfgState state = sLFGMgr->GetState(GetGUID());
694 if (!mapId || !leader || (leader->IsAlive() && leader->GetMapId() != mapId) || state == lfg::LFG_STATE_NONE)
695 {
696 Disband();
697 return false;
698 }
699 }
700
701 if (m_memberMgr.getSize() < ((isLFGGroup() || isBGGroup() || isBFGroup()) ? 1u : 2u))
702 {
703 Disband();
704 return false;
705 }
706
707 return true;
708 }
709 // If group size before player removal <= 2 then disband it
710 else
711 {
712 sScriptMgr->OnGroupRemoveMember(this, guid, method, kicker, reason);
713 Disband();
714 return false;
715 }
716}
@ GROUP_REMOVEMETHOD_KICK_LFG
Definition SharedDefines.h:3846
@ GROUP_REMOVEMETHOD_KICK
Definition SharedDefines.h:3844
void BroadcastGroupUpdate(void)
Definition Group.cpp:2274
void Disband(bool hideDestroy=false)
Definition Group.cpp:759
void ResetMaxEnchantingLevel()
Definition Group.cpp:2290
void ChangeLeader(ObjectGuid guid)
Definition Group.cpp:718
void RemovePlayerFromRolls(ObjectGuid guid)
Definition Group.cpp:1431
uint32 getSize() const
Definition LinkedList.h:115
bool IsAlive() const
Definition Unit.h:1797
@ SMSG_GROUP_UNINVITE
Definition Opcodes.h:149

References _getMemberWSlot(), _homebindIfInstance(), BroadcastGroupUpdate(), ChangeLeader(), CHAR_DEL_GROUP_MEMBER, CharacterDatabase, Disband(), ObjectAccessor::FindConnectedPlayer(), ObjectGuid::GetCounter(), GetGUID(), GetLeaderGUID(), WorldLocation::GetMapId(), GetMembersCount(), Player::GetOriginalGroup(), LinkedListHead::getSize(), Player::GetSkillValue(), GROUP_REMOVEMETHOD_KICK, GROUP_REMOVEMETHOD_KICK_LFG, WorldPacket::Initialize(), INSTANCE_RESET_GROUP_LEAVE, Unit::IsAlive(), isBFGroup(), isBGGroup(), isLFGGroup(), lfg::LFG_STATE_NONE, m_counter, m_guid, m_leaderGuid, m_memberMgr, m_memberSlots, Player::RemoveFromBattlegroundOrBattlefieldRaid(), RemovePlayerFromRolls(), Player::ResetInstances(), ResetMaxEnchantingLevel(), sCharacterCache, Player::SendDirectMessage(), SendUpdate(), PreparedStatementBase::SetData(), Player::SetGroup(), Player::SetOriginalGroup(), SKILL_ENCHANTING, sLFGMgr, SMSG_GROUP_LIST, SMSG_GROUP_UNINVITE, sScriptMgr, SubGroupCounterDecrease(), and Player::UpdateForQuestWorldObjects().

Referenced by group_commandscript::HandleGroupRemoveCommand(), lfg::LFGMgr::MakeNewGroup(), and Player::RemoveFromGroup().

◆ RemovePlayerFromRolls()

void Group::RemovePlayerFromRolls ( ObjectGuid  guid)
1432{
1433 for (Rolls::iterator it = RollId.begin(); it != RollId.end();)
1434 {
1435 Roll* roll = *it;
1436 Roll::PlayerVote::iterator itr2 = roll->playerVote.find(guid);
1437 if (itr2 == roll->playerVote.end())
1438 {
1439 ++it;
1440 continue;
1441 }
1442
1443 if (itr2->second == GREED || itr2->second == DISENCHANT)
1444 --roll->totalGreed;
1445 else if (itr2->second == NEED)
1446 --roll->totalNeed;
1447 else if (itr2->second == PASS)
1448 --roll->totalPass;
1449
1450 if (itr2->second != NOT_VALID)
1451 --roll->totalPlayersRolling;
1452
1453 roll->playerVote.erase(itr2);
1454
1455 if (CountRollVote(guid, roll->itemGUID, MAX_ROLL_TYPE))
1456 it = RollId.begin();
1457 else
1458 ++it;
1459 }
1460}
@ MAX_ROLL_TYPE
Definition LootMgr.h:37
bool CountRollVote(ObjectGuid playerGUID, ObjectGuid Guid, uint8 Choise)
Definition Group.cpp:1366
ObjectGuid itemGUID
Definition Group.h:158

References CountRollVote(), DISENCHANT, GREED, Roll::itemGUID, MAX_ROLL_TYPE, NEED, NOT_VALID, PASS, Roll::playerVote, RollId, Roll::totalGreed, Roll::totalNeed, Roll::totalPass, and Roll::totalPlayersRolling.

Referenced by RemoveMember().

◆ RemoveUniqueGroupMemberFlag()

void Group::RemoveUniqueGroupMemberFlag ( GroupMemberFlags  flag)
2593{
2594 for (member_witerator itr = m_memberSlots.begin(); itr != m_memberSlots.end(); ++itr)
2595 if (itr->flags & flag)
2596 itr->flags &= ~flag;
2597}

References m_memberSlots.

Referenced by WorldSession::HandlePartyAssignmentOpcode(), and SetGroupMemberFlag().

◆ ResetInstances()

void Group::ResetInstances ( uint8  method,
bool  isRaid,
Player leader 
)
2191{
2192 if (isBGGroup() || isBFGroup() || isLFGGroup())
2193 return;
2194
2195 switch (method)
2196 {
2197 case INSTANCE_RESET_ALL:
2198 {
2199 if (leader->GetDifficulty(false) != DUNGEON_DIFFICULTY_NORMAL)
2200 break;
2201 std::vector<InstanceSave*> toUnbind;
2202 BoundInstancesMap const& m_boundInstances = sInstanceSaveMgr->PlayerGetBoundInstances(leader->GetGUID(), Difficulty(DUNGEON_DIFFICULTY_NORMAL));
2203 for (BoundInstancesMap::const_iterator itr = m_boundInstances.begin(); itr != m_boundInstances.end(); ++itr)
2204 {
2205 InstanceSave* instanceSave = itr->second.save;
2206 MapEntry const* entry = sMapStore.LookupEntry(itr->first);
2207 if (!entry || entry->IsRaid() || !instanceSave->CanReset())
2208 continue;
2209
2210 Map* map = sMapMgr->FindMap(instanceSave->GetMapId(), instanceSave->GetInstanceId());
2211 if (!map || map->ToInstanceMap()->Reset(method))
2212 {
2213 leader->SendResetInstanceSuccess(instanceSave->GetMapId());
2214 toUnbind.push_back(instanceSave);
2215 }
2216 else
2217 {
2218 leader->SendResetInstanceFailed(INSTANCE_RESET_FAILED, instanceSave->GetMapId());
2219 }
2220
2221 sInstanceSaveMgr->DeleteInstanceSavedData(instanceSave->GetInstanceId());
2222 }
2223 for (std::vector<InstanceSave*>::const_iterator itr = toUnbind.begin(); itr != toUnbind.end(); ++itr)
2224 sInstanceSaveMgr->UnbindAllFor(*itr);
2225 }
2226 break;
2228 {
2229 std::vector<InstanceSave*> toUnbind;
2230 BoundInstancesMap const& m_boundInstances = sInstanceSaveMgr->PlayerGetBoundInstances(leader->GetGUID(), leader->GetDifficulty(isRaid));
2231 for (BoundInstancesMap::const_iterator itr = m_boundInstances.begin(); itr != m_boundInstances.end(); ++itr)
2232 {
2233 InstanceSave* instanceSave = itr->second.save;
2234 MapEntry const* entry = sMapStore.LookupEntry(itr->first);
2235 if (!entry || entry->IsRaid() != isRaid || !instanceSave->CanReset())
2236 continue;
2237
2238 Map* map = sMapMgr->FindMap(instanceSave->GetMapId(), instanceSave->GetInstanceId());
2239 if (!map || map->ToInstanceMap()->Reset(method))
2240 {
2241 leader->SendResetInstanceSuccess(instanceSave->GetMapId());
2242 toUnbind.push_back(instanceSave);
2243 }
2244 else
2245 {
2246 leader->SendResetInstanceFailed(INSTANCE_RESET_FAILED, instanceSave->GetMapId());
2247 }
2248
2249 sInstanceSaveMgr->DeleteInstanceSavedData(instanceSave->GetInstanceId());
2250 }
2251 for (std::vector<InstanceSave*>::const_iterator itr = toUnbind.begin(); itr != toUnbind.end(); ++itr)
2252 sInstanceSaveMgr->UnbindAllFor(*itr);
2253 }
2254 break;
2255 }
2256}
std::unordered_map< uint32, InstancePlayerBind > BoundInstancesMap
Definition InstanceSaveMgr.h:46
#define sMapMgr
Definition MapMgr.h:220
@ INSTANCE_RESET_CHANGE_DIFFICULTY
Definition Map.h:701
@ INSTANCE_RESET_ALL
Definition Map.h:700
@ INSTANCE_RESET_FAILED
Definition Player.h:798
bool Reset(uint8 method, GuidList *globalSkipList=nullptr)
Definition Map.cpp:2153
Definition InstanceSaveMgr.h:56
uint32 GetMapId() const
Definition InstanceSaveMgr.h:62
bool CanReset() const
Definition InstanceSaveMgr.h:81
Definition Map.h:166
InstanceMap * ToInstanceMap()
Definition Map.h:381
void SendResetInstanceFailed(InstanceResetFailureReason reason, uint32 MapId)
Definition PlayerMisc.cpp:331
void SendResetInstanceSuccess(uint32 MapId)
Definition PlayerMisc.cpp:324
Definition DBCStructure.h:1325
bool IsRaid() const
Definition DBCStructure.h:1354

References InstanceSave::CanReset(), DUNGEON_DIFFICULTY_NORMAL, Player::GetDifficulty(), Object::GetGUID(), InstanceSave::GetInstanceId(), InstanceSave::GetMapId(), INSTANCE_RESET_ALL, INSTANCE_RESET_CHANGE_DIFFICULTY, INSTANCE_RESET_FAILED, isBFGroup(), isBGGroup(), isLFGGroup(), MapEntry::IsRaid(), InstanceMap::Reset(), Player::SendResetInstanceFailed(), Player::SendResetInstanceSuccess(), sInstanceSaveMgr, sMapMgr, sMapStore, and Map::ToInstanceMap().

Referenced by WorldSession::HandleSetDungeonDifficultyOpcode(), and WorldSession::HandleSetRaidDifficultyOpcode().

◆ ResetMaxEnchantingLevel()

void Group::ResetMaxEnchantingLevel ( )
2291{
2293 Player* pMember = nullptr;
2294 for (member_citerator citr = m_memberSlots.begin(); citr != m_memberSlots.end(); ++citr)
2295 {
2296 pMember = ObjectAccessor::FindPlayer(citr->guid);
2297 if (pMember && pMember->GetSession() && !pMember->GetSession()->IsSocketClosed()
2298 && m_maxEnchantingLevel < pMember->GetSkillValue(SKILL_ENCHANTING))
2299 {
2301 }
2302 }
2303}
bool IsSocketClosed() const
Definition WorldSession.cpp:608

References ObjectAccessor::FindPlayer(), Player::GetSession(), Player::GetSkillValue(), WorldSession::IsSocketClosed(), m_maxEnchantingLevel, m_memberSlots, and SKILL_ENCHANTING.

Referenced by WorldSession::LogoutPlayer(), and RemoveMember().

◆ SameSubGroup() [1/3]

bool Group::SameSubGroup ( ObjectGuid  guid1,
MemberSlot const *  slot2 
) const
2447{
2448 member_citerator mslot1 = _getMemberCSlot(guid1);
2449 if (mslot1 == m_memberSlots.end() || !slot2)
2450 return false;
2451 return (mslot1->group == slot2->group);
2452}

References _getMemberCSlot(), Group::MemberSlot::group, and m_memberSlots.

◆ SameSubGroup() [2/3]

bool Group::SameSubGroup ( ObjectGuid  guid1,
ObjectGuid  guid2 
) const
2439{
2440 member_citerator mslot2 = _getMemberCSlot(guid2);
2441 if (mslot2 == m_memberSlots.end())
2442 return false;
2443 return SameSubGroup(guid1, &*mslot2);
2444}
bool SameSubGroup(ObjectGuid guid1, ObjectGuid guid2) const
Definition Group.cpp:2438

References _getMemberCSlot(), m_memberSlots, and SameSubGroup().

Referenced by Player::IsInSameGroupWith(), SameSubGroup(), and PetAI::UpdateAllies().

◆ SameSubGroup() [3/3]

bool Group::SameSubGroup ( Player const *  member1,
Player const *  member2 
) const
1862{
1863 if (!member1 || !member2)
1864 return false;
1865
1866 if (member1->GetGroup() != this || member2->GetGroup() != this)
1867 return false;
1868 else
1869 return member1->GetSubGroup() == member2->GetSubGroup();
1870}

References Player::GetGroup(), and Player::GetSubGroup().

◆ SendLootAllPassed()

void Group::SendLootAllPassed ( Roll const &  roll)
953{
954 WorldPacket data(SMSG_LOOT_ALL_PASSED, (8 + 4 + 4 + 4 + 4));
955 data << roll.itemGUID; // Guid of the item rolled
956 data << uint32(roll.itemSlot); // Item loot slot
957 data << uint32(roll.itemid); // The itemEntryId for the item that shall be rolled for
958 data << uint32(roll.itemRandomPropId); // Item random property ID
959 data << uint32(roll.itemRandomSuffix); // Item random suffix ID
960
961 for (Roll::PlayerVote::const_iterator itr = roll.playerVote.begin(); itr != roll.playerVote.end(); ++itr)
962 {
963 Player* player = ObjectAccessor::FindConnectedPlayer(itr->first);
964 if (!player)
965 continue;
966
967 if (itr->second != NOT_VALID)
968 player->SendDirectMessage(&data);
969 }
970}
@ SMSG_LOOT_ALL_PASSED
Definition Opcodes.h:700

References ObjectAccessor::FindConnectedPlayer(), Roll::itemGUID, Roll::itemid, Roll::itemRandomPropId, Roll::itemRandomSuffix, Roll::itemSlot, NOT_VALID, Roll::playerVote, Player::SendDirectMessage(), and SMSG_LOOT_ALL_PASSED.

Referenced by CountTheRoll().

◆ SendLooter()

void Group::SendLooter ( Creature creature,
Player pLooter 
)
974{
975 ASSERT(creature);
976
977 WorldPacket data(SMSG_LOOT_LIST, (8 + 8));
978 data << creature->GetGUID();
979
980 if (GetLootMethod() == MASTER_LOOT && creature->loot.hasOverThresholdItem())
982 else
983 data << uint8(0);
984
985 if (groupLooter)
986 data << groupLooter->GetPackGUID();
987 else
988 data << uint8(0);
989
990 BroadcastPacket(&data, false);
991}
@ MASTER_LOOT
Definition LootMgr.h:60
Loot loot
Definition Creature.h:231
ObjectGuid GetMasterLooterGuid() const
Definition Group.cpp:2401
LootMethod GetLootMethod() const
Definition Group.cpp:2391
PackedGuid WriteAsPacked() const
Definition ObjectGuid.h:316
@ SMSG_LOOT_LIST
Definition Opcodes.h:1047
bool hasOverThresholdItem() const
Definition LootMgr.cpp:952

References ASSERT, BroadcastPacket(), Object::GetGUID(), GetLootMethod(), GetMasterLooterGuid(), Object::GetPackGUID(), Loot::hasOverThresholdItem(), Creature::loot, MASTER_LOOT, SMSG_LOOT_LIST, and ObjectGuid::WriteAsPacked().

Referenced by Unit::Kill().

◆ SendLootRoll()

void Group::SendLootRoll ( ObjectGuid  SourceGuid,
ObjectGuid  TargetGuid,
uint8  RollNumber,
uint8  RollType,
const Roll r,
bool  autoPass = false 
)
906{
907 WorldPacket data(SMSG_LOOT_ROLL, (8 + 4 + 8 + 4 + 4 + 4 + 1 + 1 + 1));
908 data << sourceGuid; // guid of the item rolled
909 data << uint32(roll.itemSlot); // slot
910 data << targetGuid;
911 data << uint32(roll.itemid); // the itemEntryId for the item that shall be rolled for
912 data << uint32(roll.itemRandomSuffix); // randomSuffix
913 data << uint32(roll.itemRandomPropId); // Item random property ID
914 data << uint8(rollNumber); // 0: "Need for: [item name]" > 127: "you passed on: [item name]" Roll number
915 data << uint8(rollType); // 0: "Need for: [item name]" 0: "You have selected need for [item name] 1: need roll 2: greed roll
916 data << uint8(autoPass); // 1: "You automatically passed on: %s because you cannot loot that item."
917
918 for (Roll::PlayerVote::const_iterator itr = roll.playerVote.begin(); itr != roll.playerVote.end(); ++itr)
919 {
921 if (!p)
922 continue;
923
924 if (itr->second != NOT_VALID)
925 p->SendDirectMessage(&data);
926 }
927}
@ SMSG_LOOT_ROLL
Definition Opcodes.h:704

References ObjectAccessor::FindConnectedPlayer(), Roll::itemid, Roll::itemRandomPropId, Roll::itemRandomSuffix, Roll::itemSlot, NOT_VALID, Roll::playerVote, Player::SendDirectMessage(), and SMSG_LOOT_ROLL.

Referenced by CountRollVote(), CountTheRoll(), GroupLoot(), and NeedBeforeGreed().

◆ SendLootRollWon()

void Group::SendLootRollWon ( ObjectGuid  SourceGuid,
ObjectGuid  TargetGuid,
uint8  RollNumber,
uint8  RollType,
const Roll r 
)
930{
931 WorldPacket data(SMSG_LOOT_ROLL_WON, (8 + 4 + 4 + 4 + 4 + 8 + 1 + 1));
932 data << sourceGuid; // guid of the item rolled
933 data << uint32(roll.itemSlot); // slot
934 data << uint32(roll.itemid); // the itemEntryId for the item that shall be rolled for
935 data << uint32(roll.itemRandomSuffix); // randomSuffix
936 data << uint32(roll.itemRandomPropId); // Item random property
937 data << targetGuid; // guid of the player who won.
938 data << uint8(rollNumber); // rollnumber realted to SMSG_LOOT_ROLL
939 data << uint8(rollType); // rollType related to SMSG_LOOT_ROLL
940
941 for (Roll::PlayerVote::const_iterator itr = roll.playerVote.begin(); itr != roll.playerVote.end(); ++itr)
942 {
944 if (!p)
945 continue;
946
947 if (itr->second != NOT_VALID)
948 p->SendDirectMessage(&data);
949 }
950}
@ SMSG_LOOT_ROLL_WON
Definition Opcodes.h:701

References ObjectAccessor::FindConnectedPlayer(), Roll::itemid, Roll::itemRandomPropId, Roll::itemRandomSuffix, Roll::itemSlot, NOT_VALID, Roll::playerVote, Player::SendDirectMessage(), and SMSG_LOOT_ROLL_WON.

Referenced by CountTheRoll().

◆ SendLootStartRoll()

void Group::SendLootStartRoll ( uint32  CountDown,
uint32  mapid,
const Roll r 
)
860{
861 WorldPacket data(SMSG_LOOT_START_ROLL, (8 + 4 + 4 + 4 + 4 + 4 + 4 + 1));
862 data << r.itemGUID; // guid of rolled item
863 data << uint32(mapid); // 3.3.3 mapid
864 data << uint32(r.itemSlot); // itemslot
865 data << uint32(r.itemid); // the itemEntryId for the item that shall be rolled for
866 data << uint32(r.itemRandomSuffix); // randomSuffix
867 data << uint32(r.itemRandomPropId); // item random property ID
868 data << uint32(r.itemCount); // items in stack
869 data << uint32(CountDown); // the countdown time to choose "need" or "greed"
870 data << uint8(r.rollVoteMask); // roll type mask
871
872 for (Roll::PlayerVote::const_iterator itr = r.playerVote.begin(); itr != r.playerVote.end(); ++itr)
873 {
875 if (!p)
876 continue;
877
878 if (itr->second == NOT_EMITED_YET)
879 p->SendDirectMessage(&data);
880 }
881}
int32 itemRandomPropId
Definition Group.h:160
uint8 itemCount
Definition Group.h:162
uint32 itemRandomSuffix
Definition Group.h:161
@ SMSG_LOOT_START_ROLL
Definition Opcodes.h:703

References ObjectAccessor::FindConnectedPlayer(), Roll::itemCount, Roll::itemGUID, Roll::itemid, Roll::itemRandomPropId, Roll::itemRandomSuffix, Roll::itemSlot, NOT_EMITED_YET, Roll::playerVote, Roll::rollVoteMask, Player::SendDirectMessage(), and SMSG_LOOT_START_ROLL.

Referenced by GroupLoot().

◆ SendLootStartRollToPlayer()

void Group::SendLootStartRollToPlayer ( uint32  countDown,
uint32  mapId,
Player p,
bool  canNeed,
Roll const &  r 
)
884{
885 if (!p)
886 return;
887
888 WorldPacket data(SMSG_LOOT_START_ROLL, (8 + 4 + 4 + 4 + 4 + 4 + 4 + 1));
889 data << r.itemGUID; // guid of rolled item
890 data << uint32(mapId); // 3.3.3 mapid
891 data << uint32(r.itemSlot); // itemslot
892 data << uint32(r.itemid); // the itemEntryId for the item that shall be rolled for
893 data << uint32(r.itemRandomSuffix); // randomSuffix
894 data << uint32(r.itemRandomPropId); // item random property ID
895 data << uint32(r.itemCount); // items in stack
896 data << uint32(countDown); // the countdown time to choose "need" or "greed"
897 uint8 voteMask = r.rollVoteMask;
898 if (!canNeed)
899 voteMask &= ~ROLL_FLAG_TYPE_NEED;
900 data << uint8(voteMask); // roll type mask
901
902 p->SendDirectMessage(&data);
903}

References Roll::itemCount, Roll::itemGUID, Roll::itemid, Roll::itemRandomPropId, Roll::itemRandomSuffix, Roll::itemSlot, Roll::rollVoteMask, Player::SendDirectMessage(), and SMSG_LOOT_START_ROLL.

Referenced by NeedBeforeGreed().

◆ SendTargetIconList()

void Group::SendTargetIconList ( WorldSession session)
1711{
1712 if (!session)
1713 return;
1714
1716 data << uint8(1); // list targets
1717
1718 for (uint8 i = 0; i < TARGETICONCOUNT; ++i)
1719 {
1720 if (!m_targetIcons[i])
1721 continue;
1722
1723 data << uint8(i);
1724 data << m_targetIcons[i];
1725 }
1726
1727 session->SendPacket(&data);
1728}
void SendPacket(WorldPacket const *packet)
Send a packet to the client.
Definition WorldSession.cpp:287
@ MSG_RAID_TARGET_UPDATE
Definition Opcodes.h:831

References m_targetIcons, MSG_RAID_TARGET_UPDATE, WorldSession::SendPacket(), and TARGETICONCOUNT.

Referenced by WorldSession::HandleRaidTargetUpdateOpcode().

◆ SendUpdate()

◆ SendUpdateToPlayer()

void Group::SendUpdateToPlayer ( ObjectGuid  playerGUID,
MemberSlot slot = nullptr 
)
1737{
1738 Player* player = ObjectAccessor::FindConnectedPlayer(playerGUID);
1739
1740 if (!player || player->GetGroup() != this)
1741 return;
1742
1743 // if MemberSlot wasn't provided
1744 if (!slot)
1745 {
1746 member_witerator witr = _getMemberWSlot(playerGUID);
1747
1748 if (witr == m_memberSlots.end()) // if there is no MemberSlot for such a player
1749 return;
1750
1751 slot = &(*witr);
1752 }
1753
1754 WorldPacket data(SMSG_GROUP_LIST, (1 + 1 + 1 + 1 + 1 + 4 + 8 + 4 + 4 + (GetMembersCount() - 1) * (13 + 8 + 1 + 1 + 1 + 1) + 8 + 1 + 8 + 1 + 1 + 1 + 1));
1755 data << uint8(m_groupType); // group type (flags in 3.3)
1756 data << uint8(slot->group);
1757 data << uint8(slot->flags);
1758 data << uint8(slot->roles);
1759 if (isLFGGroup())
1760 {
1761 data << uint8(sLFGMgr->GetState(m_guid) == lfg::LFG_STATE_FINISHED_DUNGEON ? 2 : 0); // FIXME - Dungeon save status? 2 = done
1762 data << uint32(sLFGMgr->GetDungeon(m_guid));
1763 }
1764
1765 data << m_guid;
1766 data << uint32(m_counter++); // 3.3, value increases every time this packet gets sent
1767 data << uint32(GetMembersCount() - 1);
1768 for (member_citerator citr = m_memberSlots.begin(); citr != m_memberSlots.end(); ++citr)
1769 {
1770 if (slot->guid == citr->guid)
1771 continue;
1772
1773 Player* member = ObjectAccessor::FindConnectedPlayer(citr->guid);
1774
1775 uint8 onlineState = (member && !member->GetSession()->PlayerLogout()) ? MEMBER_STATUS_ONLINE : MEMBER_STATUS_OFFLINE;
1776 onlineState = onlineState | ((isBGGroup() || isBFGroup()) ? MEMBER_STATUS_PVP : 0);
1777
1778 data << citr->name;
1779 data << citr->guid; // guid
1780 data << uint8(onlineState); // online-state
1781 data << uint8(citr->group); // groupid
1782 data << uint8(citr->flags); // See enum GroupMemberFlags
1783 data << uint8(citr->roles); // Lfg Roles
1784 }
1785
1786 data << m_leaderGuid; // leader guid
1787
1788 if (GetMembersCount() - 1)
1789 {
1790 data << uint8(m_lootMethod); // loot method
1791
1793 data << m_masterLooterGuid; // master looter guid
1794 else
1795 data << uint64(0); // looter guid
1796
1797 data << uint8(m_lootThreshold); // loot threshold
1798 data << uint8(m_dungeonDifficulty); // Dungeon Difficulty
1799 data << uint8(m_raidDifficulty); // Raid Difficulty
1800 data << uint8(m_raidDifficulty >= RAID_DIFFICULTY_10MAN_HEROIC); // 3.3 Dynamic Raid Difficulty - 0 normal/1 heroic
1801 }
1802
1803 player->SendDirectMessage(&data);
1804}
@ RAID_DIFFICULTY_10MAN_HEROIC
Definition DBCEnums.h:275
@ MEMBER_STATUS_OFFLINE
Definition Group.h:60
@ MEMBER_STATUS_PVP
Definition Group.h:62
@ MEMBER_STATUS_ONLINE
Definition Group.h:61
bool PlayerLogout() const
Definition WorldSession.h:412
@ LFG_STATE_FINISHED_DUNGEON
Definition LFG.h:74

References _getMemberWSlot(), ObjectAccessor::FindConnectedPlayer(), Group::MemberSlot::flags, Player::GetGroup(), GetMembersCount(), Player::GetSession(), Group::MemberSlot::group, Group::MemberSlot::guid, isBFGroup(), isBGGroup(), isLFGGroup(), lfg::LFG_STATE_FINISHED_DUNGEON, m_counter, m_dungeonDifficulty, m_groupType, m_guid, m_leaderGuid, m_lootMethod, m_lootThreshold, m_masterLooterGuid, m_memberSlots, m_raidDifficulty, MASTER_LOOT, MEMBER_STATUS_OFFLINE, MEMBER_STATUS_ONLINE, MEMBER_STATUS_PVP, WorldSession::PlayerLogout(), RAID_DIFFICULTY_10MAN_HEROIC, Group::MemberSlot::roles, Player::SendDirectMessage(), sLFGMgr, and SMSG_GROUP_LIST.

Referenced by SendUpdate().

◆ SetBattlefieldGroup()

void Group::SetBattlefieldGroup ( Battlefield bf)
2473{
2474 m_bfGroup = bg;
2475}

References m_bfGroup.

Referenced by Battlefield::AddOrSetPlayerToCorrectBfGroup().

◆ SetBattlegroundGroup()

void Group::SetBattlegroundGroup ( Battleground bg)
2468{
2469 m_bgGroup = bg;
2470}

References m_bgGroup.

Referenced by Battleground::SetBgRaid().

◆ SetDifficultyChangePrevention()

◆ SetDungeonDifficulty()

void Group::SetDungeonDifficulty ( Difficulty  difficulty)
2149{
2150 m_dungeonDifficulty = difficulty;
2151 if (!isBGGroup() && !isBFGroup())
2152 {
2154
2156 stmt->SetData(1, GetGUID().GetCounter());
2157
2158 CharacterDatabase.Execute(stmt);
2159 }
2160
2161 for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next())
2162 {
2163 Player* player = itr->GetSource();
2164 player->SetDungeonDifficulty(difficulty);
2165 player->SendDungeonDifficulty(true);
2166 }
2167}
@ CHAR_UPD_GROUP_DIFFICULTY
Definition CharacterDatabase.h:291

References CHAR_UPD_GROUP_DIFFICULTY, CharacterDatabase, GetFirstMember(), GetGUID(), isBFGroup(), isBGGroup(), m_dungeonDifficulty, GroupReference::next(), Player::SendDungeonDifficulty(), PreparedStatementBase::SetData(), and Player::SetDungeonDifficulty().

Referenced by WorldSession::HandleSetDungeonDifficultyOpcode(), and lfg::LFGMgr::MakeNewGroup().

◆ SetGroupMemberFlag()

void Group::SetGroupMemberFlag ( ObjectGuid  guid,
bool  apply,
GroupMemberFlags  flag 
)
2478{
2479 // Assistants, main assistants and main tanks are only available in raid groups
2480 if (!isRaidGroup())
2481 return;
2482
2483 // Check if player is really in the raid
2484 member_witerator slot = _getMemberWSlot(guid);
2485 if (slot == m_memberSlots.end())
2486 return;
2487
2488 // Do flag specific actions, e.g ensure uniqueness
2489 switch (flag)
2490 {
2492 RemoveUniqueGroupMemberFlag(MEMBER_FLAG_MAINASSIST); // Remove main assist flag from current if any.
2493 break;
2495 RemoveUniqueGroupMemberFlag(MEMBER_FLAG_MAINTANK); // Remove main tank flag from current if any.
2496 break;
2498 break;
2499 default:
2500 return; // This should never happen
2501 }
2502
2503 // Switch the actual flag
2504 ToggleGroupMemberFlag(slot, flag, apply);
2505
2506 // Preserve the new setting in the db
2508
2509 stmt->SetData(0, slot->flags);
2510 stmt->SetData(1, guid.GetCounter());
2511
2512 CharacterDatabase.Execute(stmt);
2513
2514 // Broadcast the changes to the group
2515 SendUpdate();
2516}
@ CHAR_UPD_GROUP_MEMBER_FLAG
Definition CharacterDatabase.h:290
@ MEMBER_FLAG_MAINASSIST
Definition Group.h:75
@ MEMBER_FLAG_MAINTANK
Definition Group.h:74
void RemoveUniqueGroupMemberFlag(GroupMemberFlags flag)
Definition Group.cpp:2592

References _getMemberWSlot(), CHAR_UPD_GROUP_MEMBER_FLAG, CharacterDatabase, ObjectGuid::GetCounter(), isRaidGroup(), m_memberSlots, MEMBER_FLAG_ASSISTANT, MEMBER_FLAG_MAINASSIST, MEMBER_FLAG_MAINTANK, RemoveUniqueGroupMemberFlag(), SendUpdate(), PreparedStatementBase::SetData(), and ToggleGroupMemberFlag().

Referenced by WorldSession::HandleGroupAssistantLeaderOpcode(), and WorldSession::HandlePartyAssignmentOpcode().

◆ SetLfgRoles()

void Group::SetLfgRoles ( ObjectGuid  guid,
const uint8  roles 
)
2326{
2327 member_witerator slot = _getMemberWSlot(guid);
2328 if (slot == m_memberSlots.end())
2329 return;
2330
2331 slot->roles = roles;
2332 SendUpdate();
2333}

References _getMemberWSlot(), m_memberSlots, and SendUpdate().

Referenced by lfg::LFGMgr::MakeNewGroup().

◆ SetLooterGuid()

void Group::SetLooterGuid ( ObjectGuid  guid)
2311{
2312 m_looterGuid = guid;
2313}

References m_looterGuid.

Referenced by UpdateLooterGuid().

◆ SetLootMethod()

void Group::SetLootMethod ( LootMethod  method)
2306{
2307 m_lootMethod = method;
2308}

References m_lootMethod.

Referenced by WorldSession::HandleLootMethodOpcode().

◆ SetLootThreshold()

void Group::SetLootThreshold ( ItemQualities  threshold)
2321{
2322 m_lootThreshold = threshold;
2323}

References m_lootThreshold.

Referenced by WorldSession::HandleLootMethodOpcode().

◆ SetMasterLooterGuid()

void Group::SetMasterLooterGuid ( ObjectGuid  guid)
2316{
2317 m_masterLooterGuid = guid;
2318}

References m_masterLooterGuid.

Referenced by WorldSession::HandleLootMethodOpcode().

◆ SetRaidDifficulty()

void Group::SetRaidDifficulty ( Difficulty  difficulty)
2170{
2171 m_raidDifficulty = difficulty;
2172 if (!isBGGroup() && !isBFGroup())
2173 {
2175
2176 stmt->SetData(0, uint8(m_raidDifficulty));
2177 stmt->SetData(1, GetGUID().GetCounter());
2178
2179 CharacterDatabase.Execute(stmt);
2180 }
2181
2182 for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next())
2183 {
2184 Player* player = itr->GetSource();
2185 player->SetRaidDifficulty(difficulty);
2186 player->SendRaidDifficulty(true);
2187 }
2188}
@ CHAR_UPD_GROUP_RAID_DIFFICULTY
Definition CharacterDatabase.h:292

References CHAR_UPD_GROUP_RAID_DIFFICULTY, CharacterDatabase, GetFirstMember(), GetGUID(), isBFGroup(), isBGGroup(), m_raidDifficulty, GroupReference::next(), Player::SendRaidDifficulty(), PreparedStatementBase::SetData(), and Player::SetRaidDifficulty().

Referenced by WorldSession::HandleSetRaidDifficultyOpcode().

◆ SetTargetIcon()

void Group::SetTargetIcon ( uint8  id,
ObjectGuid  whoGuid,
ObjectGuid  targetGuid 
)
1690{
1691 if (id >= TARGETICONCOUNT)
1692 return;
1693
1694 // clean other icons
1695 if (targetGuid)
1696 for (int i = 0; i < TARGETICONCOUNT; ++i)
1697 if (m_targetIcons[i] == targetGuid)
1699
1700 m_targetIcons[id] = targetGuid;
1701
1702 WorldPacket data(MSG_RAID_TARGET_UPDATE, (1 + 8 + 1 + 8));
1703 data << uint8(0); // set targets
1704 data << whoGuid;
1705 data << uint8(id);
1706 data << targetGuid;
1707 BroadcastPacket(&data, true);
1708}
void SetTargetIcon(uint8 id, ObjectGuid whoGuid, ObjectGuid targetGuid)
Definition Group.cpp:1689

References BroadcastPacket(), ObjectGuid::Empty, m_targetIcons, MSG_RAID_TARGET_UPDATE, SetTargetIcon(), and TARGETICONCOUNT.

Referenced by WorldSession::HandleRaidTargetUpdateOpcode(), and SetTargetIcon().

◆ SubGroupCounterDecrease()

void Group::SubGroupCounterDecrease ( uint8  subgroup)
protected
2587{
2589 --m_subGroupsCounts[subgroup];
2590}

References m_subGroupsCounts.

Referenced by ChangeMembersGroup(), and RemoveMember().

◆ SubGroupCounterIncrease()

void Group::SubGroupCounterIncrease ( uint8  subgroup)
protected
2581{
2583 ++m_subGroupsCounts[subgroup];
2584}

References m_subGroupsCounts.

Referenced by AddMember(), ChangeMembersGroup(), and LoadMemberFromDB().

◆ ToggleGroupMemberFlag()

void Group::ToggleGroupMemberFlag ( member_witerator  slot,
uint8  flag,
bool  apply 
)
protected
2600{
2601 if (apply)
2602 slot->flags |= flag;
2603 else
2604 slot->flags &= ~flag;
2605}

Referenced by ChangeLeader(), and SetGroupMemberFlag().

◆ UpdateLooterGuid()

void Group::UpdateLooterGuid ( WorldObject pLootedObject,
bool  ifneed = false 
)
1934{
1935 // round robin style looting applies for all low
1936 // quality items in each loot method except free for all
1937 if (GetLootMethod() == FREE_FOR_ALL)
1938 return;
1939
1940 ObjectGuid oldLooterGUID = GetLooterGuid();
1941 member_citerator guid_itr = _getMemberCSlot(oldLooterGUID);
1942 if (guid_itr != m_memberSlots.end())
1943 {
1944 if (ifneed)
1945 {
1946 // not update if only update if need and ok
1947 Player* looter = ObjectAccessor::FindPlayer(guid_itr->guid);
1948 if (looter && looter->IsAtLootRewardDistance(pLootedObject))
1949 return;
1950 }
1951 ++guid_itr;
1952 }
1953
1954 // search next after current
1955 Player* pNewLooter = nullptr;
1956 for (member_citerator itr = guid_itr; itr != m_memberSlots.end(); ++itr)
1957 {
1958 if (Player* player = ObjectAccessor::FindPlayer(itr->guid))
1959 if (player->IsAtLootRewardDistance(pLootedObject))
1960 {
1961 pNewLooter = player;
1962 break;
1963 }
1964 }
1965
1966 if (!pNewLooter)
1967 {
1968 // search from start
1969 for (member_citerator itr = m_memberSlots.begin(); itr != guid_itr; ++itr)
1970 {
1971 if (Player* player = ObjectAccessor::FindPlayer(itr->guid))
1972 if (player->IsAtLootRewardDistance(pLootedObject))
1973 {
1974 pNewLooter = player;
1975 break;
1976 }
1977 }
1978 }
1979
1980 if (pNewLooter)
1981 {
1982 if (oldLooterGUID != pNewLooter->GetGUID())
1983 {
1984 SetLooterGuid(pNewLooter->GetGUID());
1985 SendUpdate();
1986 }
1987 }
1988 else
1989 {
1991 SendUpdate();
1992 }
1993}
ObjectGuid GetLooterGuid() const
Definition Group.cpp:2396
void SetLooterGuid(ObjectGuid guid)
Definition Group.cpp:2310

References _getMemberCSlot(), ObjectGuid::Empty, ObjectAccessor::FindPlayer(), FREE_FOR_ALL, Object::GetGUID(), GetLooterGuid(), GetLootMethod(), Player::IsAtLootRewardDistance(), m_memberSlots, SendUpdate(), and SetLooterGuid().

Referenced by Unit::Kill(), and Player::SendLoot().

◆ UpdatePlayerOutOfRange()

void Group::UpdatePlayerOutOfRange ( Player player)
1807{
1808 if (!player || !player->IsInWorld())
1809 return;
1810
1811 WorldPacket data;
1812 player->GetSession()->BuildPartyMemberStatsChangedPacket(player, &data);
1813
1814 for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next())
1815 {
1816 Player* member = itr->GetSource();
1817 if (member && (!member->IsInMap(player) || !member->IsWithinDist(player, member->GetSightRange(player), false)))
1818 member->SendDirectMessage(&data);
1819 }
1820}
float GetSightRange(WorldObject const *target=nullptr) const override
Definition Player.cpp:16426
bool IsWithinDist(WorldObject const *obj, float dist2compare, bool is3D=true, bool incOwnRadius=true, bool incTargetRadius=true) const
Definition Object.cpp:1372
bool IsInMap(WorldObject const *obj) const
Definition Object.cpp:1335
void BuildPartyMemberStatsChangedPacket(Player *player, WorldPacket *data)
Definition GroupHandler.cpp:804

References WorldSession::BuildPartyMemberStatsChangedPacket(), GetFirstMember(), Player::GetSession(), Player::GetSightRange(), WorldObject::IsInMap(), Object::IsInWorld(), WorldObject::IsWithinDist(), GroupReference::next(), and Player::SendDirectMessage().

Referenced by AddMember().

Member Data Documentation

◆ _difficultyChangePreventionTime

uint32 Group::_difficultyChangePreventionTime
protected

◆ _difficultyChangePreventionType

DifficultyPreventionChangeType Group::_difficultyChangePreventionType
protected

◆ CustomData

DataMap Group::CustomData

◆ m_bfGroup

Battlefield* Group::m_bfGroup
protected

Referenced by isBFGroup(), and SetBattlefieldGroup().

◆ m_bgGroup

Battleground* Group::m_bgGroup
protected

◆ m_counter

uint32 Group::m_counter
protected

◆ m_dungeonDifficulty

◆ m_groupType

◆ m_guid

◆ m_invitees

◆ m_leaderGuid

◆ m_leaderName

std::string Group::m_leaderName
protected

◆ m_lfgGroupFlags

◆ m_looterGuid

ObjectGuid Group::m_looterGuid
protected

◆ m_lootMethod

◆ m_lootThreshold

◆ m_masterLooterGuid

ObjectGuid Group::m_masterLooterGuid
protected

◆ m_maxEnchantingLevel

uint32 Group::m_maxEnchantingLevel
protected

◆ m_memberMgr

GroupRefMgr Group::m_memberMgr
protected

◆ m_memberSlots

◆ m_raidDifficulty

◆ m_subGroupsCounts

◆ m_targetIcons

◆ RollId


The documentation for this class was generated from the following files: