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, RemoveMethod const &method=GROUP_REMOVEMETHOD_DEFAULT, ObjectGuid kicker=ObjectGuid::Empty, char const *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
 
char const * 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 (std::string const &name)
 
bool IsAssistant (ObjectGuid guid) const
 
PlayerGetInvited (ObjectGuid guid) const
 
PlayerGetInvited (std::string const &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, Roll const &r)
 
void SendLootStartRollToPlayer (uint32 countDown, uint32 mapId, Player *p, bool canNeed, Roll const &r)
 
void SendPendingRollsToPlayer (Player *player, Map *map)
 
void SendLootRoll (ObjectGuid SourceGuid, ObjectGuid TargetGuid, uint8 RollNumber, uint8 RollType, Roll const &r, bool autoPass=false)
 
void SendLootRollWon (ObjectGuid SourceGuid, ObjectGuid TargetGuid, uint8 RollNumber, uint8 RollType, Roll const &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)
 
void AddMemberWithGuid (ObjectGuid guid)
 
void ForcedDisband (bool hideDestroy=false)
 

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
 

Friends

class ToCloud9GroupHooks
 

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 ( )
106{
107 sScriptMgr->OnConstructGroup(this);
108}
@ RAID_DIFFICULTY_10MAN_NORMAL
Definition DBCEnums.h:273
@ DUNGEON_DIFFICULTY_NORMAL
Definition DBCEnums.h:269
@ GROUPTYPE_NORMAL
Definition Group.h:87
@ DIFFICULTY_PREVENTION_CHANGE_NONE
Definition Group.h:141
@ FREE_FOR_ALL
Definition LootMgr.h:58
#define sScriptMgr
Definition ScriptMgr.h:743
@ ITEM_QUALITY_UNCOMMON
Definition SharedDefines.h:319
uint32 m_counter
Definition Group.h:370
Battlefield * m_bfGroup
Definition Group.h:360
uint32 m_maxEnchantingLevel
Definition Group.h:371
DifficultyPreventionChangeType _difficultyChangePreventionType
Definition Group.h:376
std::string m_leaderName
Definition Group.h:356
Battleground * m_bgGroup
Definition Group.h:361
Difficulty m_raidDifficulty
Definition Group.h:359
LootMethod m_lootMethod
Definition Group.h:363
uint8 * m_subGroupsCounts
Definition Group.h:368
Difficulty m_dungeonDifficulty
Definition Group.h:358
ItemQualities m_lootThreshold
Definition Group.h:364
GroupType m_groupType
Definition Group.h:357
uint32 _difficultyChangePreventionTime
Definition Group.h:375

References sScriptMgr.

◆ ~Group()

Group::~Group ( )
111{
112 sScriptMgr->OnDestructGroup(this);
113
114 if (m_bgGroup)
115 {
116 LOG_DEBUG("bg.battleground", "Group::~Group: battleground group being deleted.");
117
118 if (m_bgGroup->GetBgRaid(TEAM_ALLIANCE) == this)
119 {
121 }
122 else if (m_bgGroup->GetBgRaid(TEAM_HORDE) == this)
123 {
124 m_bgGroup->SetBgRaid(TEAM_HORDE, nullptr);
125 }
126 else
127 LOG_ERROR("bg.battleground", "Group::~Group: battleground group is not linked to the correct battleground.");
128 }
129
130 Rolls::iterator itr;
131 while (!RollId.empty())
132 {
133 itr = RollId.begin();
134 Roll* r = *itr;
135 RollId.erase(itr);
136 delete(r);
137 }
138
139 // Sub group counters clean up
140 delete[] m_subGroupsCounts;
141}
#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:487
void SetBgRaid(TeamId teamId, Group *bg_raid)
Definition Battleground.cpp:1858
Rolls RollId
Definition Group.h:367
Definition Group.h:151

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
2396{
2397 // if player is reinvited to group and in the instance - cancel homebind timer
2398 if (!player->FindMap() || !player->FindMap()->IsDungeon())
2399 return;
2400 InstancePlayerBind* bind = sInstanceSaveMgr->PlayerGetBoundInstance(player->GetGUID(), player->FindMap()->GetId(), player->GetDifficulty(player->FindMap()->IsRaid()));
2401 if (bind && bind->save->GetInstanceId() == player->GetInstanceId())
2402 player->m_InstanceValid = true;
2403}
#define sInstanceSaveMgr
Definition InstanceSaveMgr.h:233
uint32 GetInstanceId() const
Definition InstanceSaveMgr.h:62
bool IsDungeon() const
Definition Map.h:299
bool IsRaid() const
Definition Map.h:301
uint32 GetId() const
Definition Map.h:234
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:114
bool m_InstanceValid
Definition Player.h:2484
Difficulty GetDifficulty(bool isRaid) const
Definition Player.h:1947
Map * FindMap() const
Definition Object.h:632
uint32 GetInstanceId() const
Definition Object.h:514
Definition InstanceSaveMgr.h:40
InstanceSave * save
Definition InstanceSaveMgr.h:41

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
2696{
2697 for (member_citerator itr = m_memberSlots.begin(); itr != m_memberSlots.end(); ++itr)
2698 if (itr->guid == Guid)
2699 return itr;
2700 return m_memberSlots.end();
2701}
MemberSlotList m_memberSlots
Definition Group.h:352
MemberSlotList::const_iterator member_citerator
Definition Group.h:189

References m_memberSlots.

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

◆ _getMemberWSlot()

Group::member_witerator Group::_getMemberWSlot ( ObjectGuid  Guid)
protected
2704{
2705 for (member_witerator itr = m_memberSlots.begin(); itr != m_memberSlots.end(); ++itr)
2706 if (itr->guid == Guid)
2707 return itr;
2708 return m_memberSlots.end();
2709}
MemberSlotList::iterator member_witerator
Definition Group.h:192

References m_memberSlots.

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

◆ _homebindIfInstance()

void Group::_homebindIfInstance ( Player player)
protected
2390{
2391 if (player && !player->IsGameMaster() && player->FindMap() && sMapStore.LookupEntry(player->GetMapId())->IsDungeon())
2392 player->m_InstanceValid = false;
2393}
DBCStorage< MapEntry > sMapStore(MapEntryfmt)
bool IsGameMaster() const
Definition Player.h:1178
uint32 GetMapId() const
Definition Position.h:281

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

Referenced by ForcedDisband(), and RemoveMember().

◆ _initRaidSubGroupsCounter()

void Group::_initRaidSubGroupsCounter ( )
protected
2684{
2685 // Sub group counters initialization
2686 if (!m_subGroupsCounts)
2688
2689 memset((void*)m_subGroupsCounts, 0, (MAX_RAID_SUBGROUPS)*sizeof(uint8));
2690
2691 for (member_citerator itr = m_memberSlots.begin(); itr != m_memberSlots.end(); ++itr)
2692 ++m_subGroupsCounts[itr->group];
2693}
std::uint8_t uint8
Definition Define.h:109
#define MAX_RAID_SUBGROUPS
Definition Group.h:46

References m_memberSlots, m_subGroupsCounts, and MAX_RAID_SUBGROUPS.

Referenced by ConvertToRaid(), Create(), LoadGroupFromDB(), and ToCloud9GroupHooks::OnGroupCreated().

◆ AddInvite()

bool Group::AddInvite ( Player player)
356{
357 if (!player || player->GetGroupInvite())
358 return false;
359 Group* group = player->GetGroup();
360 if (group && (group->isBGGroup() || group->isBFGroup()))
361 group = player->GetOriginalGroup();
362 if (group)
363 return false;
364
365 RemoveInvite(player);
366
367 m_invitees.insert(player);
368
369 player->SetGroupInvite(this);
370
371 sScriptMgr->OnGroupInviteMember(this, player->GetGUID());
372
373 return true;
374}
Definition Group.h:177
InvitesList m_invitees
Definition Group.h:354
void RemoveInvite(Player *player)
Definition Group.cpp:386
bool isBGGroup() const
Definition Group.cpp:2482
bool isBFGroup() const
Definition Group.cpp:2487
void SetGroupInvite(Group *group)
Definition Player.h:2515
Group * GetGroup()
Definition Player.h:2516
Group * GetGroupInvite()
Definition Player.h:2514
Group * GetOriginalGroup()
Definition Player.h:2531

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)
377{
378 if (!AddInvite(player))
379 return false;
380
381 m_leaderGuid = player->GetGUID();
382 m_leaderName = player->GetName();
383 return true;
384}
ObjectGuid m_leaderGuid
Definition Group.h:355
bool AddInvite(Player *player)
Definition Group.cpp:355
std::string const & GetName() const
Definition Object.h:529

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:127
uint8 m_lfgGroupFlags
Definition Group.h:372

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:129

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:128

References GROUP_LFG_FLAG_IS_RANDOM_INSTANCE, and m_lfgGroupFlags.

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

◆ AddMember()

bool Group::AddMember ( Player player,
uint8  roles = 0 
)
426{
427 if (!player)
428 return false;
429
430 // Get first not-full group
431 uint8 subGroup = 0;
433 {
434 bool groupFound = false;
435 for (; subGroup < MAX_RAID_SUBGROUPS; ++subGroup)
436 {
437 if (m_subGroupsCounts[subGroup] < MAXGROUPSIZE)
438 {
439 groupFound = true;
440 break;
441 }
442 }
443 // We are raid group and no one slot is free
444 if (!groupFound)
445 return false;
446 }
447
448 MemberSlot member;
449 member.guid = player->GetGUID();
450 member.name = player->GetName();
451 member.group = subGroup;
452 member.flags = 0;
453 member.roles = roles;
454 m_memberSlots.push_back(member);
455
456 if (!isBGGroup() && !isBFGroup())
457 {
458 sCharacterCache->UpdateCharacterGroup(player->GetGUID(), GetGUID());
459 }
460
461 SubGroupCounterIncrease(subGroup);
462
463 player->SetGroupInvite(nullptr);
464 if (player->GetGroup())
465 {
466 if (isBGGroup() || isBFGroup()) // if player is in group and he is being added to BG raid group, then call SetBattlegroundRaid()
467 player->SetBattlegroundOrBattlefieldRaid(this, subGroup);
468 else //if player is in bg raid and we are adding him to normal group, then call SetOriginalGroup()
469 player->SetOriginalGroup(this, subGroup);
470 }
471 else //if player is not in group, then call set group
472 player->SetGroup(this, subGroup);
473
474 // if the same group invites the player back, cancel the homebind timer
476
477 if (!isRaidGroup()) // reset targetIcons for non-raid-groups
478 {
479 for (uint8 i = 0; i < TARGETICONCOUNT; ++i)
480 m_targetIcons[i].Clear();
481 }
482
483 if (!isBGGroup() && !isBFGroup())
484 {
486 stmt->SetData(0, GetGUID().GetCounter());
487 stmt->SetData(1, member.guid.GetCounter());
488 stmt->SetData(2, member.flags);
489 stmt->SetData(3, member.group);
490 stmt->SetData(4, member.roles);
491 CharacterDatabase.Execute(stmt);
492 }
493
494 SendUpdate();
495
496 if (player)
497 {
498 sScriptMgr->OnGroupAddMember(this, player->GetGUID());
499
500 if (!IsLeader(player->GetGUID()) && !isBGGroup() && !isBFGroup())
501 {
503
505 {
507 player->SendDungeonDifficulty(true);
508 }
509 if (player->GetRaidDifficulty() != GetRaidDifficulty())
510 {
512 player->SendRaidDifficulty(true);
513 }
514 }
515 else if (IsLeader(player->GetGUID()) && isLFGGroup()) // pussywizard
516 {
518 }
519
522
523 // quest related GO state dependent from raid membership
524 if (isRaidGroup())
526
527 {
528 // Broadcast new player group member fields to rest of the group
530
531 UpdateData groupData;
532 WorldPacket groupDataPacket;
533
534 // Broadcast group members' fields to player
535 for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next())
536 {
537 if (itr->GetSource() == player) // pussywizard: no check same map, adding members is single threaded
538 {
539 continue;
540 }
541
542 if (Player* itrMember = itr->GetSource())
543 {
544 if (player->HaveAtClient(itrMember))
545 {
546 itrMember->SetFieldNotifyFlag(UF_FLAG_PARTY_MEMBER);
547 itrMember->BuildValuesUpdateBlockForPlayer(&groupData, player);
548 itrMember->RemoveFieldNotifyFlag(UF_FLAG_PARTY_MEMBER);
549 }
550
551 if (itrMember->HaveAtClient(player))
552 {
553 UpdateData newData;
554 WorldPacket newDataPacket;
555 player->BuildValuesUpdateBlockForPlayer(&newData, itrMember);
556 if (newData.HasData())
557 {
558 newData.BuildPacket(newDataPacket);
559 itrMember->SendDirectMessage(&newDataPacket);
560 }
561 }
562 }
563 }
564
565 if (groupData.HasData())
566 {
567 groupData.BuildPacket(groupDataPacket);
568 player->SendDirectMessage(&groupDataPacket);
569 }
570
572 }
573
574 if (m_maxEnchantingLevel < player->GetSkillValue(SKILL_ENCHANTING))
576 }
577
578 return true;
579}
#define sCharacterCache
Definition CharacterCache.h:88
@ CHAR_REP_GROUP_MEMBER
Definition CharacterDatabase.h:286
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition DatabaseEnv.cpp:21
#define TARGETICONCOUNT
Definition Group.h:47
#define MAXGROUPSIZE
Definition Group.h:44
@ GROUP_UPDATE_FULL
Definition Group.h:122
@ INSTANCE_RESET_GROUP_JOIN
Definition Map.h:719
@ 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:2471
bool IsLeader(ObjectGuid guid) const
Definition Group.cpp:2547
void SendUpdate()
Definition Group.cpp:1858
ObjectGuid GetGUID() const
Definition Group.cpp:2512
void _cancelHomebindIfInstance(Player *player)
Definition Group.cpp:2395
Difficulty GetRaidDifficulty() const
Definition Group.cpp:2659
ObjectGuid m_targetIcons[TARGETICONCOUNT]
Definition Group.h:362
void UpdatePlayerOutOfRange(Player *player)
Definition Group.cpp:1940
GroupReference * GetFirstMember()
Definition Group.h:252
void SubGroupCounterIncrease(uint8 subgroup)
Definition Group.cpp:2711
Difficulty GetDungeonDifficulty() const
Definition Group.cpp:2654
bool isRaidGroup() const
Definition Group.cpp:2477
void BuildValuesUpdateBlockForPlayer(UpdateData *data, Player *target)
Definition Object.cpp:250
void RemoveFieldNotifyFlag(uint16 flag)
Definition Object.h:196
void SetFieldNotifyFlag(uint16 flag)
Definition Object.h:195
Definition Player.h:1086
Difficulty GetRaidDifficulty() const
Definition Player.h:1949
void SetOriginalGroup(Group *group, int8 subgroup=-1)
Definition Player.cpp:13412
void SetGroupUpdateFlag(uint32 flag)
Definition Player.h:2522
void SendDirectMessage(WorldPacket const *data) const
Definition Player.cpp:5852
uint16 GetSkillValue(uint32 skill) const
Definition Player.cpp:5610
void SetDungeonDifficulty(Difficulty dungeon_difficulty)
Definition Player.h:1951
void SetGroup(Group *group, int8 subgroup=-1)
Definition Player.cpp:11739
bool HaveAtClient(WorldObject const *u) const
Definition Player.cpp:11586
void UpdateForQuestWorldObjects()
Definition PlayerUpdates.cpp:1798
void SetRaidDifficulty(Difficulty raid_difficulty)
Definition Player.h:1952
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:1948
void SendRaidDifficulty(bool IsInGroup, int32 forcedDifficulty=-1)
Definition PlayerMisc.cpp:177
void SetBattlegroundOrBattlefieldRaid(Group *group, int8 subgroup=-1)
Definition Player.cpp:13384
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 AddMemberWithGuid(), Battlefield::AddOrSetPlayerToCorrectBfGroup(), Battleground::AddOrSetPlayerToCorrectBgGroup(), Arena::AddPlayer(), Create(), group_commandscript::HandleGroupJoinCommand(), and lfg::LFGMgr::MakeNewGroup().

◆ AddMemberWithGuid()

void Group::AddMemberWithGuid ( ObjectGuid  guid)
protected
582{
583 // Idempotent under sidecar event redelivery: never duplicate a MemberSlot.
584 if (IsMember(guid))
585 return;
586
587 if (Player* player = ObjectAccessor::FindPlayer(guid))
588 {
589 AddMember(player);
590 return;
591 }
592
593 // Get first not-full group
594 uint8 subGroup = 0;
596 {
597 bool groupFound = false;
598 for (; subGroup < MAX_RAID_SUBGROUPS; ++subGroup)
599 {
600 if (m_subGroupsCounts[subGroup] < MAXGROUPSIZE)
601 {
602 groupFound = true;
603 break;
604 }
605 }
606 // We are raid group and no one slot is free
607 if (!groupFound)
608 return;
609 }
610
611 MemberSlot member;
612 member.guid = guid;
613 sCharacterCache->GetCharacterNameByGuid(guid, member.name);
614 member.group = subGroup;
615 member.flags = 0;
616 member.roles = 0;
617 m_memberSlots.push_back(member);
618
619 if (!isBGGroup() && !isBFGroup())
620 {
621 sCharacterCache->UpdateCharacterGroup(guid, GetGUID());
622 }
623
624 SubGroupCounterIncrease(subGroup);
625}
bool AddMember(Player *player, uint8 roles=0)
Definition Group.cpp:425
bool IsMember(ObjectGuid guid) const
Definition Group.cpp:2542
Player * FindPlayer(ObjectGuid const guid)
Definition ObjectAccessor.cpp:269

References AddMember(), ObjectAccessor::FindPlayer(), Group::MemberSlot::flags, GetGUID(), Group::MemberSlot::group, Group::MemberSlot::guid, isBFGroup(), isBGGroup(), IsMember(), m_memberSlots, m_subGroupsCounts, MAX_RAID_SUBGROUPS, MAXGROUPSIZE, Group::MemberSlot::name, Group::MemberSlot::roles, sCharacterCache, and SubGroupCounterIncrease().

Referenced by ToCloud9GroupHooks::OnGroupCreated().

◆ BroadcastGroupUpdate()

void Group::BroadcastGroupUpdate ( void  )
2406{
2407 // FG: HACK: force flags update on group leave - for values update hack
2408 // -- not very efficient but safe
2409 for (member_citerator citr = m_memberSlots.begin(); citr != m_memberSlots.end(); ++citr)
2410 {
2411 Player* pp = ObjectAccessor::FindPlayer(citr->guid);
2412 if (pp)
2413 {
2416 LOG_DEBUG("group", "-- Forced group value update for '{}'", pp->GetName());
2417 }
2418 }
2419}
@ UNIT_FIELD_FACTIONTEMPLATE
Definition UpdateFields.h:115
@ UNIT_FIELD_BYTES_2
Definition UpdateFields.h:161
void ForceValuesUpdateAtIndex(uint32)
Definition Object.cpp:2153

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 
)
1957{
1958 for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next())
1959 {
1960 Player* player = itr->GetSource();
1961 if (!player || (ignore && player->GetGUID() == ignore) || (ignorePlayersInBGRaid && player->GetGroup() != this))
1962 continue;
1963
1964 if (group == -1 || itr->getSubGroup() == group)
1965 player->SendDirectMessage(packet);
1966 }
1967}

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)
1970{
1971 for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next())
1972 {
1973 Player* player = itr->GetSource();
1974 if (player)
1975 if (IsLeader(player->GetGUID()) || IsAssistant(player->GetGUID()))
1976 player->SendDirectMessage(packet);
1977 }
1978}
bool IsAssistant(ObjectGuid guid) const
Definition Group.cpp:2561

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 
)
2130{
2131 // check if this group is LFG group
2132 if (isLFGGroup())
2134
2135 BattlemasterListEntry const* bgEntry = sBattlemasterListStore.LookupEntry(bgTemplate->GetBgTypeID());
2136 if (!bgEntry)
2138
2139 // too many players in the group
2140 if (GetMembersCount() > bgEntry->maxGroupSize)
2141 return ERR_BATTLEGROUND_NONE;
2142
2143 // get a player as reference, to compare other players' stats to (arena team id, level bracket, etc.)
2144 Player* reference = GetFirstMember()->GetSource();
2145 if (!reference)
2147
2148 PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bgTemplate->GetMapId(), reference->GetLevel());
2149 if (!bracketEntry)
2151
2152 uint32 arenaTeamId = reference->GetArenaTeamId(arenaSlot);
2153 TeamId teamId = reference->GetTeamId();
2154
2156
2157 // check every member of the group to be able to join
2158 uint32 memberscount = 0;
2159 for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next(), ++memberscount)
2160 {
2161 Player* member = itr->GetSource();
2162
2163 // don't let join with offline members
2164 if (!member)
2166
2167 if (!sScriptMgr->CanGroupJoinBattlegroundQueue(this, member, bgTemplate, MinPlayerCount, isRated, arenaSlot))
2169
2170 // don't allow cross-faction groups to join queue
2171 if (member->GetTeamId() != teamId && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP))
2173
2174 // don't let join rated matches if the arena team id doesn't match
2175 if (isRated && member->GetArenaTeamId(arenaSlot) != arenaTeamId)
2177
2178 // not in the same battleground level braket, don't let join
2179 PvPDifficultyEntry const* memberBracketEntry = GetBattlegroundBracketByLevel(bracketEntry->mapId, member->GetLevel());
2180 if (memberBracketEntry != bracketEntry)
2182
2183 // check for deserter debuff in case not arena queue
2184 if (bgTemplate->GetBgTypeID() != BATTLEGROUND_AA && !member->CanJoinToBattleground(bgTemplate))
2186
2187 // check if someone in party is using dungeon system
2188 lfg::LfgState lfgState = sLFGMgr->GetState(member->GetGUID());
2189 if (lfgState > lfg::LFG_STATE_NONE && (lfgState != lfg::LFG_STATE_QUEUED || !sWorld->getBoolConfig(CONFIG_ALLOW_JOIN_BG_AND_LFG)))
2191
2192 // pussywizard: prevent joining when any member is in bg/arena
2193 if (member->InBattleground())
2195
2196 // pussywizard: check for free slot, this is actually ensured before calling this function, but just in case
2197 if (!member->HasFreeBattlegroundQueueId())
2199
2200 // don't let join if someone from the group is already in that bg queue
2201 if (member->InBattlegroundQueueForBattlegroundQueueType(bgQueueTypeId))
2203
2204 // don't let join if someone from the group is in bg queue random
2205 if (member->InBattlegroundQueueForBattlegroundQueueType(bgQueueTypeIdRandom))
2206 return ERR_IN_RANDOM_BG;
2207
2208 // don't let join to bg queue random if someone from the group is already in bg queue
2209 if (bgTemplate->GetBgTypeID() == BATTLEGROUND_RB && member->InBattlegroundQueue())
2210 return ERR_IN_NON_RANDOM_BG;
2211
2212 // don't let Death Knights join BG queues when they are not allowed to be teleported yet
2213 if (member->IsClass(CLASS_DEATH_KNIGHT, CLASS_CONTEXT_TELEPORT) && member->GetMapId() == MAP_EBON_HOLD && !member->IsGameMaster() && !member->HasSpell(50977))
2215
2216 if (!member->GetBGAccessByLevel(bgTemplate->GetBgTypeID()))
2218
2219 if (member->HasPlayerFlag(PLAYER_FLAGS_NO_PLAY_TIME)) // Assumed to only apply to full restriction rather than partial
2220 return ERR_GROUP_JOIN_BATTLEGROUND_FAIL; // ERR_ARENA_EXPIRED_CAIS does not seem to be a result, so using this error instead
2221 }
2222
2223 // for arenas: check party size is proper
2224 if (bgTemplate->isArena() && memberscount != MinPlayerCount)
2226
2227 //check against other arena team members
2228 if (isRated)
2229 {
2230 ArenaTeam* arenaTeam = sArenaTeamMgr->GetArenaTeamById(arenaTeamId);
2231 for (auto const& itr : arenaTeam->GetMembers())
2232 {
2233 Player* teamMember = ObjectAccessor::FindConnectedPlayer(itr.Guid);
2234 //are they online and not a member of this current group?
2235 if (teamMember && !IsMember(teamMember->GetGUID()))
2236 {
2237 //are they already in queue for a rated arena?
2238 if (teamMember->InBattlegroundQueueForBattlegroundQueueType(bgQueueTypeId))
2239 {
2240 GroupQueueInfo ginfo;
2241 BattlegroundQueue& queue = sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId);
2242 if (queue.GetPlayerGroupInfoData(teamMember->GetGUID(), &ginfo))
2243 {
2244 if (ginfo.IsRated)
2246 }
2247 }
2248 //are they currently in an arena match?
2249 Battleground* bg = teamMember->GetBattleground(false);
2250 if (bg && bg->isRated() && bg->GetMinPlayersPerTeam() == MinPlayerCount)
2252 }
2253 }
2254 }
2255
2256 return GroupJoinBattlegroundResult(bgTemplate->GetBgTypeID());
2257}
@ MAP_EBON_HOLD
Definition AreaDefines.h:260
#define sArenaTeamMgr
Definition ArenaTeamMgr.h:69
#define sBattlegroundMgr
Definition BattlegroundMgr.h:190
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:665
@ PLAYER_FLAGS_NO_PLAY_TIME
Definition Player.h:472
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:132
@ CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP
Definition WorldConfig.h:35
Definition ArenaTeam.h:137
static BattlegroundQueueTypeId BGQueueTypeId(BattlegroundTypeId bgTypeId, uint8 arenaType)
Definition BattlegroundMgr.cpp:685
Definition BattlegroundQueue.h:68
bool GetPlayerGroupInfoData(ObjectGuid guid, GroupQueueInfo *ginfo)
Definition BattlegroundQueue.cpp:400
Definition Battleground.h:303
uint32 GetMinPlayersPerTeam() const
Definition Battleground.cpp:248
bool isRated() const
Definition Battleground.h:414
uint32 GetMembersCount() const
Definition Group.h:254
bool InBattlegroundQueueForBattlegroundQueueType(BattlegroundQueueTypeId bgQueueTypeId) const
Definition Player.cpp:12479
bool InBattleground() const
Definition Player.h:2298
TeamId GetTeamId(bool original=false) const
Definition Player.h:2138
Battleground * GetBattleground(bool create=false) const
Definition Player.cpp:12430
bool InBattlegroundQueue(bool ignoreArena=false) const
Definition Player.cpp:12445
uint32 GetArenaTeamId(uint8 slot) const
Definition Player.cpp:16560
bool HasFreeBattlegroundQueueId() const
Definition Player.cpp:12499
bool IsClass(Classes playerClass, ClassContext context=CLASS_CONTEXT_NONE) const override
Definition Player.cpp:1348
bool CanJoinToBattleground(Battleground const *bg) const
Definition Player.cpp:11529
bool HasSpell(uint32 spell) const override
Definition Player.cpp:4039
bool HasPlayerFlag(PlayerFlags flags) const
Definition Player.h:1125
bool GetBGAccessByLevel(BattlegroundTypeId bgTypeId) const
Definition Player.cpp:12558
FROM * GetSource() const
Definition Reference.h:97
uint8 GetLevel() const
Definition Unit.h:1104
#define sWorld
Definition World.h:318
Player * FindConnectedPlayer(ObjectGuid const guid)
Definition ObjectAccessor.cpp:281
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::HasPlayerFlag(), 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(), PLAYER_FLAGS_NO_PLAY_TIME, sArenaTeamMgr, sBattlegroundMgr, sBattlemasterListStore, sLFGMgr, sScriptMgr, and sWorld.

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

◆ ChangeLeader()

void Group::ChangeLeader ( ObjectGuid  guid)
777{
778 member_witerator slot = _getMemberWSlot(newLeaderGuid);
779
780 if (slot == m_memberSlots.end())
781 return;
782
783 Player* newLeader = ObjectAccessor::FindConnectedPlayer(slot->guid);
784
785 // Don't allow switching leader to offline players
786 if (!newLeader)
787 return;
788
789 if (!isBGGroup() && !isBFGroup())
790 {
791 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
792 // Update the group leader
794 stmt->SetData(0, newLeader->GetGUID().GetCounter());
795 stmt->SetData(1, GetGUID().GetCounter());
796 trans->Append(stmt);
797 CharacterDatabase.CommitTransaction(trans);
798
799 sInstanceSaveMgr->CopyBinds(m_leaderGuid, newLeaderGuid, newLeader);
800 }
801
803 oldLeader->RemovePlayerFlag(PLAYER_FLAGS_GROUP_LEADER);
804
806 m_leaderGuid = newLeader->GetGUID();
807 m_leaderName = newLeader->GetName();
809
811 data << slot->name;
812 BroadcastPacket(&data, true);
813
814 sScriptMgr->OnGroupChangeLeader(this, newLeaderGuid, m_leaderGuid); // This hook should be executed at the end - Not used anywhere in the original core
815}
@ CHAR_UPD_GROUP_LEADER
Definition CharacterDatabase.h:288
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
Definition DatabaseEnvFwd.h:69
@ MEMBER_FLAG_ASSISTANT
Definition Group.h:74
@ 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:1956
void ToggleGroupMemberFlag(member_witerator slot, uint8 flag, bool apply)
Definition Group.cpp:2730
member_witerator _getMemberWSlot(ObjectGuid Guid)
Definition Group.cpp:2703
LowType GetCounter() const
Definition ObjectGuid.h:149
void SetPlayerFlag(PlayerFlags flags)
Definition Player.h:1126
@ 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 
)
2008{
2009 // Only raid groups have sub groups
2010 if (!isRaidGroup())
2011 return;
2012
2013 // Check if player is really in the raid
2014 member_witerator slot = _getMemberWSlot(guid);
2015 if (slot == m_memberSlots.end())
2016 return;
2017
2018 // Abort if the player is already in the target sub group
2019 uint8 prevSubGroup = GetMemberGroup(guid);
2020 if (prevSubGroup == group)
2021 return;
2022
2023 // Update the player slot with the new sub group setting
2024 slot->group = group;
2025
2026 // Increase the counter of the new sub group..
2028
2029 // ..and decrease the counter of the previous one
2030 SubGroupCounterDecrease(prevSubGroup);
2031
2032 // Preserve new sub group in database for non-raid groups
2033 if (!isBGGroup() && !isBFGroup())
2034 {
2036
2037 stmt->SetData(0, group);
2038 stmt->SetData(1, guid.GetCounter());
2039
2040 CharacterDatabase.Execute(stmt);
2041 }
2042
2043 // In case the moved player is online, update the player object with the new sub group references
2044 if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
2045 {
2046 if (player->GetGroup() == this)
2047 player->GetGroupRef().setSubGroup(group);
2048 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
2049 player->GetOriginalGroupRef().setSubGroup(group);
2050 }
2051
2052 // Broadcast the changes to the group
2053 SendUpdate();
2054}
@ CHAR_UPD_GROUP_MEMBER_SUBGROUP
Definition CharacterDatabase.h:290
uint8 GetMemberGroup(ObjectGuid guid) const
Definition Group.cpp:2590
void SubGroupCounterDecrease(uint8 subgroup)
Definition Group.cpp:2717

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 ( )
318{
319 for (member_citerator citr = m_memberSlots.begin(); citr != m_memberSlots.end(); ++citr)
320 if (Player* player = ObjectAccessor::FindPlayer(citr->guid))
321 if (player->GetLevel() < sConfigMgr->GetOption<int32>("Group.Raid.LevelRestriction", 10))
322 return true;
323
324 return false;
325}
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)
296{
298 if (restricted)
299 {
302 }
303
304 if (!isBGGroup() && !isBFGroup())
305 {
307
308 stmt->SetData(0, uint8(m_groupType));
309 stmt->SetData(1, GetGUID().GetCounter());
310
311 CharacterDatabase.Execute(stmt);
312 }
313
314 SendUpdate();
315}
@ CHAR_UPD_GROUP_TYPE
Definition CharacterDatabase.h:289
GroupType
Definition Group.h:86
@ GROUPTYPE_LFG_RESTRICTED
Definition Group.h:91
@ GROUPTYPE_LFG
Definition Group.h:92
@ 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 ( )
328{
330
332
333 if (!sToCloud9Sidecar->ClusterModeEnabled() && !isBGGroup() && !isBFGroup())
334 {
336
337 stmt->SetData(0, uint8(m_groupType));
338 stmt->SetData(1, GetGUID().GetCounter());
339
340 CharacterDatabase.Execute(stmt);
341 }
342
343 SendUpdate();
344
345 // update quest related GO states (quest activity dependent from raid membership)
346 for (member_citerator citr = m_memberSlots.begin(); citr != m_memberSlots.end(); ++citr)
347 if (Player* player = ObjectAccessor::FindPlayer(citr->guid))
348 player->UpdateForQuestWorldObjects();
349
350 // pussywizard: client automatically clears df "eye" near minimap, so remove from raid browser
352 sLFGMgr->LeaveLfg(GetLeaderGUID());
353}
@ GROUPTYPE_RAID
Definition Group.h:89
#define sToCloud9Sidecar
Definition TC9Sidecar.h:76
void _initRaidSubGroupsCounter()
Definition Group.cpp:2683
ObjectGuid GetLeaderGUID() const
Definition Group.cpp:2502
@ 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(), sLFGMgr, and sToCloud9Sidecar.

Referenced by WorldSession::HandleGroupRaidConvertOpcode().

◆ CountRollVote()

bool Group::CountRollVote ( ObjectGuid  playerGUID,
ObjectGuid  Guid,
uint8  Choise 
)
1495{
1496 Rolls::iterator rollI = GetRoll(Guid);
1497 if (rollI == RollId.end())
1498 return false;
1499 Roll* roll = *rollI;
1500
1501 Roll::PlayerVote::iterator itr = roll->playerVote.find(playerGUID);
1502 // this condition means that player joins to the party after roll begins
1503 // Xinef: if choice == MAX_ROLL_TYPE, player was removed from the map in removefromgroup
1504 // Xinef: itr can be invalid as it is not used below
1505 if (Choice < MAX_ROLL_TYPE && itr == roll->playerVote.end())
1506 return false;
1507
1508 if (roll->getLoot())
1509 if (roll->getLoot()->items.empty())
1510 return false;
1511
1512 switch (Choice)
1513 {
1514 case ROLL_PASS: // Player choose pass
1515 SendLootRoll(ObjectGuid::Empty, playerGUID, 128, ROLL_PASS, *roll);
1516 ++roll->totalPass;
1517 itr->second = PASS;
1518 break;
1519 case ROLL_NEED: // player choose Need
1520 SendLootRoll(ObjectGuid::Empty, playerGUID, 0, 0, *roll);
1521 ++roll->totalNeed;
1522 itr->second = NEED;
1523 break;
1524 case ROLL_GREED: // player choose Greed
1525 SendLootRoll(ObjectGuid::Empty, playerGUID, 128, ROLL_GREED, *roll);
1526 ++roll->totalGreed;
1527 itr->second = GREED;
1528 break;
1529 case ROLL_DISENCHANT: // player choose Disenchant
1530 SendLootRoll(ObjectGuid::Empty, playerGUID, 128, ROLL_DISENCHANT, *roll);
1531 ++roll->totalGreed;
1532 itr->second = DISENCHANT;
1533 break;
1534 }
1535
1536 if (roll->totalPass + roll->totalNeed + roll->totalGreed >= roll->totalPlayersRolling)
1537 {
1538 CountTheRoll(rollI);
1539 return true;
1540 }
1541 return false;
1542}
@ PASS
Definition Group.h:51
@ NEED
Definition Group.h:52
@ DISENCHANT
Definition Group.h:54
@ GREED
Definition Group.h:53
@ ROLL_PASS
Definition LootMgr.h:33
@ ROLL_GREED
Definition LootMgr.h:35
@ ROLL_NEED
Definition LootMgr.h:34
@ ROLL_DISENCHANT
Definition LootMgr.h:36
Rolls::iterator GetRoll(ObjectGuid Guid)
Definition Group.cpp:2669
void CountTheRoll(Rolls::iterator roll)
Definition Group.cpp:1590
void SendLootRoll(ObjectGuid SourceGuid, ObjectGuid TargetGuid, uint8 RollNumber, uint8 RollType, Roll const &r, bool autoPass=false)
Definition Group.cpp:1015
static ObjectGuid const Empty
Definition ObjectGuid.h:123
uint8 totalGreed
Definition Group.h:168
uint8 totalPlayersRolling
Definition Group.h:166
uint8 totalNeed
Definition Group.h:167
uint8 totalPass
Definition Group.h:169
Loot * getLoot()
Definition Group.cpp:62
PlayerVote playerVote
Definition Group.h:165
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)
1591{
1592 Roll* roll = *rollI;
1593 if (!roll->isValid()) // is loot already deleted ?
1594 {
1595 RollId.erase(rollI);
1596 delete roll;
1597 return;
1598 }
1599
1600 //end of the roll
1601 if (roll->totalNeed > 0)
1602 {
1603 if (!roll->playerVote.empty())
1604 {
1605 uint8 maxresul = 0;
1606 ObjectGuid maxguid; // pussywizard: start with 0 >_>
1607 Player* player = nullptr;
1608
1609 for (Roll::PlayerVote::const_iterator itr = roll->playerVote.begin(); itr != roll->playerVote.end(); ++itr)
1610 {
1611 if (itr->second != NEED)
1612 continue;
1613
1614 player = ObjectAccessor::FindPlayer(itr->first);
1615 if (!player)
1616 {
1617 --roll->totalNeed;
1618 continue;
1619 }
1620
1621 uint8 randomN = urand(1, 100);
1622 SendLootRoll(ObjectGuid::Empty, itr->first, randomN, ROLL_NEED, *roll);
1623 if (maxresul < randomN)
1624 {
1625 maxguid = itr->first;
1626 maxresul = randomN;
1627 }
1628 }
1629
1630 if (maxguid) // pussywizard: added condition
1631 {
1632 SendLootRollWon(ObjectGuid::Empty, maxguid, maxresul, ROLL_NEED, *roll);
1633 player = ObjectAccessor::FindPlayer(maxguid);
1634
1635 if (player)
1636 {
1638
1639 ItemPosCountVec dest;
1640 LootItem* item = &(roll->itemSlot >= roll->getLoot()->items.size() ? roll->getLoot()->quest_items[roll->itemSlot - roll->getLoot()->items.size()] : roll->getLoot()->items[roll->itemSlot]);
1641 InventoryResult msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, roll->itemid, item->count);
1642 if (msg == EQUIP_ERR_OK)
1643 {
1644 item->is_looted = true;
1645 roll->getLoot()->NotifyItemRemoved(roll->itemSlot);
1646 roll->getLoot()->unlootedCount--;
1647 AllowedLooterSet looters = item->GetAllowedLooters();
1648 Item* _item = player->StoreNewItem(dest, roll->itemid, true, item->randomPropertyId, looters);
1649 if (_item)
1650 sScriptMgr->OnPlayerGroupRollRewardItem(player, _item, item->count, NEED, roll);
1651 player->UpdateLootAchievements(item, roll->getLoot());
1652 }
1653 else
1654 {
1655 uint32 mailOnFull = sWorld->getIntConfig(CONFIG_LFG_MAIL_ITEM_ON_FULL_INVENTORY);
1656 // Only mail when bags are genuinely full. Unique/max-count failures must
1657 // leave the item on the corpse so it can be re-rolled or freely looted.
1659 {
1660 item->is_looted = true;
1661 roll->getLoot()->NotifyItemRemoved(roll->itemSlot);
1662 roll->getLoot()->unlootedCount--;
1663 player->SendEquipError(msg, nullptr, nullptr, roll->itemid);
1664 SendRollWonItemViaMail(player, item, roll->itemid);
1665 }
1666 else
1667 {
1668 item->is_blocked = false;
1669 item->rollWinnerGUID = player->GetGUID();
1670 player->SendEquipError(msg, nullptr, nullptr, roll->itemid);
1671 }
1672 }
1673 }
1674 }
1675 else
1676 roll->totalNeed = 0;
1677 }
1678 }
1679 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
1680 {
1681 if (!roll->playerVote.empty())
1682 {
1683 uint8 maxresul = 0;
1684 ObjectGuid maxguid; // pussywizard: start with 0
1685 Player* player = nullptr;
1686 RollVote rollvote = NOT_VALID;
1687
1688 Roll::PlayerVote::iterator itr;
1689 for (itr = roll->playerVote.begin(); itr != roll->playerVote.end(); ++itr)
1690 {
1691 if (itr->second != GREED && itr->second != DISENCHANT)
1692 continue;
1693
1694 player = ObjectAccessor::FindPlayer(itr->first);
1695 if (!player)
1696 {
1697 --roll->totalGreed;
1698 continue;
1699 }
1700
1701 uint8 randomN = urand(1, 100);
1702 SendLootRoll(ObjectGuid::Empty, itr->first, randomN, itr->second, *roll);
1703 if (maxresul < randomN)
1704 {
1705 maxguid = itr->first;
1706 maxresul = randomN;
1707 rollvote = itr->second;
1708 }
1709 }
1710
1711 if (maxguid) // pussywizard: added condition
1712 {
1713 SendLootRollWon(ObjectGuid::Empty, maxguid, maxresul, rollvote, *roll);
1714 player = ObjectAccessor::FindPlayer(maxguid);
1715
1716 if (player)
1717 {
1719
1720 LootItem* item = &(roll->itemSlot >= roll->getLoot()->items.size() ? roll->getLoot()->quest_items[roll->itemSlot - roll->getLoot()->items.size()] : roll->getLoot()->items[roll->itemSlot]);
1721
1722 if (rollvote == GREED)
1723 {
1724 ItemPosCountVec dest;
1725 InventoryResult msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, roll->itemid, item->count);
1726 if (msg == EQUIP_ERR_OK)
1727 {
1728 item->is_looted = true;
1729 roll->getLoot()->NotifyItemRemoved(roll->itemSlot);
1730 roll->getLoot()->unlootedCount--;
1731 AllowedLooterSet looters = item->GetAllowedLooters();
1732 Item* _item = player->StoreNewItem(dest, roll->itemid, true, item->randomPropertyId, looters);
1733 if (_item)
1734 sScriptMgr->OnPlayerGroupRollRewardItem(player, _item, item->count, GREED, roll);
1735 player->UpdateLootAchievements(item, roll->getLoot());
1736 }
1737 else
1738 {
1739 uint32 mailOnFull = sWorld->getIntConfig(CONFIG_LFG_MAIL_ITEM_ON_FULL_INVENTORY);
1740 // Only mail when bags are genuinely full. Unique/max-count failures must
1741 // leave the item on the corpse so it can be re-rolled or freely looted.
1743 {
1744 item->is_looted = true;
1745 roll->getLoot()->NotifyItemRemoved(roll->itemSlot);
1746 roll->getLoot()->unlootedCount--;
1747 player->SendEquipError(msg, nullptr, nullptr, roll->itemid);
1748 SendRollWonItemViaMail(player, item, roll->itemid);
1749 }
1750 else
1751 {
1752 item->is_blocked = false;
1753 item->rollWinnerGUID = player->GetGUID();
1754 player->SendEquipError(msg, nullptr, nullptr, roll->itemid);
1755 }
1756 }
1757 }
1758 else if (rollvote == DISENCHANT)
1759 {
1760 item->is_looted = true;
1761 roll->getLoot()->NotifyItemRemoved(roll->itemSlot);
1762 roll->getLoot()->unlootedCount--;
1763 ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(roll->itemid);
1765
1766 ItemPosCountVec dest;
1767 InventoryResult msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, roll->itemid, item->count);
1768
1769 if (msg == EQUIP_ERR_OK)
1770 {
1771 player->AutoStoreLoot(pProto->DisenchantID, LootTemplates_Disenchant, true);
1772 }
1773 else
1774 {
1775 Loot loot;
1776 loot.FillLoot(pProto->DisenchantID, LootTemplates_Disenchant, player, true);
1777
1778 uint32 max_slot = loot.GetMaxSlotInLootFor(player);
1779 for(uint32 i = 0; i < max_slot; i++)
1780 {
1781 LootItem* lootItem = loot.LootItemInSlot(i, player);
1782 player->SendEquipError(msg, nullptr, nullptr, lootItem->itemid);
1783 player->SendItemRetrievalMail(lootItem->itemid, lootItem->count);
1784 }
1785 }
1786 }
1787 }
1788 }
1789 else
1790 roll->totalGreed = 0;
1791 }
1792 }
1793 if (roll->totalNeed == 0 && roll->totalGreed == 0) // if, not else, because the totals can be decremented above when a rolling player is offline
1794 {
1795 SendLootAllPassed(*roll);
1796
1797 // remove is_blocked so that the item is lootable by all players
1798 LootItem* item = &(roll->itemSlot >= roll->getLoot()->items.size() ? roll->getLoot()->quest_items[roll->itemSlot - roll->getLoot()->items.size()] : roll->getLoot()->items[roll->itemSlot]);
1799 if (item)
1800 item->is_blocked = false;
1801 }
1802
1803 if (Loot* loot = roll->getLoot(); loot && loot->isLooted() && loot->sourceGameObject)
1804 {
1805 GameObjectTemplate const* goInfo = loot->sourceGameObject->GetGOInfo();
1806 if (goInfo && goInfo->type == GAMEOBJECT_TYPE_CHEST)
1807 {
1808 // Deactivate chest if the last item was rolled in group
1810 }
1811 }
1812
1813 RollId.erase(rollI);
1814 delete roll;
1815}
@ 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:67
@ MAIL_ITEM_ON_FULL_INVENTORY_LFG_ONLY
Definition Group.h:135
@ MAIL_ITEM_ON_FULL_INVENTORY_EVERYWHERE
Definition Group.h:136
RollVote
Definition Group.h:50
@ NOT_VALID
Definition Group.h:56
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:1730
std::vector< ItemPosCount > ItemPosCountVec
Definition Player.h:758
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:391
GameObjectTemplate const * GetGOInfo() const
Definition GameObject.h:136
void SetLootState(LootState s, Unit *unit=nullptr)
Definition GameObject.cpp:2468
void SendLootAllPassed(Roll const &roll)
Definition Group.cpp:1062
void SendLootRollWon(ObjectGuid SourceGuid, ObjectGuid TargetGuid, uint8 RollNumber, uint8 RollType, Roll const &r)
Definition Group.cpp:1039
Definition Item.h:220
Definition ObjectGuid.h:121
void UpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscValue1=0, uint32 miscValue2=0, Unit *unit=nullptr)
Definition PlayerUpdates.cpp:2181
void AutoStoreLoot(uint8 bag, uint8 slot, uint32 loot_id, LootStore const &store, bool broadcast=false)
Definition Player.cpp:13797
void SendItemRetrievalMail(uint32 itemEntry, uint32 count)
Definition PlayerMisc.cpp:432
void UpdateLootAchievements(LootItem *item, Loot *loot)
Definition PlayerUpdates.cpp:2171
Item * StoreNewItem(ItemPosCountVec const &pos, uint32 item, bool update, int32 randomPropertyId=0, bool refund=false)
Definition PlayerStorage.cpp:2606
void SendEquipError(InventoryResult msg, Item *pItem, Item *pItem2=nullptr, uint32 itemid=0)
Definition PlayerStorage.cpp:4098
InventoryResult CanStoreNewItem(uint8 bag, uint8 slot, ItemPosCountVec &dest, uint32 item, uint32 count, uint32 *no_space_count=nullptr) const
Definition Player.h:1304
bool isValid() const
Definition Reference.h:79
uint8 itemSlot
Definition Group.h:170
uint32 itemid
Definition Group.h:160
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
AllowedLooterSet const & GetAllowedLooters() const
Definition LootMgr.h:181
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
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)
144{
145 ObjectGuid leaderGuid = leader->GetGUID();
146 ObjectGuid::LowType lowguid = sGroupMgr->GenerateGroupId();
147
148 m_guid = ObjectGuid::Create<HighGuid::Group>(lowguid);
149 m_leaderGuid = leaderGuid;
150 m_leaderName = leader->GetName();
152
153 if (isBGGroup() || isBFGroup())
155
158
159 if (!isLFGGroup())
161
163 m_looterGuid = leaderGuid;
165
168
169 if (!isBGGroup() && !isBFGroup())
170 {
173
174 // Store group in database
176
177 uint8 index = 0;
178
179 stmt->SetData(index++, lowguid);
180 stmt->SetData(index++, m_leaderGuid.GetCounter());
181 stmt->SetData(index++, uint8(m_lootMethod));
182 stmt->SetData(index++, m_looterGuid.GetCounter());
183 stmt->SetData(index++, uint8(m_lootThreshold));
184 stmt->SetData(index++, m_targetIcons[0].GetRawValue());
185 stmt->SetData(index++, m_targetIcons[1].GetRawValue());
186 stmt->SetData(index++, m_targetIcons[2].GetRawValue());
187 stmt->SetData(index++, m_targetIcons[3].GetRawValue());
188 stmt->SetData(index++, m_targetIcons[4].GetRawValue());
189 stmt->SetData(index++, m_targetIcons[5].GetRawValue());
190 stmt->SetData(index++, m_targetIcons[6].GetRawValue());
191 stmt->SetData(index++, m_targetIcons[7].GetRawValue());
192 stmt->SetData(index++, uint8(m_groupType));
193 stmt->SetData(index++, uint8(m_dungeonDifficulty));
194 stmt->SetData(index++, uint8(m_raidDifficulty));
195 stmt->SetData(index++, m_masterLooterGuid.GetCounter());
196
197 CharacterDatabase.Execute(stmt);
198
199 ASSERT(AddMember(leader)); // If the leader can't be added to a new group because it appears full, something is clearly wrong.
200
201 sScriptMgr->OnCreate(this, leader);
202 }
203 else if (!AddMember(leader))
204 return false;
205
206 return true;
207}
@ CHAR_INS_GROUP
Definition CharacterDatabase.h:285
#define ASSERT
Definition Errors.h:68
#define sGroupMgr
Definition GroupMgr.h:51
@ GROUPTYPE_BGRAID
Definition Group.h:90
@ GROUP_LOOT
Definition LootMgr.h:61
ObjectGuid m_looterGuid
Definition Group.h:365
ObjectGuid m_masterLooterGuid
Definition Group.h:366
ObjectGuid m_guid
Definition Group.h:369
uint32 LowType
Definition ObjectGuid.h:125
void Clear()
Definition ObjectGuid.h:141

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)
914{
915 if (sToCloud9Sidecar->ClusterModeEnabled() && !this->isBFGroup() && !this->isBGGroup())
916 return;
917
918 ForcedDisband(hideDestroy);
919}
void ForcedDisband(bool hideDestroy=false)
Definition Group.cpp:817

References ForcedDisband(), and sToCloud9Sidecar.

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

◆ DoForAllMembers()

void Group::DoForAllMembers ( std::function< void(Player *)> const &  worker)
2750{
2751 for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next())
2752 {
2753 Player* member = itr->GetSource();
2754 if (!member)
2755 continue;
2756
2757 worker(member);
2758 }
2759}

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

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

◆ DoMinimapPing()

void Group::DoMinimapPing ( ObjectGuid  sourceGuid,
float  mapX,
float  mapY 
)
2260{
2262 minimapPing.SourceGuid = sourceGuid;
2263 minimapPing.MapX = mapX;
2264 minimapPing.MapY = mapY;
2265
2266 BroadcastPacket(minimapPing.Write(), true, -1, sourceGuid);
2267}
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)
1546{
1547 for (Rolls::iterator itr = RollId.begin(); itr != RollId.end();)
1548 {
1549 if ((*itr)->getLoot() == pLoot)
1550 {
1551 CountTheRoll(itr); //i don't have to edit player votes, who didn't vote ... he will pass
1552 itr = RollId.begin();
1553 }
1554 else
1555 ++itr;
1556 }
1557}

References CountTheRoll(), and RollId.

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

◆ ForcedDisband()

void Group::ForcedDisband ( bool  hideDestroy = false)
protected
818{
819 sScriptMgr->OnGroupDisband(this);
820
821 Player* player;
822 uint32 instanceId = 0;
823
824 for (member_citerator citr = m_memberSlots.begin(); citr != m_memberSlots.end(); ++citr)
825 {
826 if (!isBGGroup() && !isBFGroup())
827 {
828 sCharacterCache->ClearCharacterGroup(citr->guid);
829 }
830
831 player = ObjectAccessor::FindConnectedPlayer(citr->guid);
832
833 if (player && !instanceId && !isBGGroup() && !isBFGroup())
834 {
835 instanceId = player->GetInstanceId();
836 }
837
838 _homebindIfInstance(player);
839 if (!isBGGroup() && !isBFGroup())
841
842 if (!player)
843 continue;
844
845 //we cannot call _removeMember because it would invalidate member iterator
846 //if we are removing player from battleground raid
847 if (isBGGroup() || isBFGroup())
849 else
850 {
851 //we can remove player who is in battleground from his original group
852 if (player->GetOriginalGroup() == this)
853 player->SetOriginalGroup(nullptr);
854 else
855 player->SetGroup(nullptr);
856 }
857
858 // quest related GO state dependent from raid membership
859 if (isRaidGroup())
861
862 WorldPacket data;
863 if (!hideDestroy)
864 {
866 player->SendDirectMessage(&data);
867 }
868
869 //we already removed player from group and in player->GetGroup() is his original group, send update
870 if (Group* group = player->GetGroup())
871 {
872 group->SendUpdate();
873 }
874 else
875 {
876 data.Initialize(SMSG_GROUP_LIST, 1 + 1 + 1 + 1 + 8 + 4 + 4 + 8);
877 data << uint8(0x10) << uint8(0) << uint8(0) << uint8(0);
878 data << m_guid << uint32(m_counter) << uint32(0) << uint64(0);
879 player->SendDirectMessage(&data);
880 }
881 }
882 RollId.clear();
883 m_memberSlots.clear();
884
886
887 if (!isBGGroup() && !isBFGroup())
888 {
889 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
890
892 stmt->SetData(0, GetGUID().GetCounter());
893 trans->Append(stmt);
894
895 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GROUP_MEMBER_ALL);
896 stmt->SetData(0, GetGUID().GetCounter());
897 trans->Append(stmt);
898
899 CharacterDatabase.CommitTransaction(trans);
900
901 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_LFG_DATA);
902 stmt->SetData(0, GetGUID().GetCounter());
903 CharacterDatabase.Execute(stmt);
904 }
905
906 // Cleaning up instance saved data for gameobjects when a group is disbanded
907 sInstanceSaveMgr->DeleteInstanceSavedData(instanceId);
908
909 sGroupMgr->RemoveGroup(this);
910 delete this;
911}
@ CHAR_DEL_GROUP_MEMBER_ALL
Definition CharacterDatabase.h:383
@ CHAR_DEL_GROUP
Definition CharacterDatabase.h:382
@ CHAR_DEL_LFG_DATA
Definition CharacterDatabase.h:329
std::uint64_t uint64
Definition Define.h:106
@ INSTANCE_RESET_GROUP_LEAVE
Definition Map.h:720
void RemoveAllInvites()
Definition Group.cpp:396
void _homebindIfInstance(Player *player)
Definition Group.cpp:2389
void RemoveFromBattlegroundOrBattlefieldRaid()
Definition Player.cpp:13400
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 Disband().

◆ GetDifficulty()

Difficulty Group::GetDifficulty ( bool  isRaid) const
2650{
2651 return isRaid ? m_raidDifficulty : m_dungeonDifficulty;
2652}

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
2655{
2656 return m_dungeonDifficulty;
2657}

References m_dungeonDifficulty.

Referenced by AddMember().

◆ GetFirstMember() [1/2]

◆ GetFirstMember() [2/2]

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

References GroupRefMgr::getFirst(), and m_memberMgr.

◆ GetGroupType()

GroupType Group::GetGroupType ( ) const
2498{
2499 return m_groupType;
2500}

References m_groupType.

◆ GetGUID()

◆ GetInvited() [1/2]

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

References m_invitees.

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

◆ GetInvited() [2/2]

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

References m_invitees.

◆ GetInviteeCount()

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

References m_invitees.

Referenced by Player::UninviteFromGroup().

◆ GetLeader()

Player * Group::GetLeader ( )

◆ GetLeaderGUID()

◆ GetLeaderName()

char const * Group::GetLeaderName ( ) const
2518{
2519 return m_leaderName.c_str();
2520}

References m_leaderName.

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

◆ GetLooterGuid()

ObjectGuid Group::GetLooterGuid ( ) const
2528{
2529 return m_looterGuid;
2530}

References m_looterGuid.

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

◆ GetLootMethod()

◆ GetLootThreshold()

ItemQualities Group::GetLootThreshold ( ) const
2538{
2539 return m_lootThreshold;
2540}

References m_lootThreshold.

Referenced by Loot::FillLoot().

◆ GetMasterLooterGuid()

ObjectGuid Group::GetMasterLooterGuid ( ) const

◆ GetMemberGroup()

uint8 Group::GetMemberGroup ( ObjectGuid  guid) const
2591{
2592 member_citerator mslot = _getMemberCSlot(guid);
2593 if (mslot == m_memberSlots.end())
2594 return (MAX_RAID_SUBGROUPS + 1);
2595 return mslot->group;
2596}
member_citerator _getMemberCSlot(ObjectGuid Guid) const
Definition Group.cpp:2695

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 ( std::string const &  name)
2553{
2554 for (member_citerator itr = m_memberSlots.begin(); itr != m_memberSlots.end(); ++itr)
2555 if (itr->name == name)
2556 return itr->guid;
2557
2558 return ObjectGuid::Empty;
2559}

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
2660{
2661 return m_raidDifficulty;
2662}

References m_raidDifficulty.

Referenced by AddMember().

◆ GetRoll()

Group::Rolls::iterator Group::GetRoll ( ObjectGuid  Guid)
2670{
2671 Rolls::iterator iter;
2672 for (iter = RollId.begin(); iter != RollId.end(); ++iter)
2673 if ((*iter)->itemGUID == Guid && (*iter)->isValid())
2674 return iter;
2675 return RollId.end();
2676}

References RollId.

Referenced by CountRollVote().

◆ GroupLoot()

void Group::GroupLoot ( Loot loot,
WorldObject pLootedObject 
)
1121{
1122 std::vector<LootItem>::iterator i;
1123 ItemTemplate const* item;
1124 uint8 itemSlot = 0;
1125
1126 for (i = loot->items.begin(); i != loot->items.end(); ++i, ++itemSlot)
1127 {
1128 if (i->freeforall)
1129 continue;
1130
1131 item = sObjectMgr->GetItemTemplate(i->itemid);
1132 if (!item)
1133 {
1134 continue;
1135 }
1136
1137 // roll for over-threshold item if it's one-player loot
1138 if (item->Quality >= uint32(m_lootThreshold))
1139 {
1140 ObjectGuid newitemGUID = ObjectGuid::Create<HighGuid::Item>(sObjectMgr->GetGenerator<HighGuid::Item>().Generate());
1141 Roll* r = new Roll(newitemGUID, *i);
1142
1143 //a vector is filled with only near party members
1144 for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next())
1145 {
1146 Player* member = itr->GetSource();
1147 if (!member || !member->GetSession())
1148 continue;
1149
1150 bool canLoot = member->IsAtLootRewardDistance(pLootedObject);
1151 if (!canLoot && !pLootedObject->GetAllowedLooters().empty())
1152 canLoot = pLootedObject->HasAllowedLooter(member->GetGUID());
1153
1154 if (canLoot)
1155 {
1157
1158 RollVote vote = member->GetPassOnGroupLoot() ? PASS : NOT_EMITED_YET;
1159 if (!CanRollOnItem(*i, member, loot))
1160 {
1161 vote = PASS;
1162 ++r->totalPass;
1163 }
1164
1165 r->playerVote[member->GetGUID()] = vote;
1166 }
1167 }
1168
1169 if (r->totalPlayersRolling > 0)
1170 {
1171 r->setLoot(loot);
1172 r->itemSlot = itemSlot;
1175
1176 loot->items[itemSlot].is_blocked = true;
1177
1178 // If there is any "auto pass", broadcast the pass now.
1179 if (r->totalPass)
1180 {
1181 for (Roll::PlayerVote::const_iterator itr = r->playerVote.begin(); itr != r->playerVote.end(); ++itr)
1182 {
1183 Player* p = ObjectAccessor::FindPlayer(itr->first);
1184 if (!p)
1185 continue;
1186
1187 if (itr->second == PASS)
1188 SendLootRoll(newitemGUID, p->GetGUID(), 128, ROLL_PASS, *r, true);
1189 }
1190 }
1191
1192 if (r->totalPass == r->totalPlayersRolling)
1193 delete r;
1194 else
1195 {
1196 SendLootStartRoll(60000, pLootedObject->GetMapId(), *r);
1197
1198 RollId.push_back(r);
1199
1200 if (Creature* creature = pLootedObject->ToCreature())
1201 {
1202 creature->m_groupLootTimer = 60000;
1203 creature->lootingGroupLowGUID = GetGUID().GetCounter();
1204 }
1205 else if (GameObject* go = pLootedObject->ToGameObject())
1206 {
1207 go->m_groupLootTimer = 60000;
1208 go->lootingGroupLowGUID = GetGUID().GetCounter();
1209 }
1210 }
1211 }
1212 else
1213 delete r;
1214 }
1215 else
1216 i->is_underthreshold = true;
1217 }
1218
1219 for (i = loot->quest_items.begin(); i != loot->quest_items.end(); ++i, ++itemSlot)
1220 {
1221 if (!i->follow_loot_rules)
1222 continue;
1223
1224 item = sObjectMgr->GetItemTemplate(i->itemid);
1225 if (!item)
1226 {
1227 continue;
1228 }
1229
1230 ObjectGuid newitemGUID = ObjectGuid::Create<HighGuid::Item>(sObjectMgr->GetGenerator<HighGuid::Item>().Generate());
1231 Roll* r = new Roll(newitemGUID, *i);
1232
1233 //a vector is filled with only near party members
1234 for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next())
1235 {
1236 Player* member = itr->GetSource();
1237 if (!member || !member->GetSession())
1238 continue;
1239
1240 bool canLoot = member->IsAtLootRewardDistance(pLootedObject);
1241 if (!canLoot && !pLootedObject->GetAllowedLooters().empty())
1242 canLoot = pLootedObject->HasAllowedLooter(member->GetGUID());
1243
1244 if (canLoot)
1245 {
1247
1248 RollVote vote = NOT_EMITED_YET;
1249 if (!CanRollOnItem(*i, member, loot))
1250 {
1251 vote = PASS;
1252 ++r->totalPass;
1253 }
1254 r->playerVote[member->GetGUID()] = vote;
1255 }
1256 }
1257
1258 if (r->totalPlayersRolling > 0)
1259 {
1260 r->setLoot(loot);
1261 r->itemSlot = itemSlot;
1262
1263 loot->quest_items[itemSlot - loot->items.size()].is_blocked = true;
1264
1265 SendLootStartRoll(60000, pLootedObject->GetMapId(), *r);
1266
1267 RollId.push_back(r);
1268
1269 if (Creature* creature = pLootedObject->ToCreature())
1270 {
1271 creature->m_groupLootTimer = 60000;
1272 creature->lootingGroupLowGUID = GetGUID().GetCounter();
1273 }
1274 else if (GameObject* go = pLootedObject->ToGameObject())
1275 {
1276 go->m_groupLootTimer = 60000;
1277 go->lootingGroupLowGUID = GetGUID().GetCounter();
1278 }
1279 }
1280 else
1281 delete r;
1282 }
1283}
bool CanRollOnItem(LootItem const &item, Player const *player, Loot *loot)
Definition Group.cpp:1103
@ NOT_EMITED_YET
Definition Group.h:55
@ ROLL_FLAG_TYPE_DISENCHANT
Definition LootMgr.h:45
Definition Creature.h:47
Definition GameObject.h:120
void SendLootStartRoll(uint32 CountDown, uint32 mapid, Roll const &r)
Definition Group.cpp:925
GameObject * ToGameObject()
Definition Object.h:214
Creature * ToCreature()
Definition Object.h:206
WorldSession * GetSession() const
Definition Player.h:2030
bool IsAtLootRewardDistance(WorldObject const *pRewardSource) const
Definition Player.cpp:13066
bool GetPassOnGroupLoot() const
Definition Player.h:2537
void setLoot(Loot *pLoot)
Definition Group.cpp:57
uint8 rollVoteMask
Definition Group.h:171
bool HasAllowedLooter(ObjectGuid guid) const
Definition Object.cpp:3222
GuidUnorderedSet const & GetAllowedLooters() const
Definition Object.cpp:3232
uint32 Quality
Definition ItemTemplate.h:626
uint32 RequiredDisenchantSkill
Definition ItemTemplate.h:684

References CanRollOnItem(), ItemTemplate::DisenchantID, ObjectAccessor::FindPlayer(), WorldObject::GetAllowedLooters(), ObjectGuid::GetCounter(), GetFirstMember(), GetGUID(), Object::GetGUID(), WorldLocation::GetMapId(), Player::GetPassOnGroupLoot(), Player::GetSession(), WorldObject::HasAllowedLooter(), 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
2493{
2494 return GetMembersCount() > 0;
2495}

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
2665{
2666 return !RollId.empty();
2667}

References RollId.

Referenced by Player::CanUninviteFromGroup().

◆ LinkMember()

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

References LinkedListHead::insertFirst(), and m_memberMgr.

Referenced by GroupReference::targetObjectBuildLink().

◆ LoadGroupFromDB()

bool Group::LoadGroupFromDB ( Field field)
210{
211 ObjectGuid::LowType groupLowGuid = fields[16].Get<uint32>();
212 m_guid = ObjectGuid::Create<HighGuid::Group>(groupLowGuid);
213
214 m_leaderGuid = ObjectGuid::Create<HighGuid::Player>(fields[0].Get<uint32>());
215
216 // group leader not exist
217 if (!sCharacterCache->GetCharacterNameByGuid(m_leaderGuid, m_leaderName))
218 {
219 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
221 stmt->SetData(0, groupLowGuid);
222 trans->Append(stmt);
223 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GROUP_MEMBER_ALL);
224 stmt->SetData(0, groupLowGuid);
225 trans->Append(stmt);
226 CharacterDatabase.CommitTransaction(trans);
227 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_LFG_DATA);
228 stmt->SetData(0, groupLowGuid);
229 CharacterDatabase.Execute(stmt);
230 return false;
231 }
232
233 m_lootMethod = LootMethod(fields[1].Get<uint8>());
234 m_looterGuid = ObjectGuid::Create<HighGuid::Player>(fields[2].Get<uint32>());
235 m_lootThreshold = ItemQualities(fields[3].Get<uint8>());
236
237 for (uint8 i = 0; i < TARGETICONCOUNT; ++i)
238 m_targetIcons[i].Set(fields[4 + i].Get<uint64>());
239
240 m_groupType = GroupType(fields[12].Get<uint8>());
243
244 uint32 diff = fields[13].Get<uint8>();
245 if (diff >= MAX_DUNGEON_DIFFICULTY)
247 else
249
250 uint32 r_diff = fields[14].Get<uint8>();
251 if (r_diff >= MAX_RAID_DIFFICULTY)
253 else
255
256 m_masterLooterGuid = ObjectGuid::Create<HighGuid::Player>(fields[15].Get<uint32>());
257
259 sLFGMgr->_LoadFromDB(fields, GetGUID());
260
261 return true;
262}
#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 
)
265{
266 MemberSlot member;
267 member.guid = ObjectGuid::Create<HighGuid::Player>(guidLow);
268
269 // skip non-existed member
270 if (!sCharacterCache->GetCharacterNameByGuid(member.guid, member.name))
271 {
273 stmt->SetData(0, guidLow);
274 stmt->SetData(1, GetGUID().GetCounter());
275 CharacterDatabase.Execute(stmt);
276 return;
277 }
278
279 member.group = subgroup;
280 member.flags = memberFlags;
281 member.roles = roles;
282
283 m_memberSlots.push_back(member);
284
285 if (!isBGGroup() && !isBFGroup())
286 {
287 sCharacterCache->UpdateCharacterGroup(ObjectGuid(HighGuid::Player, guidLow), GetGUID());
288 }
289
290 SubGroupCounterIncrease(subgroup);
291
292 sLFGMgr->SetupGroupMember(member.guid, GetGUID());
293}
@ CHAR_DEL_GROUP_MEMBER
Definition CharacterDatabase.h:287

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 
)
1441{
1442 LOG_DEBUG("network", "Group::MasterLoot (SMSG_LOOT_MASTER_LIST, 330)");
1443
1444 for (std::vector<LootItem>::iterator i = loot->items.begin(); i != loot->items.end(); ++i)
1445 {
1446 if (i->freeforall)
1447 continue;
1448
1449 i->is_blocked = !i->is_underthreshold;
1450 }
1451
1452 for (std::vector<LootItem>::iterator i = loot->quest_items.begin(); i != loot->quest_items.end(); ++i)
1453 {
1454 if (!i->follow_loot_rules)
1455 continue;
1456
1457 i->is_blocked = !i->is_underthreshold;
1458 }
1459
1460 std::vector<Player*> looters;
1461 bool hasAllowedLooters = !pLootedObject->GetAllowedLooters().empty();
1462 for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next())
1463 {
1464 Player* looter = itr->GetSource();
1465 if (!looter->IsInWorld())
1466 {
1467 continue;
1468 }
1469
1470 bool canLoot = looter->IsAtLootRewardDistance(pLootedObject);
1471 if (!canLoot && hasAllowedLooters)
1472 canLoot = pLootedObject->HasAllowedLooter(looter->GetGUID());
1473
1474 if (canLoot)
1475 {
1476 looters.push_back(looter);
1477 }
1478 }
1479
1480 WorldPacket data(SMSG_LOOT_MASTER_LIST, 1 + looters.size() * (1 + 8));
1481 data << uint8(looters.size());
1482
1483 for (Player* looter : looters)
1484 {
1485 data << looter->GetGUID();
1486 }
1487
1488 for (Player* looter : looters)
1489 {
1490 looter->SendDirectMessage(&data);
1491 }
1492}
bool IsInWorld() const
Definition Object.h:109
@ SMSG_LOOT_MASTER_LIST
Definition Opcodes.h:706

References WorldObject::GetAllowedLooters(), GetFirstMember(), Object::GetGUID(), WorldObject::HasAllowedLooter(), 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 
)
1286{
1287 ItemTemplate const* item;
1288 uint8 itemSlot = 0;
1289 for (std::vector<LootItem>::iterator i = loot->items.begin(); i != loot->items.end(); ++i, ++itemSlot)
1290 {
1291 if (i->freeforall)
1292 continue;
1293
1294 item = sObjectMgr->GetItemTemplate(i->itemid);
1295
1296 //roll for over-threshold item if it's one-player loot
1297 if (item->Quality >= uint32(m_lootThreshold))
1298 {
1299 ObjectGuid newitemGUID = ObjectGuid::Create<HighGuid::Item>(sObjectMgr->GetGenerator<HighGuid::Item>().Generate());
1300 Roll* r = new Roll(newitemGUID, *i);
1301
1302 for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next())
1303 {
1304 Player* playerToRoll = itr->GetSource();
1305 if (!playerToRoll || !playerToRoll->GetSession())
1306 continue;
1307
1308 bool canLoot = playerToRoll->IsAtGroupRewardDistance(lootedObject);
1309 if (!canLoot && !lootedObject->GetAllowedLooters().empty())
1310 canLoot = lootedObject->HasAllowedLooter(playerToRoll->GetGUID());
1311
1312 if (canLoot)
1313 {
1315
1316 RollVote vote = playerToRoll->GetPassOnGroupLoot() ? PASS : NOT_EMITED_YET;
1317 if (!CanRollOnItem(*i, playerToRoll, loot))
1318 {
1319 vote = PASS;
1320 r->totalPass++; // Can't broadcast the pass now. need to wait until all rolling players are known
1321 }
1322
1323 r->playerVote[playerToRoll->GetGUID()] = vote;
1324 }
1325 }
1326
1327 if (r->totalPlayersRolling > 0)
1328 {
1329 r->setLoot(loot);
1330 r->itemSlot = itemSlot;
1333
1335 r->rollVoteMask &= ~ROLL_FLAG_TYPE_NEED;
1336
1337 loot->items[itemSlot].is_blocked = true;
1338
1339 //Broadcast Pass and Send Rollstart
1340 for (Roll::PlayerVote::const_iterator itr = r->playerVote.begin(); itr != r->playerVote.end(); ++itr)
1341 {
1342 Player* p = ObjectAccessor::FindPlayer(itr->first);
1343 if (!p)
1344 continue;
1345
1346 if (itr->second == PASS)
1347 SendLootRoll(newitemGUID, p->GetGUID(), 128, ROLL_PASS, *r);
1348 else
1349 SendLootStartRollToPlayer(60000, lootedObject->GetMapId(), p, p->CanRollForItemInLFG(item, lootedObject) == EQUIP_ERR_OK, *r);
1350 }
1351
1352 RollId.push_back(r);
1353
1354 if (Creature* creature = lootedObject->ToCreature())
1355 {
1356 creature->m_groupLootTimer = 60000;
1357 creature->lootingGroupLowGUID = GetGUID().GetCounter();
1358 }
1359 else if (GameObject* go = lootedObject->ToGameObject())
1360 {
1361 go->m_groupLootTimer = 60000;
1362 go->lootingGroupLowGUID = GetGUID().GetCounter();
1363 }
1364 }
1365 else
1366 delete r;
1367 }
1368 else
1369 i->is_underthreshold = true;
1370 }
1371
1372 for (std::vector<LootItem>::iterator i = loot->quest_items.begin(); i != loot->quest_items.end(); ++i, ++itemSlot)
1373 {
1374 if (!i->follow_loot_rules)
1375 continue;
1376
1377 item = sObjectMgr->GetItemTemplate(i->itemid);
1378 ObjectGuid newitemGUID = ObjectGuid::Create<HighGuid::Item>(sObjectMgr->GetGenerator<HighGuid::Item>().Generate());
1379 Roll* r = new Roll(newitemGUID, *i);
1380
1381 for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next())
1382 {
1383 Player* playerToRoll = itr->GetSource();
1384 if (!playerToRoll || !playerToRoll->GetSession())
1385 continue;
1386
1387 if (playerToRoll->IsAtGroupRewardDistance(lootedObject))
1388 {
1390
1391 RollVote vote = playerToRoll->GetPassOnGroupLoot() ? PASS : NOT_EMITED_YET;
1392 if (!CanRollOnItem(*i, playerToRoll, loot))
1393 {
1394 vote = PASS;
1395 r->totalPass++; // Can't broadcast the pass now. need to wait until all rolling players are known
1396 }
1397
1398 r->playerVote[playerToRoll->GetGUID()] = vote;
1399 }
1400 }
1401
1402 if (r->totalPlayersRolling > 0)
1403 {
1404 r->setLoot(loot);
1405 r->itemSlot = itemSlot;
1406
1407 loot->quest_items[itemSlot - loot->items.size()].is_blocked = true;
1408
1409 //Broadcast Pass and Send Rollstart
1410 for (Roll::PlayerVote::const_iterator itr = r->playerVote.begin(); itr != r->playerVote.end(); ++itr)
1411 {
1412 Player* p = ObjectAccessor::FindPlayer(itr->first);
1413 if (!p)
1414 continue;
1415
1416 if (itr->second == PASS)
1417 SendLootRoll(newitemGUID, p->GetGUID(), 128, ROLL_PASS, *r);
1418 else
1419 SendLootStartRollToPlayer(60000, lootedObject->GetMapId(), p, p->CanRollForItemInLFG(item, lootedObject) == EQUIP_ERR_OK, *r);
1420 }
1421
1422 RollId.push_back(r);
1423
1424 if (Creature* creature = lootedObject->ToCreature())
1425 {
1426 creature->m_groupLootTimer = 60000;
1427 creature->lootingGroupLowGUID = GetGUID().GetCounter();
1428 }
1429 else if (GameObject* go = lootedObject->ToGameObject())
1430 {
1431 go->m_groupLootTimer = 60000;
1432 go->lootingGroupLowGUID = GetGUID().GetCounter();
1433 }
1434 }
1435 else
1436 delete r;
1437 }
1438}
@ 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:993
InventoryResult CanRollForItemInLFG(ItemTemplate const *item, WorldObject const *lootedObject) const
Definition PlayerStorage.cpp:2415
bool IsAtGroupRewardDistance(WorldObject const *pRewardSource) const
Definition Player.cpp:13045
bool HasFlag2(ItemFlags2 flag) const
Definition ItemTemplate.h:826

References Player::CanRollForItemInLFG(), CanRollOnItem(), ItemTemplate::DisenchantID, EQUIP_ERR_OK, ObjectAccessor::FindPlayer(), WorldObject::GetAllowedLooters(), ObjectGuid::GetCounter(), GetFirstMember(), GetGUID(), Object::GetGUID(), WorldLocation::GetMapId(), Player::GetPassOnGroupLoot(), Player::GetSession(), WorldObject::HasAllowedLooter(), 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 ( )
1981{
1982 for (member_citerator citr = m_memberSlots.begin(); citr != m_memberSlots.end(); ++citr)
1983 {
1984 Player* player = ObjectAccessor::FindConnectedPlayer(citr->guid);
1985 if (!player)
1986 {
1988 data << citr->guid;
1989 data << uint8(0);
1990 BroadcastReadyCheck(&data);
1991 }
1992 }
1993}
void BroadcastReadyCheck(WorldPacket const *packet)
Definition Group.cpp:1969
@ 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 ( )
397{
398 for (InvitesList::iterator itr = m_invitees.begin(); itr != m_invitees.end(); ++itr)
399 if (*itr)
400 (*itr)->SetGroupInvite(nullptr);
401
402 m_invitees.clear();
403}

References m_invitees.

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

◆ RemoveInvite()

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

References m_invitees, and Player::SetGroupInvite().

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

◆ RemoveMember()

bool Group::RemoveMember ( ObjectGuid  guid,
RemoveMethod const &  method = GROUP_REMOVEMETHOD_DEFAULT,
ObjectGuid  kicker = ObjectGuid::Empty,
char const *  reason = nullptr 
)
628{
630
631 // LFG group vote kick handled in scripts
632 if (isLFGGroup(true) && method == GROUP_REMOVEMETHOD_KICK)
633 {
634 sLFGMgr->InitBoot(GetGUID(), kicker, guid, std::string(reason ? reason : ""));
635 return m_memberSlots.size() > 0;
636 }
637
638 // remove member and change leader (if need) only if strong more 2 members _before_ member remove (BG/BF allow 1 member group),
639 // except in cluster mode, where this branch is taken for any size: the group
640 // service owns the group lifecycle and local Disband() is a no-op, so always
641 // unlink the removed member here; waiting for the disband event leaves the
642 // last two members with a dangling group pointer whenever that event is lost
643 // (group service restart).
644 if (GetMembersCount() > ((isBGGroup() || isLFGGroup() || isBFGroup()) ? 1u : 2u)
645 || (sToCloud9Sidecar->ClusterModeEnabled() && !isBGGroup() && !isBFGroup()))
646 {
648 if (player)
649 {
650 // Battleground group handling
651 if (isBGGroup() || isBFGroup())
653 else
654 // Regular group
655 {
656 if (player->GetOriginalGroup() == this)
657 player->SetOriginalGroup(nullptr);
658 else
659 player->SetGroup(nullptr);
660
661 // quest related GO state dependent from raid membership
663 }
664
665 // BG/BF groups stay locally owned in cluster mode (see the gates above),
666 // so their removal packets must not be delegated to the group service.
667 if (!sToCloud9Sidecar->ClusterModeEnabled() || isBGGroup() || isBFGroup())
668 {
669 WorldPacket data;
670
671 if (method == GROUP_REMOVEMETHOD_KICK || method == GROUP_REMOVEMETHOD_KICK_LFG)
672 {
674 player->GetSession()->SendPacket(&data);
675 }
676
677 // Do we really need to send this opcode?
678 data.Initialize(SMSG_GROUP_LIST, 1 + 1 + 1 + 1 + 8 + 4 + 4 + 8);
679 data << uint8(0x10) << uint8(0) << uint8(0) << uint8(0);
680 data << m_guid << uint32(m_counter) << uint32(0) << uint64(0);
681 player->GetSession()->SendPacket(&data);
682 }
683 }
684
685 // Remove player from group in DB
686 if (!isBGGroup() && !isBFGroup())
687 {
689 stmt->SetData(0, guid.GetCounter());
690 stmt->SetData(1, GetGUID().GetCounter());
691 CharacterDatabase.Execute(stmt);
692 }
693
694 // Remove player from loot rolls
696
697 // Update subgroups
699 if (slot != m_memberSlots.end())
700 {
701 SubGroupCounterDecrease(slot->group);
702 m_memberSlots.erase(slot);
703
704 if (!isBGGroup() && !isBFGroup())
705 {
706 sCharacterCache->ClearCharacterGroup(guid);
707 }
708 }
709
710 // Reevaluate group enchanter if the leaving player had enchanting skill or the player is offline
711 if (!player || player->GetSkillValue(SKILL_ENCHANTING))
712 {
714 }
715
716 // Pick new leader if necessary
717 bool validLeader = true;
718 if (m_leaderGuid == guid)
719 {
720 validLeader = false;
721 for (member_witerator itr = m_memberSlots.begin(); itr != m_memberSlots.end(); ++itr)
722 {
724 {
725 ChangeLeader(itr->guid);
726 validLeader = true;
727 break;
728 }
729 }
730 }
731
732 _homebindIfInstance(player);
733 if (!isBGGroup() && !isBFGroup())
735
736 sScriptMgr->OnGroupRemoveMember(this, guid, method, kicker, reason);
737
738 SendUpdate();
739
740 if (!validLeader)
741 {
742 // pussywizard: temp do nothing, something causes crashes in MakeNewGroup
743 //Disband();
744 //return false;
745 }
746
747 if (isLFGGroup() && GetMembersCount() == 1)
748 {
750 uint32 mapId = sLFGMgr->GetDungeonMapId(GetGUID());
751 lfg::LfgState state = sLFGMgr->GetState(GetGUID());
752 if (!mapId || !leader || (leader->IsAlive() && leader->GetMapId() != mapId) || state == lfg::LFG_STATE_NONE)
753 {
754 Disband();
755 return false;
756 }
757 }
758
759 if (m_memberMgr.getSize() < ((isLFGGroup() || isBGGroup() || isBFGroup()) ? 1u : 2u))
760 {
761 Disband();
762 return false;
763 }
764
765 return true;
766 }
767 // If group size before player removal <= 2 then disband it
768 else
769 {
770 sScriptMgr->OnGroupRemoveMember(this, guid, method, kicker, reason);
771 Disband();
772 return false;
773 }
774}
@ GROUP_REMOVEMETHOD_KICK_LFG
Definition SharedDefines.h:3846
@ GROUP_REMOVEMETHOD_KICK
Definition SharedDefines.h:3844
void BroadcastGroupUpdate(void)
Definition Group.cpp:2405
void Disband(bool hideDestroy=false)
Definition Group.cpp:913
void ResetMaxEnchantingLevel()
Definition Group.cpp:2421
void ChangeLeader(ObjectGuid guid)
Definition Group.cpp:776
void RemovePlayerFromRolls(ObjectGuid guid)
Definition Group.cpp:1559
uint32 getSize() const
Definition LinkedList.h:115
bool IsAlive() const
Definition Unit.h:1793
void SendPacket(WorldPacket const *packet)
Send a packet to the client.
Definition WorldSession.cpp:303
@ 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(), Player::GetSession(), 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, WorldSession::SendPacket(), SendUpdate(), PreparedStatementBase::SetData(), Player::SetGroup(), Player::SetOriginalGroup(), SKILL_ENCHANTING, sLFGMgr, SMSG_GROUP_LIST, SMSG_GROUP_UNINVITE, sScriptMgr, sToCloud9Sidecar, SubGroupCounterDecrease(), and Player::UpdateForQuestWorldObjects().

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

◆ RemovePlayerFromRolls()

void Group::RemovePlayerFromRolls ( ObjectGuid  guid)
1560{
1561 for (Rolls::iterator it = RollId.begin(); it != RollId.end();)
1562 {
1563 Roll* roll = *it;
1564 Roll::PlayerVote::iterator itr2 = roll->playerVote.find(guid);
1565 if (itr2 == roll->playerVote.end())
1566 {
1567 ++it;
1568 continue;
1569 }
1570
1571 if (itr2->second == GREED || itr2->second == DISENCHANT)
1572 --roll->totalGreed;
1573 else if (itr2->second == NEED)
1574 --roll->totalNeed;
1575 else if (itr2->second == PASS)
1576 --roll->totalPass;
1577
1578 if (itr2->second != NOT_VALID)
1579 --roll->totalPlayersRolling;
1580
1581 roll->playerVote.erase(itr2);
1582
1583 if (CountRollVote(guid, roll->itemGUID, MAX_ROLL_TYPE))
1584 it = RollId.begin();
1585 else
1586 ++it;
1587 }
1588}
@ MAX_ROLL_TYPE
Definition LootMgr.h:37
bool CountRollVote(ObjectGuid playerGUID, ObjectGuid Guid, uint8 Choise)
Definition Group.cpp:1494
ObjectGuid itemGUID
Definition Group.h:159

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)
2724{
2725 for (member_witerator itr = m_memberSlots.begin(); itr != m_memberSlots.end(); ++itr)
2726 if (itr->flags & flag)
2727 itr->flags &= ~flag;
2728}

References m_memberSlots.

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

◆ ResetInstances()

void Group::ResetInstances ( uint8  method,
bool  isRaid,
Player leader 
)
2322{
2323 if (isBGGroup() || isBFGroup() || isLFGGroup())
2324 return;
2325
2326 switch (method)
2327 {
2328 case INSTANCE_RESET_ALL:
2329 {
2330 if (leader->GetDifficulty(false) != DUNGEON_DIFFICULTY_NORMAL)
2331 break;
2332 std::vector<InstanceSave*> toUnbind;
2333 BoundInstancesMap const& m_boundInstances = sInstanceSaveMgr->PlayerGetBoundInstances(leader->GetGUID(), Difficulty(DUNGEON_DIFFICULTY_NORMAL));
2334 for (BoundInstancesMap::const_iterator itr = m_boundInstances.begin(); itr != m_boundInstances.end(); ++itr)
2335 {
2336 InstanceSave* instanceSave = itr->second.save;
2337 MapEntry const* entry = sMapStore.LookupEntry(itr->first);
2338 if (!entry || entry->IsRaid() || !instanceSave->CanReset())
2339 continue;
2340
2341 Map* map = sMapMgr->FindMap(instanceSave->GetMapId(), instanceSave->GetInstanceId());
2342 if (!map || map->ToInstanceMap()->Reset(method))
2343 {
2344 leader->SendResetInstanceSuccess(instanceSave->GetMapId());
2345 toUnbind.push_back(instanceSave);
2346 }
2347 else
2348 {
2349 leader->SendResetInstanceFailed(INSTANCE_RESET_FAILED, instanceSave->GetMapId());
2350 }
2351
2352 sInstanceSaveMgr->DeleteInstanceSavedData(instanceSave->GetInstanceId());
2353 }
2354 for (std::vector<InstanceSave*>::const_iterator itr = toUnbind.begin(); itr != toUnbind.end(); ++itr)
2355 sInstanceSaveMgr->UnbindAllFor(*itr);
2356 }
2357 break;
2359 {
2360 std::vector<InstanceSave*> toUnbind;
2361 BoundInstancesMap const& m_boundInstances = sInstanceSaveMgr->PlayerGetBoundInstances(leader->GetGUID(), leader->GetDifficulty(isRaid));
2362 for (BoundInstancesMap::const_iterator itr = m_boundInstances.begin(); itr != m_boundInstances.end(); ++itr)
2363 {
2364 InstanceSave* instanceSave = itr->second.save;
2365 MapEntry const* entry = sMapStore.LookupEntry(itr->first);
2366 if (!entry || entry->IsRaid() != isRaid || !instanceSave->CanReset())
2367 continue;
2368
2369 Map* map = sMapMgr->FindMap(instanceSave->GetMapId(), instanceSave->GetInstanceId());
2370 if (!map || map->ToInstanceMap()->Reset(method))
2371 {
2372 leader->SendResetInstanceSuccess(instanceSave->GetMapId());
2373 toUnbind.push_back(instanceSave);
2374 }
2375 else
2376 {
2377 leader->SendResetInstanceFailed(INSTANCE_RESET_FAILED, instanceSave->GetMapId());
2378 }
2379
2380 sInstanceSaveMgr->DeleteInstanceSavedData(instanceSave->GetInstanceId());
2381 }
2382 for (std::vector<InstanceSave*>::const_iterator itr = toUnbind.begin(); itr != toUnbind.end(); ++itr)
2383 sInstanceSaveMgr->UnbindAllFor(*itr);
2384 }
2385 break;
2386 }
2387}
std::unordered_map< uint32, InstancePlayerBind > BoundInstancesMap
Definition InstanceSaveMgr.h:47
#define sMapMgr
Definition MapMgr.h:220
@ INSTANCE_RESET_CHANGE_DIFFICULTY
Definition Map.h:717
@ INSTANCE_RESET_ALL
Definition Map.h:716
@ INSTANCE_RESET_FAILED
Definition Player.h:799
bool Reset(uint8 method, GuidList *globalSkipList=nullptr)
Definition Map.cpp:2205
Definition InstanceSaveMgr.h:57
uint32 GetMapId() const
Definition InstanceSaveMgr.h:63
bool CanReset() const
Definition InstanceSaveMgr.h:82
Definition Map.h:168
InstanceMap * ToInstanceMap()
Definition Map.h:390
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 ( )
2422{
2424 Player* pMember = nullptr;
2425 for (member_citerator citr = m_memberSlots.begin(); citr != m_memberSlots.end(); ++citr)
2426 {
2427 pMember = ObjectAccessor::FindPlayer(citr->guid);
2428 if (pMember && pMember->GetSession() && !pMember->GetSession()->IsSocketClosed()
2429 && m_maxEnchantingLevel < pMember->GetSkillValue(SKILL_ENCHANTING))
2430 {
2432 }
2433 }
2434}
bool IsSocketClosed() const
Definition WorldSession.cpp:630

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
2578{
2579 member_citerator mslot1 = _getMemberCSlot(guid1);
2580 if (mslot1 == m_memberSlots.end() || !slot2)
2581 return false;
2582 return (mslot1->group == slot2->group);
2583}

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

◆ SameSubGroup() [2/3]

bool Group::SameSubGroup ( ObjectGuid  guid1,
ObjectGuid  guid2 
) const
2570{
2571 member_citerator mslot2 = _getMemberCSlot(guid2);
2572 if (mslot2 == m_memberSlots.end())
2573 return false;
2574 return SameSubGroup(guid1, &*mslot2);
2575}
bool SameSubGroup(ObjectGuid guid1, ObjectGuid guid2) const
Definition Group.cpp:2569

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
1996{
1997 if (!member1 || !member2)
1998 return false;
1999
2000 if (member1->GetGroup() != this || member2->GetGroup() != this)
2001 return false;
2002 else
2003 return member1->GetSubGroup() == member2->GetSubGroup();
2004}

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

◆ SendLootAllPassed()

void Group::SendLootAllPassed ( Roll const &  roll)
1063{
1064 WorldPacket data(SMSG_LOOT_ALL_PASSED, (8 + 4 + 4 + 4 + 4));
1065 data << roll.itemGUID; // Guid of the item rolled
1066 data << uint32(roll.itemSlot); // Item loot slot
1067 data << uint32(roll.itemid); // The itemEntryId for the item that shall be rolled for
1068 data << uint32(roll.itemRandomPropId); // Item random property ID
1069 data << uint32(roll.itemRandomSuffix); // Item random suffix ID
1070
1071 for (Roll::PlayerVote::const_iterator itr = roll.playerVote.begin(); itr != roll.playerVote.end(); ++itr)
1072 {
1073 Player* player = ObjectAccessor::FindConnectedPlayer(itr->first);
1074 if (!player)
1075 continue;
1076
1077 if (itr->second != NOT_VALID)
1078 player->SendDirectMessage(&data);
1079 }
1080}
@ 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 
)
1084{
1085 ASSERT(creature);
1086
1087 WorldPacket data(SMSG_LOOT_LIST, (8 + 8));
1088 data << creature->GetGUID();
1089
1090 if (GetLootMethod() == MASTER_LOOT && creature->loot.hasOverThresholdItem())
1092 else
1093 data << uint8(0);
1094
1095 if (groupLooter)
1096 data << groupLooter->GetPackGUID();
1097 else
1098 data << uint8(0);
1099
1100 BroadcastPacket(&data, false);
1101}
@ MASTER_LOOT
Definition LootMgr.h:60
Loot loot
Definition Creature.h:231
ObjectGuid GetMasterLooterGuid() const
Definition Group.cpp:2532
LootMethod GetLootMethod() const
Definition Group.cpp:2522
PackedGuid WriteAsPacked() const
Definition ObjectGuid.h:325
@ 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,
Roll const &  r,
bool  autoPass = false 
)
1016{
1017 WorldPacket data(SMSG_LOOT_ROLL, (8 + 4 + 8 + 4 + 4 + 4 + 1 + 1 + 1));
1018 data << sourceGuid; // guid of the item rolled
1019 data << uint32(roll.itemSlot); // slot
1020 data << targetGuid;
1021 data << uint32(roll.itemid); // the itemEntryId for the item that shall be rolled for
1022 data << uint32(roll.itemRandomSuffix); // randomSuffix
1023 data << uint32(roll.itemRandomPropId); // Item random property ID
1024 data << uint8(rollNumber); // 0: "Need for: [item name]" > 127: "you passed on: [item name]" Roll number
1025 data << uint8(rollType); // 0: "Need for: [item name]" 0: "You have selected need for [item name] 1: need roll 2: greed roll
1026 data << uint8(autoPass); // 1: "You automatically passed on: %s because you cannot loot that item."
1027
1028 for (Roll::PlayerVote::const_iterator itr = roll.playerVote.begin(); itr != roll.playerVote.end(); ++itr)
1029 {
1031 if (!p)
1032 continue;
1033
1034 if (itr->second != NOT_VALID)
1035 p->SendDirectMessage(&data);
1036 }
1037}
@ 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,
Roll const &  r 
)
1040{
1041 WorldPacket data(SMSG_LOOT_ROLL_WON, (8 + 4 + 4 + 4 + 4 + 8 + 1 + 1));
1042 data << sourceGuid; // guid of the item rolled
1043 data << uint32(roll.itemSlot); // slot
1044 data << uint32(roll.itemid); // the itemEntryId for the item that shall be rolled for
1045 data << uint32(roll.itemRandomSuffix); // randomSuffix
1046 data << uint32(roll.itemRandomPropId); // Item random property
1047 data << targetGuid; // guid of the player who won.
1048 data << uint8(rollNumber); // rollnumber realted to SMSG_LOOT_ROLL
1049 data << uint8(rollType); // rollType related to SMSG_LOOT_ROLL
1050
1051 for (Roll::PlayerVote::const_iterator itr = roll.playerVote.begin(); itr != roll.playerVote.end(); ++itr)
1052 {
1054 if (!p)
1055 continue;
1056
1057 if (itr->second != NOT_VALID)
1058 p->SendDirectMessage(&data);
1059 }
1060}
@ 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,
Roll const &  r 
)
926{
927 WorldPacket data(SMSG_LOOT_START_ROLL, (8 + 4 + 4 + 4 + 4 + 4 + 4 + 1));
928 data << r.itemGUID; // guid of rolled item
929 data << uint32(mapid); // 3.3.3 mapid
930 data << uint32(r.itemSlot); // itemslot
931 data << uint32(r.itemid); // the itemEntryId for the item that shall be rolled for
932 data << uint32(r.itemRandomSuffix); // randomSuffix
933 data << uint32(r.itemRandomPropId); // item random property ID
934 data << uint32(r.itemCount); // items in stack
935 data << uint32(CountDown); // the countdown time to choose "need" or "greed"
936 data << uint8(r.rollVoteMask); // roll type mask
937
938 for (Roll::PlayerVote::const_iterator itr = r.playerVote.begin(); itr != r.playerVote.end(); ++itr)
939 {
941 if (!p)
942 continue;
943
944 if (itr->second == NOT_EMITED_YET)
945 p->SendDirectMessage(&data);
946 }
947}
@ 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 
)
994{
995 if (!p)
996 return;
997
998 WorldPacket data(SMSG_LOOT_START_ROLL, (8 + 4 + 4 + 4 + 4 + 4 + 4 + 1));
999 data << r.itemGUID; // guid of rolled item
1000 data << uint32(mapId); // 3.3.3 mapid
1001 data << uint32(r.itemSlot); // itemslot
1002 data << uint32(r.itemid); // the itemEntryId for the item that shall be rolled for
1003 data << uint32(r.itemRandomSuffix); // randomSuffix
1004 data << uint32(r.itemRandomPropId); // item random property ID
1005 data << uint32(r.itemCount); // items in stack
1006 data << uint32(countDown); // the countdown time to choose "need" or "greed"
1007 uint8 voteMask = r.rollVoteMask;
1008 if (!canNeed)
1009 voteMask &= ~ROLL_FLAG_TYPE_NEED;
1010 data << uint8(voteMask); // roll type mask
1011
1012 p->SendDirectMessage(&data);
1013}

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(), and SendPendingRollsToPlayer().

◆ SendPendingRollsToPlayer()

void Group::SendPendingRollsToPlayer ( Player player,
Map map 
)
950{
951 for (Roll* roll : RollId)
952 {
953 auto itr = roll->playerVote.find(player->GetGUID());
954 if (itr == roll->playerVote.end())
955 continue;
956
957 if (itr->second != NOT_EMITED_YET)
958 continue;
959
960 Loot* loot = roll->getLoot();
961 if (!loot)
962 continue;
963
964 // Get remaining time from the loot source object
965 uint32 remainingTime = 60000;
966 WorldObject* lootedObject = nullptr;
967 if (GameObject* go = loot->sourceGameObject)
968 {
969 remainingTime = go->m_groupLootTimer;
970 lootedObject = go;
971 }
972 else if (!loot->sourceWorldObjectGUID.IsEmpty())
973 {
974 if (Creature* creature = map->GetCreature(loot->sourceWorldObjectGUID))
975 {
976 remainingTime = creature->m_groupLootTimer;
977 lootedObject = creature;
978 }
979 }
980
981 bool canNeed = true;
983 {
984 ItemTemplate const* proto = sObjectMgr->GetItemTemplate(roll->itemid);
985 if (proto && lootedObject)
986 canNeed = (player->CanRollForItemInLFG(proto, lootedObject) == EQUIP_ERR_OK);
987 }
988
989 SendLootStartRollToPlayer(remainingTime, map->GetId(), player, canNeed, *roll);
990 }
991}
Creature * GetCreature(ObjectGuid const &guid)
Definition Map.cpp:2414
bool IsEmpty() const
Definition ObjectGuid.h:165
Definition Object.h:476
ObjectGuid sourceWorldObjectGUID
Definition LootMgr.h:330

References Player::CanRollForItemInLFG(), EQUIP_ERR_OK, Map::GetCreature(), Object::GetGUID(), Map::GetId(), GetLootMethod(), ObjectGuid::IsEmpty(), NEED_BEFORE_GREED, NOT_EMITED_YET, RollId, SendLootStartRollToPlayer(), sObjectMgr, Loot::sourceGameObject, and Loot::sourceWorldObjectGUID.

◆ SendTargetIconList()

void Group::SendTargetIconList ( WorldSession session)
1839{
1840 if (!session)
1841 return;
1842
1844 data << uint8(1); // list targets
1845
1846 for (uint8 i = 0; i < TARGETICONCOUNT; ++i)
1847 {
1848 if (!m_targetIcons[i])
1849 continue;
1850
1851 data << uint8(i);
1852 data << m_targetIcons[i];
1853 }
1854
1855 session->SendPacket(&data);
1856}
@ MSG_RAID_TARGET_UPDATE
Definition Opcodes.h:831

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

Referenced by WorldSession::HandleRaidTargetUpdateOpcode().

◆ SendUpdate()

void Group::SendUpdate ( )
1859{
1860 if (sToCloud9Sidecar->ClusterModeEnabled() && !this->isBFGroup() && !this->isBGGroup())
1861 {
1862 // Group service responsible for sending these updates.
1863 return;
1864 }
1865
1866 for (member_witerator witr = m_memberSlots.begin(); witr != m_memberSlots.end(); ++witr)
1867 SendUpdateToPlayer(witr->guid, &(*witr));
1868}
void SendUpdateToPlayer(ObjectGuid playerGUID, MemberSlot *slot=nullptr)
Definition Group.cpp:1870

References m_memberSlots, SendUpdateToPlayer(), and sToCloud9Sidecar.

Referenced by AddMember(), Battleground::AddOrSetPlayerToCorrectBgGroup(), ChangeMembersGroup(), ConvertToLFG(), ConvertToRaid(), WorldSession::HandleGroupAssistantLeaderOpcode(), group_commandscript::HandleGroupLeaderCommand(), WorldSession::HandleGroupSetLeaderOpcode(), WorldSession::HandleLootMethodOpcode(), WorldSession::HandlePartyAssignmentOpcode(), WorldSession::LogoutPlayer(), lfg::LFGMgr::MakeNewGroup(), RemoveMember(), SetGroupMemberFlag(), SetLfgRoles(), and UpdateLooterGuid().

◆ SendUpdateToPlayer()

void Group::SendUpdateToPlayer ( ObjectGuid  playerGUID,
MemberSlot slot = nullptr 
)
1871{
1872 Player* player = ObjectAccessor::FindConnectedPlayer(playerGUID);
1873
1874 if (!player || player->GetGroup() != this)
1875 return;
1876
1877 // if MemberSlot wasn't provided
1878 if (!slot)
1879 {
1880 member_witerator witr = _getMemberWSlot(playerGUID);
1881
1882 if (witr == m_memberSlots.end()) // if there is no MemberSlot for such a player
1883 return;
1884
1885 slot = &(*witr);
1886 }
1887
1888 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));
1889 data << uint8(m_groupType); // group type (flags in 3.3)
1890 data << uint8(slot->group);
1891 data << uint8(slot->flags);
1892 data << uint8(slot->roles);
1893 if (isLFGGroup())
1894 {
1895 data << uint8(sLFGMgr->GetState(m_guid) == lfg::LFG_STATE_FINISHED_DUNGEON ? 2 : 0); // FIXME - Dungeon save status? 2 = done
1896 data << uint32(sLFGMgr->GetDungeon(m_guid));
1897 }
1898
1899 data << m_guid;
1900 data << uint32(m_counter++); // 3.3, value increases every time this packet gets sent
1901 data << uint32(GetMembersCount() - 1);
1902 for (member_citerator citr = m_memberSlots.begin(); citr != m_memberSlots.end(); ++citr)
1903 {
1904 if (slot->guid == citr->guid)
1905 continue;
1906
1907 Player* member = ObjectAccessor::FindConnectedPlayer(citr->guid);
1908
1909 uint8 onlineState = (member && !member->GetSession()->PlayerLogout()) ? MEMBER_STATUS_ONLINE : MEMBER_STATUS_OFFLINE;
1910 onlineState = onlineState | ((isBGGroup() || isBFGroup()) ? MEMBER_STATUS_PVP : 0);
1911
1912 data << citr->name;
1913 data << citr->guid; // guid
1914 data << uint8(onlineState); // online-state
1915 data << uint8(citr->group); // groupid
1916 data << uint8(citr->flags); // See enum GroupMemberFlags
1917 data << uint8(citr->roles); // Lfg Roles
1918 }
1919
1920 data << m_leaderGuid; // leader guid
1921
1922 if (GetMembersCount() - 1)
1923 {
1924 data << uint8(m_lootMethod); // loot method
1925
1927 data << m_masterLooterGuid; // master looter guid
1928 else
1929 data << uint64(0); // looter guid
1930
1931 data << uint8(m_lootThreshold); // loot threshold
1932 data << uint8(m_dungeonDifficulty); // Dungeon Difficulty
1933 data << uint8(m_raidDifficulty); // Raid Difficulty
1934 data << uint8(m_raidDifficulty >= RAID_DIFFICULTY_10MAN_HEROIC); // 3.3 Dynamic Raid Difficulty - 0 normal/1 heroic
1935 }
1936
1937 player->SendDirectMessage(&data);
1938}
@ RAID_DIFFICULTY_10MAN_HEROIC
Definition DBCEnums.h:275
@ MEMBER_STATUS_OFFLINE
Definition Group.h:61
@ MEMBER_STATUS_PVP
Definition Group.h:63
@ MEMBER_STATUS_ONLINE
Definition Group.h:62
bool PlayerLogout() const
Definition WorldSession.h:428
@ 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)
2604{
2605 m_bfGroup = bg;
2606}

References m_bfGroup.

Referenced by Battlefield::AddOrSetPlayerToCorrectBfGroup().

◆ SetBattlegroundGroup()

void Group::SetBattlegroundGroup ( Battleground bg)
2599{
2600 m_bgGroup = bg;
2601}

References m_bgGroup.

Referenced by Battleground::SetBgRaid().

◆ SetDifficultyChangePrevention()

◆ SetDungeonDifficulty()

void Group::SetDungeonDifficulty ( Difficulty  difficulty)
2280{
2281 m_dungeonDifficulty = difficulty;
2282 if (!sToCloud9Sidecar->ClusterModeEnabled() && !isBGGroup() && !isBFGroup())
2283 {
2285
2287 stmt->SetData(1, GetGUID().GetCounter());
2288
2289 CharacterDatabase.Execute(stmt);
2290 }
2291
2292 for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next())
2293 {
2294 Player* player = itr->GetSource();
2295 player->SetDungeonDifficulty(difficulty);
2296 player->SendDungeonDifficulty(true);
2297 }
2298}
@ CHAR_UPD_GROUP_DIFFICULTY
Definition CharacterDatabase.h:292

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

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

◆ SetGroupMemberFlag()

void Group::SetGroupMemberFlag ( ObjectGuid  guid,
bool  apply,
GroupMemberFlags  flag 
)
2609{
2610 // Assistants, main assistants and main tanks are only available in raid groups
2611 if (!isRaidGroup())
2612 return;
2613
2614 // Check if player is really in the raid
2615 member_witerator slot = _getMemberWSlot(guid);
2616 if (slot == m_memberSlots.end())
2617 return;
2618
2619 // Do flag specific actions, e.g ensure uniqueness
2620 switch (flag)
2621 {
2623 RemoveUniqueGroupMemberFlag(MEMBER_FLAG_MAINASSIST); // Remove main assist flag from current if any.
2624 break;
2626 RemoveUniqueGroupMemberFlag(MEMBER_FLAG_MAINTANK); // Remove main tank flag from current if any.
2627 break;
2629 break;
2630 default:
2631 return; // This should never happen
2632 }
2633
2634 // Switch the actual flag
2635 ToggleGroupMemberFlag(slot, flag, apply);
2636
2637 // Preserve the new setting in the db
2639
2640 stmt->SetData(0, slot->flags);
2641 stmt->SetData(1, guid.GetCounter());
2642
2643 CharacterDatabase.Execute(stmt);
2644
2645 // Broadcast the changes to the group
2646 SendUpdate();
2647}
@ CHAR_UPD_GROUP_MEMBER_FLAG
Definition CharacterDatabase.h:291
@ MEMBER_FLAG_MAINASSIST
Definition Group.h:76
@ MEMBER_FLAG_MAINTANK
Definition Group.h:75
void RemoveUniqueGroupMemberFlag(GroupMemberFlags flag)
Definition Group.cpp:2723

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 
)
2457{
2458 member_witerator slot = _getMemberWSlot(guid);
2459 if (slot == m_memberSlots.end())
2460 return;
2461
2462 slot->roles = roles;
2463 SendUpdate();
2464}

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

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

◆ SetLooterGuid()

void Group::SetLooterGuid ( ObjectGuid  guid)
2442{
2443 m_looterGuid = guid;
2444}

References m_looterGuid.

Referenced by UpdateLooterGuid().

◆ SetLootMethod()

void Group::SetLootMethod ( LootMethod  method)
2437{
2438 m_lootMethod = method;
2439}

References m_lootMethod.

Referenced by WorldSession::HandleLootMethodOpcode().

◆ SetLootThreshold()

void Group::SetLootThreshold ( ItemQualities  threshold)
2452{
2453 m_lootThreshold = threshold;
2454}

References m_lootThreshold.

Referenced by WorldSession::HandleLootMethodOpcode().

◆ SetMasterLooterGuid()

void Group::SetMasterLooterGuid ( ObjectGuid  guid)
2447{
2448 m_masterLooterGuid = guid;
2449}

References m_masterLooterGuid.

Referenced by WorldSession::HandleLootMethodOpcode().

◆ SetRaidDifficulty()

void Group::SetRaidDifficulty ( Difficulty  difficulty)
2301{
2302 m_raidDifficulty = difficulty;
2303 if (!sToCloud9Sidecar->ClusterModeEnabled() && !isBGGroup() && !isBFGroup())
2304 {
2306
2307 stmt->SetData(0, uint8(m_raidDifficulty));
2308 stmt->SetData(1, GetGUID().GetCounter());
2309
2310 CharacterDatabase.Execute(stmt);
2311 }
2312
2313 for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next())
2314 {
2315 Player* player = itr->GetSource();
2316 player->SetRaidDifficulty(difficulty);
2317 player->SendRaidDifficulty(true);
2318 }
2319}
@ CHAR_UPD_GROUP_RAID_DIFFICULTY
Definition CharacterDatabase.h:293

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

Referenced by WorldSession::HandleSetRaidDifficultyOpcode().

◆ SetTargetIcon()

void Group::SetTargetIcon ( uint8  id,
ObjectGuid  whoGuid,
ObjectGuid  targetGuid 
)
1818{
1819 if (id >= TARGETICONCOUNT)
1820 return;
1821
1822 // clean other icons
1823 if (targetGuid)
1824 for (int i = 0; i < TARGETICONCOUNT; ++i)
1825 if (m_targetIcons[i] == targetGuid)
1827
1828 m_targetIcons[id] = targetGuid;
1829
1830 WorldPacket data(MSG_RAID_TARGET_UPDATE, (1 + 8 + 1 + 8));
1831 data << uint8(0); // set targets
1832 data << whoGuid;
1833 data << uint8(id);
1834 data << targetGuid;
1835 BroadcastPacket(&data, true);
1836}
void SetTargetIcon(uint8 id, ObjectGuid whoGuid, ObjectGuid targetGuid)
Definition Group.cpp:1817

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
2718{
2720 --m_subGroupsCounts[subgroup];
2721}

References m_subGroupsCounts.

Referenced by ChangeMembersGroup(), and RemoveMember().

◆ SubGroupCounterIncrease()

void Group::SubGroupCounterIncrease ( uint8  subgroup)
protected
2712{
2714 ++m_subGroupsCounts[subgroup];
2715}

References m_subGroupsCounts.

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

◆ ToggleGroupMemberFlag()

void Group::ToggleGroupMemberFlag ( member_witerator  slot,
uint8  flag,
bool  apply 
)
protected
2731{
2732 if (apply)
2733 slot->flags |= flag;
2734 else
2735 slot->flags &= ~flag;
2736}

Referenced by ChangeLeader(), and SetGroupMemberFlag().

◆ UpdateLooterGuid()

void Group::UpdateLooterGuid ( WorldObject pLootedObject,
bool  ifneed = false 
)
2068{
2069 // round robin style looting applies for all low
2070 // quality items in each loot method except free for all
2071 if (GetLootMethod() == FREE_FOR_ALL)
2072 return;
2073
2074 ObjectGuid oldLooterGUID = GetLooterGuid();
2075 member_citerator guid_itr = _getMemberCSlot(oldLooterGUID);
2076 if (guid_itr != m_memberSlots.end())
2077 {
2078 if (ifneed)
2079 {
2080 // not update if only update if need and ok
2081 Player* looter = ObjectAccessor::FindPlayer(guid_itr->guid);
2082 if (looter && looter->IsAtLootRewardDistance(pLootedObject))
2083 return;
2084 }
2085 ++guid_itr;
2086 }
2087
2088 // search next after current
2089 Player* pNewLooter = nullptr;
2090 for (member_citerator itr = guid_itr; itr != m_memberSlots.end(); ++itr)
2091 {
2092 if (Player* player = ObjectAccessor::FindPlayer(itr->guid))
2093 if (player->IsAtLootRewardDistance(pLootedObject))
2094 {
2095 pNewLooter = player;
2096 break;
2097 }
2098 }
2099
2100 if (!pNewLooter)
2101 {
2102 // search from start
2103 for (member_citerator itr = m_memberSlots.begin(); itr != guid_itr; ++itr)
2104 {
2105 if (Player* player = ObjectAccessor::FindPlayer(itr->guid))
2106 if (player->IsAtLootRewardDistance(pLootedObject))
2107 {
2108 pNewLooter = player;
2109 break;
2110 }
2111 }
2112 }
2113
2114 if (pNewLooter)
2115 {
2116 if (oldLooterGUID != pNewLooter->GetGUID())
2117 {
2118 SetLooterGuid(pNewLooter->GetGUID());
2119 SendUpdate();
2120 }
2121 }
2122 else
2123 {
2125 SendUpdate();
2126 }
2127}
ObjectGuid GetLooterGuid() const
Definition Group.cpp:2527
void SetLooterGuid(ObjectGuid guid)
Definition Group.cpp:2441

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)
1941{
1942 if (!player || !player->IsInWorld())
1943 return;
1944
1945 WorldPacket data;
1946 player->GetSession()->BuildPartyMemberStatsChangedPacket(player, &data);
1947
1948 for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next())
1949 {
1950 Player* member = itr->GetSource();
1951 if (member && (!member->IsInMap(player) || !member->IsWithinDist(player, member->GetSightRange(player), false)))
1952 member->SendDirectMessage(&data);
1953 }
1954}
float GetSightRange(WorldObject const *target=nullptr) const override
Definition Player.cpp:16634
bool IsWithinDist(WorldObject const *obj, float dist2compare, bool is3D=true, bool incOwnRadius=true, bool incTargetRadius=true) const
Definition Object.cpp:1376
bool IsInMap(WorldObject const *obj) const
Definition Object.cpp:1339
void BuildPartyMemberStatsChangedPacket(Player *player, WorldPacket *data)
Definition GroupHandler.cpp:817

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

Referenced by AddMember().

Friends And Related Symbol Documentation

◆ ToCloud9GroupHooks

friend class ToCloud9GroupHooks
friend

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

◆ m_lootMethod

◆ m_lootThreshold

◆ m_masterLooterGuid

◆ 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: