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

Public Attributes

DataMap CustomData
 

Protected Types

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

Protected Member Functions

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

Protected Attributes

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

Detailed Description

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

Member Typedef Documentation

◆ InvitesList

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

◆ member_citerator

typedef MemberSlotList::const_iterator Group::member_citerator

◆ member_witerator

typedef MemberSlotList::iterator Group::member_witerator
protected

◆ MemberSlotList

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

◆ Rolls

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

Constructor & Destructor Documentation

◆ Group()

Group::Group ( )
73{
74 sScriptMgr->OnConstructGroup(this);
75}
#define sScriptMgr
Definition: ScriptMgr.h:708
@ GROUPTYPE_NORMAL
Definition: Group.h:86
@ DIFFICULTY_PREVENTION_CHANGE_NONE
Definition: Group.h:133
@ FREE_FOR_ALL
Definition: LootMgr.h:59
@ ITEM_QUALITY_UNCOMMON
Definition: SharedDefines.h:331
@ RAID_DIFFICULTY_10MAN_NORMAL
Definition: DBCEnums.h:273
@ DUNGEON_DIFFICULTY_NORMAL
Definition: DBCEnums.h:269
uint32 m_counter
Definition: Group.h:354
Battlefield * m_bfGroup
Definition: Group.h:344
uint32 m_maxEnchantingLevel
Definition: Group.h:355
DifficultyPreventionChangeType _difficultyChangePreventionType
Definition: Group.h:360
std::string m_leaderName
Definition: Group.h:340
Battleground * m_bgGroup
Definition: Group.h:345
Difficulty m_raidDifficulty
Definition: Group.h:343
LootMethod m_lootMethod
Definition: Group.h:347
uint8 * m_subGroupsCounts
Definition: Group.h:352
Difficulty m_dungeonDifficulty
Definition: Group.h:342
ItemQualities m_lootThreshold
Definition: Group.h:348
GroupType m_groupType
Definition: Group.h:341
uint32 _difficultyChangePreventionTime
Definition: Group.h:359

References sScriptMgr.

◆ ~Group()

Group::~Group ( )
78{
79 sScriptMgr->OnDestructGroup(this);
80
81 if (m_bgGroup)
82 {
83 LOG_DEBUG("bg.battleground", "Group::~Group: battleground group being deleted.");
84
85 if (m_bgGroup->GetBgRaid(TEAM_ALLIANCE) == this)
86 {
88 }
89 else if (m_bgGroup->GetBgRaid(TEAM_HORDE) == this)
90 {
92 }
93 else
94 LOG_ERROR("bg.battleground", "Group::~Group: battleground group is not linked to the correct battleground.");
95 }
96
97 Rolls::iterator itr;
98 while (!RollId.empty())
99 {
100 itr = RollId.begin();
101 Roll* r = *itr;
102 RollId.erase(itr);
103 delete(r);
104 }
105
106 // Sub group counters clean up
107 delete[] m_subGroupsCounts;
108}
#define LOG_ERROR(filterType__,...)
Definition: Log.h:156
#define LOG_DEBUG(filterType__,...)
Definition: Log.h:168
@ TEAM_ALLIANCE
Definition: SharedDefines.h:760
@ TEAM_HORDE
Definition: SharedDefines.h:761
Group * GetBgRaid(TeamId teamId) const
Definition: Battleground.h:474
void SetBgRaid(TeamId teamId, Group *bg_raid)
Definition: Battleground.cpp:1807
Definition: Group.h:143
Rolls RollId
Definition: Group.h:351

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
2190{
2191 // if player is reinvited to group and in the instance - cancel homebind timer
2192 if (!player->FindMap() || !player->FindMap()->IsDungeon())
2193 return;
2194 InstancePlayerBind* bind = sInstanceSaveMgr->PlayerGetBoundInstance(player->GetGUID(), player->FindMap()->GetId(), player->GetDifficulty(player->FindMap()->IsRaid()));
2195 if (bind && bind->save->GetInstanceId() == player->GetInstanceId())
2196 player->m_InstanceValid = true;
2197}
#define sInstanceSaveMgr
Definition: InstanceSaveMgr.h:202
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:109
Map * FindMap() const
Definition: Object.h:532
uint32 GetInstanceId() const
Definition: Object.h:443
bool m_InstanceValid
Definition: Player.h:2416
Difficulty GetDifficulty(bool isRaid) const
Definition: Player.h:1900
Definition: InstanceSaveMgr.h:39
InstanceSave * save
Definition: InstanceSaveMgr.h:40
uint32 GetInstanceId() const
Definition: InstanceSaveMgr.h:61
bool IsDungeon() const
Definition: Map.h:448
bool IsRaid() const
Definition: Map.h:450
uint32 GetId() const
Definition: Map.h:379

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
2490{
2491 for (member_citerator itr = m_memberSlots.begin(); itr != m_memberSlots.end(); ++itr)
2492 if (itr->guid == Guid)
2493 return itr;
2494 return m_memberSlots.end();
2495}
MemberSlotList m_memberSlots
Definition: Group.h:336
MemberSlotList::const_iterator member_citerator
Definition: Group.h:180

References m_memberSlots.

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

◆ _getMemberWSlot()

Group::member_witerator Group::_getMemberWSlot ( ObjectGuid  Guid)
protected
2498{
2499 for (member_witerator itr = m_memberSlots.begin(); itr != m_memberSlots.end(); ++itr)
2500 if (itr->guid == Guid)
2501 return itr;
2502 return m_memberSlots.end();
2503}
MemberSlotList::iterator member_witerator
Definition: Group.h:183

References m_memberSlots.

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

◆ _homebindIfInstance()

void Group::_homebindIfInstance ( Player player)
protected
2184{
2185 if (player && !player->IsGameMaster() && player->FindMap() && sMapStore.LookupEntry(player->GetMapId())->IsDungeon())
2186 player->m_InstanceValid = false;
2187}
DBCStorage< MapEntry > sMapStore(MapEntryfmt)
uint32 GetMapId() const
Definition: Position.h:276
bool IsGameMaster() const
Definition: Player.h:1158

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

Referenced by Disband(), and RemoveMember().

◆ _initRaidSubGroupsCounter()

void Group::_initRaidSubGroupsCounter ( )
protected
2478{
2479 // Sub group counters initialization
2480 if (!m_subGroupsCounts)
2482
2483 memset((void*)m_subGroupsCounts, 0, (MAX_RAID_SUBGROUPS)*sizeof(uint8));
2484
2485 for (member_citerator itr = m_memberSlots.begin(); itr != m_memberSlots.end(); ++itr)
2486 ++m_subGroupsCounts[itr->group];
2487}
std::uint8_t uint8
Definition: Define.h:109
#define MAX_RAID_SUBGROUPS
Definition: Group.h:45

References m_memberSlots, m_subGroupsCounts, and MAX_RAID_SUBGROUPS.

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

◆ AddInvite()

bool Group::AddInvite ( Player player)
323{
324 if (!player || player->GetGroupInvite())
325 return false;
326 Group* group = player->GetGroup();
327 if (group && (group->isBGGroup() || group->isBFGroup()))
328 group = player->GetOriginalGroup();
329 if (group)
330 return false;
331
332 RemoveInvite(player);
333
334 m_invitees.insert(player);
335
336 player->SetGroupInvite(this);
337
338 sScriptMgr->OnGroupInviteMember(this, player->GetGUID());
339
340 return true;
341}
void SetGroupInvite(Group *group)
Definition: Player.h:2447
Group * GetGroup()
Definition: Player.h:2448
Group * GetGroupInvite()
Definition: Player.h:2446
Group * GetOriginalGroup()
Definition: Player.h:2463
Definition: Group.h:169
InvitesList m_invitees
Definition: Group.h:338
void RemoveInvite(Player *player)
Definition: Group.cpp:353
bool isBGGroup() const
Definition: Group.cpp:2276
bool isBFGroup() const
Definition: Group.cpp:2281

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)
344{
345 if (!AddInvite(player))
346 return false;
347
348 m_leaderGuid = player->GetGUID();
349 m_leaderName = player->GetName();
350 return true;
351}
std::string const & GetName() const
Definition: Object.h:458
ObjectGuid m_leaderGuid
Definition: Group.h:339
bool AddInvite(Player *player)
Definition: Group.cpp:322

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

Referenced by WorldSession::HandleGroupInviteOpcode().

◆ AddLfgBuffFlag()

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

References GROUP_LFG_FLAG_APPLY_RANDOM_BUFF, and m_lfgGroupFlags.

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

◆ AddLfgHeroicFlag()

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

References GROUP_LFG_FLAG_IS_HEROIC, and m_lfgGroupFlags.

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

◆ AddLfgRandomInstanceFlag()

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

References GROUP_LFG_FLAG_IS_RANDOM_INSTANCE, and m_lfgGroupFlags.

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

◆ AddMember()

bool Group::AddMember ( Player player)
393{
394 if (!player)
395 return false;
396
397 // Get first not-full group
398 uint8 subGroup = 0;
400 {
401 bool groupFound = false;
402 for (; subGroup < MAX_RAID_SUBGROUPS; ++subGroup)
403 {
404 if (m_subGroupsCounts[subGroup] < MAXGROUPSIZE)
405 {
406 groupFound = true;
407 break;
408 }
409 }
410 // We are raid group and no one slot is free
411 if (!groupFound)
412 return false;
413 }
414
415 MemberSlot member;
416 member.guid = player->GetGUID();
417 member.name = player->GetName();
418 member.group = subGroup;
419 member.flags = 0;
420 member.roles = 0;
421 m_memberSlots.push_back(member);
422
423 if (!isBGGroup() && !isBFGroup())
424 {
425 sCharacterCache->UpdateCharacterGroup(player->GetGUID(), GetGUID());
426 }
427
428 SubGroupCounterIncrease(subGroup);
429
430 player->SetGroupInvite(nullptr);
431 if (player->GetGroup())
432 {
433 if (isBGGroup() || isBFGroup()) // if player is in group and he is being added to BG raid group, then call SetBattlegroundRaid()
434 player->SetBattlegroundOrBattlefieldRaid(this, subGroup);
435 else //if player is in bg raid and we are adding him to normal group, then call SetOriginalGroup()
436 player->SetOriginalGroup(this, subGroup);
437 }
438 else //if player is not in group, then call set group
439 player->SetGroup(this, subGroup);
440
441 // if the same group invites the player back, cancel the homebind timer
443
444 if (!isRaidGroup()) // reset targetIcons for non-raid-groups
445 {
446 for (uint8 i = 0; i < TARGETICONCOUNT; ++i)
447 m_targetIcons[i].Clear();
448 }
449
450 if (!isBGGroup() && !isBFGroup())
451 {
453 stmt->SetData(0, GetGUID().GetCounter());
454 stmt->SetData(1, member.guid.GetCounter());
455 stmt->SetData(2, member.flags);
456 stmt->SetData(3, member.group);
457 stmt->SetData(4, member.roles);
458 CharacterDatabase.Execute(stmt);
459 }
460
461 SendUpdate();
462
463 if (player)
464 {
465 sScriptMgr->OnGroupAddMember(this, player->GetGUID());
466
467 if (!IsLeader(player->GetGUID()) && !isBGGroup() && !isBFGroup())
468 {
470
472 {
474 player->SendDungeonDifficulty(true);
475 }
476 if (player->GetRaidDifficulty() != GetRaidDifficulty())
477 {
479 player->SendRaidDifficulty(true);
480 }
481 }
482 else if (IsLeader(player->GetGUID()) && isLFGGroup()) // pussywizard
483 {
485 }
486
489
490 // quest related GO state dependent from raid membership
491 if (isRaidGroup())
493
494 {
495 // Broadcast new player group member fields to rest of the group
497
498 UpdateData groupData;
499 WorldPacket groupDataPacket;
500
501 // Broadcast group members' fields to player
502 for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next())
503 {
504 if (itr->GetSource() == player) // pussywizard: no check same map, adding members is single threaded
505 {
506 continue;
507 }
508
509 if (Player* itrMember = itr->GetSource())
510 {
511 if (player->HaveAtClient(itrMember))
512 {
513 itrMember->SetFieldNotifyFlag(UF_FLAG_PARTY_MEMBER);
514 itrMember->BuildValuesUpdateBlockForPlayer(&groupData, player);
515 itrMember->RemoveFieldNotifyFlag(UF_FLAG_PARTY_MEMBER);
516 }
517
518 if (itrMember->HaveAtClient(player))
519 {
520 UpdateData newData;
521 WorldPacket newDataPacket;
522 player->BuildValuesUpdateBlockForPlayer(&newData, itrMember);
523 if (newData.HasData())
524 {
525 newData.BuildPacket(newDataPacket);
526 itrMember->SendDirectMessage(&newDataPacket);
527 }
528 }
529 }
530 }
531
532 if (groupData.HasData())
533 {
534 groupData.BuildPacket(groupDataPacket);
535 player->SendDirectMessage(&groupDataPacket);
536 }
537
539 }
540
541 if (m_maxEnchantingLevel < player->GetSkillValue(SKILL_ENCHANTING))
543 }
544
545 return true;
546}
@ INSTANCE_RESET_GROUP_JOIN
Definition: Map.h:814
#define TARGETICONCOUNT
Definition: Group.h:46
#define MAXGROUPSIZE
Definition: Group.h:43
@ GROUP_UPDATE_FULL
Definition: Group.h:121
#define sCharacterCache
Definition: CharacterCache.h:83
@ UF_FLAG_PARTY_MEMBER
Definition: UpdateFieldFlags.h:33
@ CHAR_REP_GROUP_MEMBER
Definition: CharacterDatabase.h:282
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
@ SKILL_ENCHANTING
Definition: SharedDefines.h:2954
Definition: PreparedStatement.h:158
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition: PreparedStatement.h:78
void BuildValuesUpdateBlockForPlayer(UpdateData *data, Player *target)
Definition: Object.cpp:257
void RemoveFieldNotifyFlag(uint16 flag)
Definition: Object.h:192
void SetFieldNotifyFlag(uint16 flag)
Definition: Object.h:191
Definition: UpdateData.h:52
bool HasData() const
Definition: UpdateData.h:60
bool BuildPacket(WorldPacket &packet)
Definition: UpdateData.cpp:48
Definition: Player.h:1064
Difficulty GetRaidDifficulty() const
Definition: Player.h:1902
void SetOriginalGroup(Group *group, int8 subgroup=-1)
Definition: Player.cpp:13111
void SetGroupUpdateFlag(uint32 flag)
Definition: Player.h:2454
void SendDirectMessage(WorldPacket const *data) const
Definition: Player.cpp:5692
uint16 GetSkillValue(uint32 skill) const
Definition: Player.cpp:5437
void SetDungeonDifficulty(Difficulty dungeon_difficulty)
Definition: Player.h:1904
void SetGroup(Group *group, int8 subgroup=-1)
Definition: Player.cpp:11559
bool HaveAtClient(WorldObject const *u) const
Definition: Player.cpp:11408
void UpdateForQuestWorldObjects()
Definition: PlayerUpdates.cpp:1742
void SetRaidDifficulty(Difficulty raid_difficulty)
Definition: Player.h:1905
void SendDungeonDifficulty(bool IsInGroup)
Definition: PlayerMisc.cpp:167
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:195
Difficulty GetDungeonDifficulty() const
Definition: Player.h:1901
void SendRaidDifficulty(bool IsInGroup, int32 forcedDifficulty=-1)
Definition: PlayerMisc.cpp:177
void SetBattlegroundOrBattlefieldRaid(Group *group, int8 subgroup=-1)
Definition: Player.cpp:13083
bool isLFGGroup(bool restricted=false) const
Definition: Group.cpp:2265
bool IsLeader(ObjectGuid guid) const
Definition: Group.cpp:2341
void SendUpdate()
Definition: Group.cpp:1665
ObjectGuid GetGUID() const
Definition: Group.cpp:2306
void _cancelHomebindIfInstance(Player *player)
Definition: Group.cpp:2189
Difficulty GetRaidDifficulty() const
Definition: Group.cpp:2453
ObjectGuid m_targetIcons[TARGETICONCOUNT]
Definition: Group.h:346
void UpdatePlayerOutOfRange(Player *player)
Definition: Group.cpp:1741
GroupReference * GetFirstMember()
Definition: Group.h:243
void SubGroupCounterIncrease(uint8 subgroup)
Definition: Group.cpp:2505
Difficulty GetDungeonDifficulty() const
Definition: Group.cpp:2448
bool isRaidGroup() const
Definition: Group.cpp:2271
Definition: GroupReference.h:27
GroupReference * next()
Definition: GroupReference.h:36
Definition: WorldPacket.h:27

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

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

◆ BroadcastGroupUpdate()

void Group::BroadcastGroupUpdate ( void  )
2200{
2201 // FG: HACK: force flags update on group leave - for values update hack
2202 // -- not very efficient but safe
2203 for (member_citerator citr = m_memberSlots.begin(); citr != m_memberSlots.end(); ++citr)
2204 {
2205 Player* pp = ObjectAccessor::FindPlayer(citr->guid);
2206 if (pp)
2207 {
2210 LOG_DEBUG("group", "-- Forced group value update for '{}'", pp->GetName());
2211 }
2212 }
2213}
@ UNIT_FIELD_FACTIONTEMPLATE
Definition: UpdateFields.h:115
@ UNIT_FIELD_BYTES_2
Definition: UpdateFields.h:161
Player * FindPlayer(ObjectGuid const guid)
Definition: ObjectAccessor.cpp:248
void ForceValuesUpdateAtIndex(uint32)
Definition: Object.cpp:2067

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 
)
1758{
1759 for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next())
1760 {
1761 Player* player = itr->GetSource();
1762 if (!player || (ignore && player->GetGUID() == ignore) || (ignorePlayersInBGRaid && player->GetGroup() != this))
1763 continue;
1764
1765 if (group == -1 || itr->getSubGroup() == group)
1766 player->GetSession()->SendPacket(packet);
1767 }
1768}
WorldSession * GetSession() const
Definition: Player.h:1978
void SendPacket(WorldPacket const *packet)
Send a packet to the client.
Definition: WorldSession.cpp:214

References GetFirstMember(), Player::GetGroup(), Object::GetGUID(), Player::GetSession(), GroupReference::next(), and WorldSession::SendPacket().

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

◆ BroadcastReadyCheck()

void Group::BroadcastReadyCheck ( WorldPacket const *  packet)
1771{
1772 for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next())
1773 {
1774 Player* player = itr->GetSource();
1775 if (player)
1776 if (IsLeader(player->GetGUID()) || IsAssistant(player->GetGUID()))
1777 player->GetSession()->SendPacket(packet);
1778 }
1779}
bool IsAssistant(ObjectGuid guid) const
Definition: Group.cpp:2355

References GetFirstMember(), Object::GetGUID(), Player::GetSession(), IsAssistant(), IsLeader(), GroupReference::next(), and WorldSession::SendPacket().

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

◆ CanJoinBattlegroundQueue()

GroupJoinBattlegroundResult Group::CanJoinBattlegroundQueue ( Battleground const *  bgTemplate,
BattlegroundQueueTypeId  bgQueueTypeId,
uint32  MinPlayerCount,
uint32  MaxPlayerCount,
bool  isRated,
uint32  arenaSlot 
)
1931{
1932 // check if this group is LFG group
1933 if (isLFGGroup())
1935
1936 BattlemasterListEntry const* bgEntry = sBattlemasterListStore.LookupEntry(bgTemplate->GetBgTypeID());
1937 if (!bgEntry)
1939
1940 // too many players in the group
1941 if (GetMembersCount() > bgEntry->maxGroupSize)
1942 return ERR_BATTLEGROUND_NONE;
1943
1944 // get a player as reference, to compare other players' stats to (arena team id, level bracket, etc.)
1945 Player* reference = GetFirstMember()->GetSource();
1946 if (!reference)
1948
1949 PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bgTemplate->GetMapId(), reference->GetLevel());
1950 if (!bracketEntry)
1952
1953 uint32 arenaTeamId = reference->GetArenaTeamId(arenaSlot);
1954 TeamId teamId = reference->GetTeamId();
1955
1957
1958 // check every member of the group to be able to join
1959 uint32 memberscount = 0;
1960 for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next(), ++memberscount)
1961 {
1962 Player* member = itr->GetSource();
1963
1964 // don't let join with offline members
1965 if (!member)
1967
1968 if (!sScriptMgr->CanGroupJoinBattlegroundQueue(this, member, bgTemplate, MinPlayerCount, isRated, arenaSlot))
1970
1971 // don't allow cross-faction groups to join queue
1972 if (member->GetTeamId() != teamId && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP))
1974
1975 // don't let join rated matches if the arena team id doesn't match
1976 if (isRated && member->GetArenaTeamId(arenaSlot) != arenaTeamId)
1978
1979 // not in the same battleground level braket, don't let join
1980 PvPDifficultyEntry const* memberBracketEntry = GetBattlegroundBracketByLevel(bracketEntry->mapId, member->GetLevel());
1981 if (memberBracketEntry != bracketEntry)
1983
1984 // check for deserter debuff in case not arena queue
1985 if (bgTemplate->GetBgTypeID() != BATTLEGROUND_AA && !member->CanJoinToBattleground())
1987
1988 // check if someone in party is using dungeon system
1989 lfg::LfgState lfgState = sLFGMgr->GetState(member->GetGUID());
1990 if (lfgState > lfg::LFG_STATE_NONE && (lfgState != lfg::LFG_STATE_QUEUED || !sWorld->getBoolConfig(CONFIG_ALLOW_JOIN_BG_AND_LFG)))
1991 {
1993 }
1994
1995 // pussywizard: prevent joining when any member is in bg/arena
1996 if (member->InBattleground())
1998
1999 // pussywizard: check for free slot, this is actually ensured before calling this function, but just in case
2000 if (!member->HasFreeBattlegroundQueueId())
2002
2003 // don't let join if someone from the group is already in that bg queue
2004 if (member->InBattlegroundQueueForBattlegroundQueueType(bgQueueTypeId))
2005 {
2007 }
2008
2009 // don't let join if someone from the group is in bg queue random
2010 if (member->InBattlegroundQueueForBattlegroundQueueType(bgQueueTypeIdRandom))
2011 return ERR_IN_RANDOM_BG;
2012
2013 // don't let join to bg queue random if someone from the group is already in bg queue
2014 if (bgTemplate->GetBgTypeID() == BATTLEGROUND_RB && member->InBattlegroundQueue())
2015 return ERR_IN_NON_RANDOM_BG;
2016
2017 // don't let Death Knights join BG queues when they are not allowed to be teleported yet
2018 if (member->IsClass(CLASS_DEATH_KNIGHT, CLASS_CONTEXT_TELEPORT) && member->GetMapId() == 609 && !member->IsGameMaster() && !member->HasSpell(50977))
2020
2021 if (!member->GetBGAccessByLevel(bgTemplate->GetBgTypeID()))
2022 {
2024 }
2025 }
2026
2027 // for arenas: check party size is proper
2028 if (bgTemplate->isArena() && memberscount != MinPlayerCount)
2030
2031 //check against other arena team members
2032 if (isRated)
2033 {
2034 ArenaTeam* arenaTeam = sArenaTeamMgr->GetArenaTeamById(arenaTeamId);
2035 for (auto const& itr : arenaTeam->GetMembers())
2036 {
2037 Player* teamMember = ObjectAccessor::FindConnectedPlayer(itr.Guid);
2038 //are they online and not a member of this current group?
2039 if (teamMember && !IsMember(teamMember->GetGUID()))
2040 {
2041 //are they already in queue for a rated arena?
2042 if (teamMember->InBattlegroundQueueForBattlegroundQueueType(bgQueueTypeId))
2043 {
2044 GroupQueueInfo ginfo;
2045 BattlegroundQueue& queue = sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId);
2046 if (queue.GetPlayerGroupInfoData(teamMember->GetGUID(), &ginfo))
2047 {
2048 if (ginfo.IsRated)
2050 }
2051 }
2052 //are they currently in an arena match?
2053 Battleground* bg = teamMember->GetBattleground(false);
2054 if (bg && bg->isRated() && bg->GetMinPlayersPerTeam() == MinPlayerCount)
2056 }
2057 }
2058 }
2059
2060 return GroupJoinBattlegroundResult(bgTemplate->GetBgTypeID());
2061}
std::uint32_t uint32
Definition: Define.h:107
#define sArenaTeamMgr
Definition: ArenaTeamMgr.h:67
#define sBattlegroundMgr
Definition: BattlegroundMgr.h:188
#define sLFGMgr
Definition: LFGMgr.h:641
DBCStorage< BattlemasterListEntry > sBattlemasterListStore(BattlemasterListEntryfmt)
PvPDifficultyEntry const * GetBattlegroundBracketByLevel(uint32 mapid, uint32 level)
Definition: DBCStores.cpp:793
@ CONFIG_ALLOW_JOIN_BG_AND_LFG
Definition: IWorld.h:177
@ CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP
Definition: IWorld.h:80
@ CLASS_CONTEXT_TELEPORT
Definition: UnitDefines.h:207
GroupJoinBattlegroundResult
Definition: SharedDefines.h:3635
@ ERR_BATTLEGROUND_JOIN_TIMED_OUT
Definition: SharedDefines.h:3648
@ ERR_BATTLEGROUND_JOIN_FAILED
Definition: SharedDefines.h:3649
@ ERR_LFG_CANT_USE_BATTLEGROUND
Definition: SharedDefines.h:3650
@ ERR_IN_NON_RANDOM_BG
Definition: SharedDefines.h:3652
@ ERR_BATTLEGROUND_NONE
Definition: SharedDefines.h:3638
@ ERR_GROUP_JOIN_BATTLEGROUND_DESERTERS
Definition: SharedDefines.h:3639
@ ERR_ARENA_TEAM_PARTY_SIZE
Definition: SharedDefines.h:3640
@ ERR_BATTLEGROUND_TOO_MANY_QUEUES
Definition: SharedDefines.h:3641
@ ERR_GROUP_JOIN_BATTLEGROUND_FAIL
Definition: SharedDefines.h:3637
@ ERR_BATTLEGROUND_JOIN_RANGE_INDEX
Definition: SharedDefines.h:3647
@ ERR_IN_RANDOM_BG
Definition: SharedDefines.h:3651
@ CLASS_DEATH_KNIGHT
Definition: SharedDefines.h:146
@ BATTLEGROUND_AA
Definition: SharedDefines.h:3486
@ BATTLEGROUND_RB
Definition: SharedDefines.h:3493
BattlegroundQueueTypeId
Definition: SharedDefines.h:3619
TeamId
Definition: SharedDefines.h:759
#define sWorld
Definition: World.h:444
LfgState
Definition: LFG.h:70
@ LFG_STATE_NONE
Definition: LFG.h:71
@ LFG_STATE_QUEUED
Definition: LFG.h:73
Player * FindConnectedPlayer(ObjectGuid const guid)
Definition: ObjectAccessor.cpp:260
FROM * GetSource() const
Definition: Reference.h:97
Definition: ArenaTeam.h:138
MemberList & GetMembers()
Definition: ArenaTeam.h:174
Definition: Battleground.h:298
uint32 GetMinPlayersPerTeam() const
Definition: Battleground.h:337
bool isRated() const
Definition: Battleground.h:398
static BattlegroundQueueTypeId BGQueueTypeId(BattlegroundTypeId bgTypeId, uint8 arenaType)
Definition: BattlegroundMgr.cpp:672
Definition: BattlegroundQueue.h:31
bool IsRated
Definition: BattlegroundQueue.h:36
Definition: BattlegroundQueue.h:64
bool GetPlayerGroupInfoData(ObjectGuid guid, GroupQueueInfo *ginfo)
Definition: BattlegroundQueue.cpp:383
bool InBattlegroundQueueForBattlegroundQueueType(BattlegroundQueueTypeId bgQueueTypeId) const
Definition: Player.cpp:12235
bool InBattleground() const
Definition: Player.h:2232
TeamId GetTeamId(bool original=false) const
Definition: Player.h:2088
Battleground * GetBattleground(bool create=false) const
Definition: Player.cpp:12192
bool InBattlegroundQueue(bool ignoreArena=false) const
Definition: Player.cpp:12201
uint32 GetArenaTeamId(uint8 slot) const
Definition: Player.cpp:16212
bool CanJoinToBattleground() const
Definition: Player.cpp:11355
bool HasFreeBattlegroundQueueId() const
Definition: Player.cpp:12255
bool IsClass(Classes playerClass, ClassContext context=CLASS_CONTEXT_NONE) const override
Definition: Player.cpp:1280
bool HasSpell(uint32 spell) const override
Definition: Player.cpp:3859
bool GetBGAccessByLevel(BattlegroundTypeId bgTypeId) const
Definition: Player.cpp:12314
uint8 GetLevel() const
Definition: Unit.h:855
uint32 GetMembersCount() const
Definition: Group.h:245
bool IsMember(ObjectGuid guid) const
Definition: Group.cpp:2336
Definition: DBCStructure.h:604
uint32 maxGroupSize
Definition: DBCStructure.h:611
Definition: DBCStructure.h:1431
uint32 mapId
Definition: DBCStructure.h:1433

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

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

◆ ChangeLeader()

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

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 
)
1809{
1810 // Only raid groups have sub groups
1811 if (!isRaidGroup())
1812 return;
1813
1814 // Check if player is really in the raid
1815 member_witerator slot = _getMemberWSlot(guid);
1816 if (slot == m_memberSlots.end())
1817 return;
1818
1819 // Abort if the player is already in the target sub group
1820 uint8 prevSubGroup = GetMemberGroup(guid);
1821 if (prevSubGroup == group)
1822 return;
1823
1824 // Update the player slot with the new sub group setting
1825 slot->group = group;
1826
1827 // Increase the counter of the new sub group..
1829
1830 // ..and decrease the counter of the previous one
1831 SubGroupCounterDecrease(prevSubGroup);
1832
1833 // Preserve new sub group in database for non-raid groups
1834 if (!isBGGroup() && !isBFGroup())
1835 {
1837
1838 stmt->SetData(0, group);
1839 stmt->SetData(1, guid.GetCounter());
1840
1841 CharacterDatabase.Execute(stmt);
1842 }
1843
1844 // In case the moved player is online, update the player object with the new sub group references
1845 if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
1846 {
1847 if (player->GetGroup() == this)
1848 player->GetGroupRef().setSubGroup(group);
1849 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
1850 player->GetOriginalGroupRef().setSubGroup(group);
1851 }
1852
1853 // Broadcast the changes to the group
1854 SendUpdate();
1855}
@ CHAR_UPD_GROUP_MEMBER_SUBGROUP
Definition: CharacterDatabase.h:286
uint8 GetMemberGroup(ObjectGuid guid) const
Definition: Group.cpp:2384
void SubGroupCounterDecrease(uint8 subgroup)
Definition: Group.cpp:2511

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 ( )
285{
286 for (member_citerator citr = m_memberSlots.begin(); citr != m_memberSlots.end(); ++citr)
287 if (Player* player = ObjectAccessor::FindPlayer(citr->guid))
288 if (player->GetLevel() < sConfigMgr->GetOption<int32>("Group.Raid.LevelRestriction", 10))
289 return true;
290
291 return false;
292}
#define sConfigMgr
Definition: Config.h:74
std::int32_t int32
Definition: Define.h:103

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

Referenced by WorldSession::HandleGroupRaidConvertOpcode().

◆ ConvertToLFG()

void Group::ConvertToLFG ( bool  restricted = true)
263{
265 if (restricted)
266 {
269 }
270
271 if (!isBGGroup() && !isBFGroup())
272 {
274
275 stmt->SetData(0, uint8(m_groupType));
276 stmt->SetData(1, GetGUID().GetCounter());
277
278 CharacterDatabase.Execute(stmt);
279 }
280
281 SendUpdate();
282}
GroupType
Definition: Group.h:85
@ GROUPTYPE_LFG_RESTRICTED
Definition: Group.h:90
@ GROUPTYPE_LFG
Definition: Group.h:91
@ NEED_BEFORE_GREED
Definition: LootMgr.h:63
@ CHAR_UPD_GROUP_TYPE
Definition: CharacterDatabase.h:285

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 ( )
295{
297
299
300 if (!isBGGroup() && !isBFGroup())
301 {
303
304 stmt->SetData(0, uint8(m_groupType));
305 stmt->SetData(1, GetGUID().GetCounter());
306
307 CharacterDatabase.Execute(stmt);
308 }
309
310 SendUpdate();
311
312 // update quest related GO states (quest activity dependent from raid membership)
313 for (member_citerator citr = m_memberSlots.begin(); citr != m_memberSlots.end(); ++citr)
314 if (Player* player = ObjectAccessor::FindPlayer(citr->guid))
315 player->UpdateForQuestWorldObjects();
316
317 // pussywizard: client automatically clears df "eye" near minimap, so remove from raid browser
319 sLFGMgr->LeaveLfg(GetLeaderGUID());
320}
@ GROUPTYPE_RAID
Definition: Group.h:88
@ LFG_STATE_RAIDBROWSER
Definition: LFG.h:78
void _initRaidSubGroupsCounter()
Definition: Group.cpp:2477
ObjectGuid GetLeaderGUID() const
Definition: Group.cpp:2296

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

Referenced by WorldSession::HandleGroupRaidConvertOpcode().

◆ CountRollVote()

bool Group::CountRollVote ( ObjectGuid  playerGUID,
ObjectGuid  Guid,
uint8  Choise 
)
1361{
1362 Rolls::iterator rollI = GetRoll(Guid);
1363 if (rollI == RollId.end())
1364 return false;
1365 Roll* roll = *rollI;
1366
1367 Roll::PlayerVote::iterator itr = roll->playerVote.find(playerGUID);
1368 // this condition means that player joins to the party after roll begins
1369 // Xinef: if choice == MAX_ROLL_TYPE, player was removed from the map in removefromgroup
1370 // Xinef: itr can be invalid as it is not used below
1371 if (Choice < MAX_ROLL_TYPE && itr == roll->playerVote.end())
1372 return false;
1373
1374 if (roll->getLoot())
1375 if (roll->getLoot()->items.empty())
1376 return false;
1377
1378 switch (Choice)
1379 {
1380 case ROLL_PASS: // Player choose pass
1381 SendLootRoll(ObjectGuid::Empty, playerGUID, 128, ROLL_PASS, *roll);
1382 ++roll->totalPass;
1383 itr->second = PASS;
1384 break;
1385 case ROLL_NEED: // player choose Need
1386 SendLootRoll(ObjectGuid::Empty, playerGUID, 0, 0, *roll);
1387 ++roll->totalNeed;
1388 itr->second = NEED;
1389 break;
1390 case ROLL_GREED: // player choose Greed
1391 SendLootRoll(ObjectGuid::Empty, playerGUID, 128, ROLL_GREED, *roll);
1392 ++roll->totalGreed;
1393 itr->second = GREED;
1394 break;
1395 case ROLL_DISENCHANT: // player choose Disenchant
1396 SendLootRoll(ObjectGuid::Empty, playerGUID, 128, ROLL_DISENCHANT, *roll);
1397 ++roll->totalGreed;
1398 itr->second = DISENCHANT;
1399 break;
1400 }
1401
1402 if (roll->totalPass + roll->totalNeed + roll->totalGreed >= roll->totalPlayersRolling)
1403 {
1404 CountTheRoll(rollI, nullptr);
1405 return true;
1406 }
1407 return false;
1408}
@ PASS
Definition: Group.h:50
@ NEED
Definition: Group.h:51
@ DISENCHANT
Definition: Group.h:53
@ GREED
Definition: Group.h:52
@ ROLL_PASS
Definition: LootMgr.h:34
@ ROLL_GREED
Definition: LootMgr.h:36
@ ROLL_NEED
Definition: LootMgr.h:35
@ ROLL_DISENCHANT
Definition: LootMgr.h:37
static ObjectGuid const Empty
Definition: ObjectGuid.h:120
uint8 totalGreed
Definition: Group.h:160
uint8 totalPlayersRolling
Definition: Group.h:158
uint8 totalNeed
Definition: Group.h:159
uint8 totalPass
Definition: Group.h:161
Loot * getLoot()
Definition: Group.cpp:63
PlayerVote playerVote
Definition: Group.h:157
void SendLootRoll(ObjectGuid SourceGuid, ObjectGuid TargetGuid, uint8 RollNumber, uint8 RollType, const Roll &r, bool autoPass=false)
Definition: Group.cpp:901
Rolls::iterator GetRoll(ObjectGuid Guid)
Definition: Group.cpp:2463
void CountTheRoll(Rolls::iterator roll, Map *allowedMap)
Definition: Group.cpp:1425
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 RemoveMember().

◆ CountTheRoll()

void Group::CountTheRoll ( Rolls::iterator  roll,
Map allowedMap 
)
1426{
1427 Roll* roll = *rollI;
1428 if (!roll->isValid()) // is loot already deleted ?
1429 {
1430 RollId.erase(rollI);
1431 delete roll;
1432 return;
1433 }
1434
1435 //end of the roll
1436 if (roll->totalNeed > 0)
1437 {
1438 if (!roll->playerVote.empty())
1439 {
1440 uint8 maxresul = 0;
1441 ObjectGuid maxguid; // pussywizard: start with 0 >_>
1442 Player* player = nullptr;
1443
1444 for (Roll::PlayerVote::const_iterator itr = roll->playerVote.begin(); itr != roll->playerVote.end(); ++itr)
1445 {
1446 if (itr->second != NEED)
1447 continue;
1448
1449 player = ObjectAccessor::FindPlayer(itr->first);
1450 if (!player || (allowedMap != nullptr && player->FindMap() != allowedMap))
1451 {
1452 --roll->totalNeed;
1453 continue;
1454 }
1455
1456 uint8 randomN = urand(1, 100);
1457 SendLootRoll(ObjectGuid::Empty, itr->first, randomN, ROLL_NEED, *roll);
1458 if (maxresul < randomN)
1459 {
1460 maxguid = itr->first;
1461 maxresul = randomN;
1462 }
1463 }
1464
1465 if (maxguid) // pussywizard: added condition
1466 {
1467 SendLootRollWon(ObjectGuid::Empty, maxguid, maxresul, ROLL_NEED, *roll);
1468 player = ObjectAccessor::FindPlayer(maxguid);
1469
1470 if (player)
1471 {
1473
1474 ItemPosCountVec dest;
1475 LootItem* item = &(roll->itemSlot >= roll->getLoot()->items.size() ? roll->getLoot()->quest_items[roll->itemSlot - roll->getLoot()->items.size()] : roll->getLoot()->items[roll->itemSlot]);
1476 InventoryResult msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, roll->itemid, item->count);
1477 if (msg == EQUIP_ERR_OK)
1478 {
1479 item->is_looted = true;
1480 roll->getLoot()->NotifyItemRemoved(roll->itemSlot);
1481 roll->getLoot()->unlootedCount--;
1482 AllowedLooterSet looters = item->GetAllowedLooters();
1483 Item* _item = player->StoreNewItem(dest, roll->itemid, true, item->randomPropertyId, looters);
1484 if (_item)
1485 sScriptMgr->OnGroupRollRewardItem(player, _item, _item->GetCount(), NEED, roll);
1486 player->UpdateLootAchievements(item, roll->getLoot());
1487 }
1488 else
1489 {
1490 item->is_blocked = false;
1491 item->rollWinnerGUID = player->GetGUID();
1492 player->SendEquipError(msg, nullptr, nullptr, roll->itemid);
1493 }
1494 }
1495 }
1496 else
1497 roll->totalNeed = 0;
1498 }
1499 }
1500 if (roll->totalNeed == 0 && roll->totalGreed > 0) // pussywizard: if (roll->totalNeed == 0 && ...), not else if, because numbers can be modified above if player is on a different map
1501 {
1502 if (!roll->playerVote.empty())
1503 {
1504 uint8 maxresul = 0;
1505 ObjectGuid maxguid; // pussywizard: start with 0
1506 Player* player = nullptr;
1507 RollVote rollvote = NOT_VALID;
1508
1509 Roll::PlayerVote::iterator itr;
1510 for (itr = roll->playerVote.begin(); itr != roll->playerVote.end(); ++itr)
1511 {
1512 if (itr->second != GREED && itr->second != DISENCHANT)
1513 continue;
1514
1515 player = ObjectAccessor::FindPlayer(itr->first);
1516 if (!player || (allowedMap != nullptr && player->FindMap() != allowedMap))
1517 {
1518 --roll->totalGreed;
1519 continue;
1520 }
1521
1522 uint8 randomN = urand(1, 100);
1523 SendLootRoll(ObjectGuid::Empty, itr->first, randomN, itr->second, *roll);
1524 if (maxresul < randomN)
1525 {
1526 maxguid = itr->first;
1527 maxresul = randomN;
1528 rollvote = itr->second;
1529 }
1530 }
1531
1532 if (maxguid) // pussywizard: added condition
1533 {
1534 SendLootRollWon(ObjectGuid::Empty, maxguid, maxresul, rollvote, *roll);
1535 player = ObjectAccessor::FindPlayer(maxguid);
1536
1537 if (player)
1538 {
1540
1541 LootItem* item = &(roll->itemSlot >= roll->getLoot()->items.size() ? roll->getLoot()->quest_items[roll->itemSlot - roll->getLoot()->items.size()] : roll->getLoot()->items[roll->itemSlot]);
1542
1543 if (rollvote == GREED)
1544 {
1545 ItemPosCountVec dest;
1546 InventoryResult msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, roll->itemid, item->count);
1547 if (msg == EQUIP_ERR_OK)
1548 {
1549 item->is_looted = true;
1550 roll->getLoot()->NotifyItemRemoved(roll->itemSlot);
1551 roll->getLoot()->unlootedCount--;
1552 AllowedLooterSet looters = item->GetAllowedLooters();
1553 Item* _item = player->StoreNewItem(dest, roll->itemid, true, item->randomPropertyId, looters);
1554 if (_item)
1555 sScriptMgr->OnGroupRollRewardItem(player, _item, _item->GetCount(), GREED, roll);
1556 player->UpdateLootAchievements(item, roll->getLoot());
1557 }
1558 else
1559 {
1560 item->is_blocked = false;
1561 item->rollWinnerGUID = player->GetGUID();
1562 player->SendEquipError(msg, nullptr, nullptr, roll->itemid);
1563 }
1564 }
1565 else if (rollvote == DISENCHANT)
1566 {
1567 item->is_looted = true;
1568 roll->getLoot()->NotifyItemRemoved(roll->itemSlot);
1569 roll->getLoot()->unlootedCount--;
1570 ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(roll->itemid);
1572
1573 ItemPosCountVec dest;
1574 InventoryResult msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, roll->itemid, item->count);
1575
1576 if (msg == EQUIP_ERR_OK)
1577 {
1578 player->AutoStoreLoot(pProto->DisenchantID, LootTemplates_Disenchant, true);
1579 }
1580 else
1581 {
1582 Loot loot;
1583 loot.FillLoot(pProto->DisenchantID, LootTemplates_Disenchant, player, true);
1584
1585 uint32 max_slot = loot.GetMaxSlotInLootFor(player);
1586 for(uint32 i = 0; i < max_slot; i++)
1587 {
1588 LootItem* lootItem = loot.LootItemInSlot(i, player);
1589 player->SendEquipError(msg, nullptr, nullptr, lootItem->itemid);
1590 player->SendItemRetrievalMail(lootItem->itemid, lootItem->count);
1591 }
1592 }
1593 }
1594 }
1595 }
1596 else
1597 roll->totalGreed = 0;
1598 }
1599 }
1600 if (roll->totalNeed == 0 && roll->totalGreed == 0) // pussywizard: if, not else, because numbers can be modified above if player is on a different map
1601 {
1602 SendLootAllPassed(*roll);
1603
1604 // remove is_blocked so that the item is lootable by all players
1605 LootItem* item = &(roll->itemSlot >= roll->getLoot()->items.size() ? roll->getLoot()->quest_items[roll->itemSlot - roll->getLoot()->items.size()] : roll->getLoot()->items[roll->itemSlot]);
1606 if (item)
1607 item->is_blocked = false;
1608 }
1609
1610 if (Loot* loot = roll->getLoot(); loot && loot->isLooted() && loot->sourceGameObject)
1611 {
1612 const GameObjectTemplate* goInfo = loot->sourceGameObject->GetGOInfo();
1613 if (goInfo && goInfo->type == GAMEOBJECT_TYPE_CHEST)
1614 {
1615 // Deactivate chest if the last item was rolled in group
1617 }
1618 }
1619
1620 RollId.erase(rollI);
1621 delete roll;
1622}
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:44
#define sObjectMgr
Definition: ObjectMgr.h:1623
RollVote
Definition: Group.h:49
@ NOT_VALID
Definition: Group.h:55
LootStore LootTemplates_Disenchant("disenchant_loot_template", "item disenchant id", true)
GuidSet AllowedLooterSet
Definition: LootMgr.h:152
std::vector< ItemPosCount > ItemPosCountVec
Definition: Player.h:771
@ GO_JUST_DEACTIVATED
Definition: GameObject.h:114
InventoryResult
Definition: Item.h:46
@ EQUIP_ERR_OK
Definition: Item.h:47
@ NULL_BAG
Definition: Item.h:40
@ NULL_SLOT
Definition: Item.h:41
@ GAMEOBJECT_TYPE_CHEST
Definition: SharedDefines.h:1563
@ 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
bool isValid() const
Definition: Reference.h:79
GameObjectTemplate const * GetGOInfo() const
Definition: GameObject.h:137
void SetLootState(LootState s, Unit *unit=nullptr)
Definition: GameObject.cpp:2442
Definition: GameObjectData.h:32
uint32 type
Definition: GameObjectData.h:34
Definition: Item.h:220
uint32 GetCount() const
Definition: Item.h:272
Definition: ItemTemplate.h:619
uint32 DisenchantID
Definition: ItemTemplate.h:690
Definition: ObjectGuid.h:118
void UpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscValue1=0, uint32 miscValue2=0, Unit *unit=nullptr)
Definition: PlayerUpdates.cpp:2127
void AutoStoreLoot(uint8 bag, uint8 slot, uint32 loot_id, LootStore const &store, bool broadcast=false)
Definition: Player.cpp:13488
void SendItemRetrievalMail(uint32 itemEntry, uint32 count)
Definition: PlayerMisc.cpp:439
void UpdateLootAchievements(LootItem *item, Loot *loot)
Definition: PlayerUpdates.cpp:2117
Item * StoreNewItem(ItemPosCountVec const &pos, uint32 item, bool update, int32 randomPropertyId=0)
Definition: PlayerStorage.cpp:2530
void SendEquipError(InventoryResult msg, Item *pItem, Item *pItem2=nullptr, uint32 itemid=0)
Definition: PlayerStorage.cpp:4027
InventoryResult CanStoreNewItem(uint8 bag, uint8 slot, ItemPosCountVec &dest, uint32 item, uint32 count, uint32 *no_space_count=nullptr) const
Definition: Player.h:1272
uint8 itemSlot
Definition: Group.h:162
uint32 itemid
Definition: Group.h:152
void SendLootAllPassed(Roll const &roll)
Definition: Group.cpp:948
void SendLootRollWon(ObjectGuid SourceGuid, ObjectGuid TargetGuid, uint8 RollNumber, uint8 RollType, const Roll &r)
Definition: Group.cpp:925
Definition: LootMgr.h:155
uint32 itemid
Definition: LootMgr.h:156
bool is_blocked
Definition: LootMgr.h:165
ObjectGuid rollWinnerGUID
Definition: LootMgr.h:162
int32 randomPropertyId
Definition: LootMgr.h:159
uint8 count
Definition: LootMgr.h:163
bool is_looted
Definition: LootMgr.h:164
const AllowedLooterSet & GetAllowedLooters() const
Definition: LootMgr.h:182
Definition: LootMgr.h:313
uint32 GetMaxSlotInLootFor(Player *player) const
Definition: LootMgr.cpp:907
LootItem * LootItemInSlot(uint32 lootslot, Player *player, QuestItem **qitem=nullptr, QuestItem **ffaitem=nullptr, QuestItem **conditem=nullptr)
Definition: LootMgr.cpp:842
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:564
GameObject * sourceGameObject
Definition: LootMgr.h:331
void NotifyItemRemoved(uint8 lootIndex)
Definition: LootMgr.cpp:764
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(), LootItem::count, DISENCHANT, ItemTemplate::DisenchantID, ObjectGuid::Empty, EQUIP_ERR_OK, Loot::FillLoot(), WorldObject::FindMap(), ObjectAccessor::FindPlayer(), GAMEOBJECT_TYPE_CHEST, LootItem::GetAllowedLooters(), Item::GetCount(), Object::GetGUID(), Roll::getLoot(), Loot::GetMaxSlotInLootFor(), GO_JUST_DEACTIVATED, GREED, LootItem::is_blocked, LootItem::is_looted, Loot::isLooted(), Reference< TO, FROM >::isValid(), Roll::itemid, LootItem::itemid, Loot::items, Roll::itemSlot, Loot::LootItemInSlot(), LootTemplates_Disenchant, 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(), sObjectMgr, sScriptMgr, Player::StoreNewItem(), 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)
111{
112 ObjectGuid leaderGuid = leader->GetGUID();
113 ObjectGuid::LowType lowguid = sGroupMgr->GenerateGroupId();
114
115 m_guid = ObjectGuid::Create<HighGuid::Group>(lowguid);
116 m_leaderGuid = leaderGuid;
117 m_leaderName = leader->GetName();
119
120 if (isBGGroup() || isBFGroup())
122
125
126 if (!isLFGGroup())
128
130 m_looterGuid = leaderGuid;
132
135
136 if (!isBGGroup() && !isBFGroup())
137 {
140
141 // Store group in database
143
144 uint8 index = 0;
145
146 stmt->SetData(index++, lowguid);
147 stmt->SetData(index++, m_leaderGuid.GetCounter());
148 stmt->SetData(index++, uint8(m_lootMethod));
149 stmt->SetData(index++, m_looterGuid.GetCounter());
150 stmt->SetData(index++, uint8(m_lootThreshold));
151 stmt->SetData(index++, m_targetIcons[0].GetRawValue());
152 stmt->SetData(index++, m_targetIcons[1].GetRawValue());
153 stmt->SetData(index++, m_targetIcons[2].GetRawValue());
154 stmt->SetData(index++, m_targetIcons[3].GetRawValue());
155 stmt->SetData(index++, m_targetIcons[4].GetRawValue());
156 stmt->SetData(index++, m_targetIcons[5].GetRawValue());
157 stmt->SetData(index++, m_targetIcons[6].GetRawValue());
158 stmt->SetData(index++, m_targetIcons[7].GetRawValue());
159 stmt->SetData(index++, uint8(m_groupType));
160 stmt->SetData(index++, uint8(m_dungeonDifficulty));
161 stmt->SetData(index++, uint8(m_raidDifficulty));
162 stmt->SetData(index++, m_masterLooterGuid.GetCounter());
163
164 CharacterDatabase.Execute(stmt);
165
166 ASSERT(AddMember(leader)); // If the leader can't be added to a new group because it appears full, something is clearly wrong.
167
168 sScriptMgr->OnCreate(this, leader);
169 }
170 else if (!AddMember(leader))
171 return false;
172
173 return true;
174}
#define ASSERT
Definition: Errors.h:68
@ GROUPTYPE_BGRAID
Definition: Group.h:89
#define sGroupMgr
Definition: GroupMgr.h:51
@ GROUP_LOOT
Definition: LootMgr.h:62
@ CHAR_INS_GROUP
Definition: CharacterDatabase.h:281
uint32 LowType
Definition: ObjectGuid.h:122
void Clear()
Definition: ObjectGuid.h:138
ObjectGuid m_looterGuid
Definition: Group.h:349
bool AddMember(Player *player)
Definition: Group.cpp:392
ObjectGuid m_masterLooterGuid
Definition: Group.h:350
ObjectGuid m_guid
Definition: Group.h:353

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

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

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

◆ DoForAllMembers()

void Group::DoForAllMembers ( std::function< void(Player *)> const &  worker)
2544{
2545 for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next())
2546 {
2547 Player* member = itr->GetSource();
2548 if (!member)
2549 continue;
2550
2551 worker(member);
2552 }
2553}

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

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

◆ EndRoll()

void Group::EndRoll ( Loot loot,
Map allowedMap 
)
1412{
1413 for (Rolls::iterator itr = RollId.begin(); itr != RollId.end();)
1414 {
1415 if ((*itr)->getLoot() == pLoot)
1416 {
1417 CountTheRoll(itr, allowedMap); //i don't have to edit player votes, who didn't vote ... he will pass
1418 itr = RollId.begin();
1419 }
1420 else
1421 ++itr;
1422 }
1423}

References CountTheRoll(), and RollId.

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

◆ GetDifficulty()

Difficulty Group::GetDifficulty ( bool  isRaid) const
2444{
2445 return isRaid ? m_raidDifficulty : m_dungeonDifficulty;
2446}

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
2449{
2450 return m_dungeonDifficulty;
2451}

References m_dungeonDifficulty.

Referenced by AddMember().

◆ GetFirstMember() [1/2]

◆ GetFirstMember() [2/2]

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

References GroupRefMgr::getFirst(), and m_memberMgr.

◆ GetGroupType()

GroupType Group::GetGroupType ( ) const
2292{
2293 return m_groupType;
2294}

References m_groupType.

◆ GetGUID()

◆ GetInvited() [1/2]

Player * Group::GetInvited ( const std::string &  name) const
383{
384 for (InvitesList::const_iterator itr = m_invitees.begin(); itr != m_invitees.end(); ++itr)
385 {
386 if ((*itr) && (*itr)->GetName() == name)
387 return (*itr);
388 }
389 return nullptr;
390}

References m_invitees.

◆ GetInvited() [2/2]

Player * Group::GetInvited ( ObjectGuid  guid) const
373{
374 for (InvitesList::const_iterator itr = m_invitees.begin(); itr != m_invitees.end(); ++itr)
375 {
376 if ((*itr) && (*itr)->GetGUID() == guid)
377 return (*itr);
378 }
379 return nullptr;
380}

References m_invitees.

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

◆ GetInviteeCount()

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

References m_invitees.

Referenced by Player::UninviteFromGroup().

◆ GetLeader()

Player * Group::GetLeader ( )

◆ GetLeaderGUID()

◆ GetLeaderName()

const char * Group::GetLeaderName ( ) const
2312{
2313 return m_leaderName.c_str();
2314}

References m_leaderName.

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

◆ GetLooterGuid()

ObjectGuid Group::GetLooterGuid ( ) const
2322{
2323 return m_looterGuid;
2324}

References m_looterGuid.

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

◆ GetLootMethod()

◆ GetLootThreshold()

ItemQualities Group::GetLootThreshold ( ) const
2332{
2333 return m_lootThreshold;
2334}

References m_lootThreshold.

Referenced by Loot::FillLoot().

◆ GetMasterLooterGuid()

ObjectGuid Group::GetMasterLooterGuid ( ) const

◆ GetMemberGroup()

uint8 Group::GetMemberGroup ( ObjectGuid  guid) const
2385{
2386 member_citerator mslot = _getMemberCSlot(guid);
2387 if (mslot == m_memberSlots.end())
2388 return (MAX_RAID_SUBGROUPS + 1);
2389 return mslot->group;
2390}
member_citerator _getMemberCSlot(ObjectGuid Guid) const
Definition: Group.cpp:2489

References _getMemberCSlot(), m_memberSlots, and MAX_RAID_SUBGROUPS.

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

◆ GetMemberGUID()

ObjectGuid Group::GetMemberGUID ( const std::string &  name)
2347{
2348 for (member_citerator itr = m_memberSlots.begin(); itr != m_memberSlots.end(); ++itr)
2349 if (itr->name == name)
2350 return itr->guid;
2351
2352 return ObjectGuid::Empty;
2353}

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
2454{
2455 return m_raidDifficulty;
2456}

References m_raidDifficulty.

Referenced by AddMember().

◆ GetRoll()

Group::Rolls::iterator Group::GetRoll ( ObjectGuid  Guid)
2464{
2465 Rolls::iterator iter;
2466 for (iter = RollId.begin(); iter != RollId.end(); ++iter)
2467 if ((*iter)->itemGUID == Guid && (*iter)->isValid())
2468 return iter;
2469 return RollId.end();
2470}

References RollId.

Referenced by CountRollVote().

◆ GroupLoot()

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

References CanRollOnItem(), ItemTemplate::DisenchantID, ObjectAccessor::FindPlayer(), ObjectGuid::GetCounter(), GetFirstMember(), GetGUID(), Object::GetGUID(), WorldLocation::GetMapId(), Player::GetPassOnGroupLoot(), Player::GetSession(), Player::IsAtLootRewardDistance(), 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
2287{
2288 return GetMembersCount() > 0;
2289}

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
2459{
2460 return !RollId.empty();
2461}

References RollId.

Referenced by Player::CanUninviteFromGroup().

◆ LinkMember()

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

References LinkedListHead::insertFirst(), and m_memberMgr.

Referenced by GroupReference::targetObjectBuildLink().

◆ LoadGroupFromDB()

bool Group::LoadGroupFromDB ( Field field)
177{
178 ObjectGuid::LowType groupLowGuid = fields[16].Get<uint32>();
179 m_guid = ObjectGuid::Create<HighGuid::Group>(groupLowGuid);
180
181 m_leaderGuid = ObjectGuid::Create<HighGuid::Player>(fields[0].Get<uint32>());
182
183 // group leader not exist
184 if (!sCharacterCache->GetCharacterNameByGuid(m_leaderGuid, m_leaderName))
185 {
186 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
188 stmt->SetData(0, groupLowGuid);
189 trans->Append(stmt);
190 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GROUP_MEMBER_ALL);
191 stmt->SetData(0, groupLowGuid);
192 trans->Append(stmt);
193 CharacterDatabase.CommitTransaction(trans);
194 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_LFG_DATA);
195 stmt->SetData(0, groupLowGuid);
196 CharacterDatabase.Execute(stmt);
197 return false;
198 }
199
200 m_lootMethod = LootMethod(fields[1].Get<uint8>());
201 m_looterGuid = ObjectGuid::Create<HighGuid::Player>(fields[2].Get<uint32>());
202 m_lootThreshold = ItemQualities(fields[3].Get<uint8>());
203
204 for (uint8 i = 0; i < TARGETICONCOUNT; ++i)
205 m_targetIcons[i].Set(fields[4 + i].Get<uint64>());
206
207 m_groupType = GroupType(fields[12].Get<uint8>());
210
211 uint32 diff = fields[13].Get<uint8>();
212 if (diff >= MAX_DUNGEON_DIFFICULTY)
214 else
216
217 uint32 r_diff = fields[14].Get<uint8>();
218 if (r_diff >= MAX_RAID_DIFFICULTY)
220 else
222
223 m_masterLooterGuid = ObjectGuid::Create<HighGuid::Player>(fields[15].Get<uint32>());
224
226 sLFGMgr->_LoadFromDB(fields, GetGUID());
227
228 return true;
229}
LootMethod
Definition: LootMgr.h:58
ItemQualities
Definition: SharedDefines.h:328
#define MAX_RAID_DIFFICULTY
Definition: DBCEnums.h:282
Difficulty
Definition: DBCEnums.h:266
#define MAX_DUNGEON_DIFFICULTY
Definition: DBCEnums.h:281

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 
)
232{
233 MemberSlot member;
234 member.guid = ObjectGuid::Create<HighGuid::Player>(guidLow);
235
236 // skip non-existed member
237 if (!sCharacterCache->GetCharacterNameByGuid(member.guid, member.name))
238 {
240 stmt->SetData(0, guidLow);
241 stmt->SetData(1, GetGUID().GetCounter());
242 CharacterDatabase.Execute(stmt);
243 return;
244 }
245
246 member.group = subgroup;
247 member.flags = memberFlags;
248 member.roles = roles;
249
250 m_memberSlots.push_back(member);
251
252 if (!isBGGroup() && !isBFGroup())
253 {
254 sCharacterCache->UpdateCharacterGroup(ObjectGuid(HighGuid::Player, guidLow), GetGUID());
255 }
256
257 SubGroupCounterIncrease(subgroup);
258
259 sLFGMgr->SetupGroupMember(member.guid, GetGUID());
260}
@ CHAR_DEL_GROUP_MEMBER
Definition: CharacterDatabase.h:283

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

Referenced by GroupMgr::LoadGroups().

◆ MasterLoot()

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

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

Referenced by Player::SendLoot().

◆ NeedBeforeGreed()

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

References Player::CanRollForItemInLFG(), CanRollOnItem(), ItemTemplate::DisenchantID, EQUIP_ERR_OK, ObjectAccessor::FindPlayer(), ObjectGuid::GetCounter(), GetFirstMember(), GetGUID(), Object::GetGUID(), WorldLocation::GetMapId(), Player::GetPassOnGroupLoot(), Player::GetSession(), ItemTemplate::HasFlag2(), Player::IsAtGroupRewardDistance(), ITEM_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 ( )
1782{
1783 for (member_citerator citr = m_memberSlots.begin(); citr != m_memberSlots.end(); ++citr)
1784 {
1785 Player* player = ObjectAccessor::FindConnectedPlayer(citr->guid);
1786 if (!player)
1787 {
1789 data << citr->guid;
1790 data << uint8(0);
1791 BroadcastReadyCheck(&data);
1792 }
1793 }
1794}
@ MSG_RAID_READY_CHECK_CONFIRM
Definition: Opcodes.h:972
void BroadcastReadyCheck(WorldPacket const *packet)
Definition: Group.cpp:1770

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

Referenced by WorldSession::HandleRaidReadyCheckOpcode().

◆ RemoveAllInvites()

void Group::RemoveAllInvites ( )
364{
365 for (InvitesList::iterator itr = m_invitees.begin(); itr != m_invitees.end(); ++itr)
366 if (*itr)
367 (*itr)->SetGroupInvite(nullptr);
368
369 m_invitees.clear();
370}

References m_invitees.

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

◆ RemoveInvite()

void Group::RemoveInvite ( Player player)
354{
355 if (player)
356 {
357 if (!m_invitees.empty())
358 m_invitees.erase(player);
359 player->SetGroupInvite(nullptr);
360 }
361}

References m_invitees, and Player::SetGroupInvite().

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

◆ RemoveMember()

bool Group::RemoveMember ( ObjectGuid  guid,
const RemoveMethod method = GROUP_REMOVEMETHOD_DEFAULT,
ObjectGuid  kicker = ObjectGuid::Empty,
const char *  reason = nullptr 
)
549{
551
552 // LFG group vote kick handled in scripts
553 if (isLFGGroup(true) && method == GROUP_REMOVEMETHOD_KICK)
554 {
555 sLFGMgr->InitBoot(GetGUID(), kicker, guid, std::string(reason ? reason : ""));
556 return m_memberSlots.size() > 0;
557 }
558
559 // remove member and change leader (if need) only if strong more 2 members _before_ member remove (BG/BF allow 1 member group)
560 if (GetMembersCount() > ((isBGGroup() || isLFGGroup() || isBFGroup()) ? 1u : 2u))
561 {
563 if (player)
564 {
565 // Battleground group handling
566 if (isBGGroup() || isBFGroup())
568 else
569 // Regular group
570 {
571 if (player->GetOriginalGroup() == this)
572 player->SetOriginalGroup(nullptr);
573 else
574 player->SetGroup(nullptr);
575
576 // quest related GO state dependent from raid membership
578 }
579
580 WorldPacket data;
581
582 if (method == GROUP_REMOVEMETHOD_KICK || method == GROUP_REMOVEMETHOD_KICK_LFG)
583 {
585 player->GetSession()->SendPacket(&data);
586 }
587
588 // Do we really need to send this opcode?
589 data.Initialize(SMSG_GROUP_LIST, 1 + 1 + 1 + 1 + 8 + 4 + 4 + 8);
590 data << uint8(0x10) << uint8(0) << uint8(0) << uint8(0);
591 data << m_guid << uint32(m_counter) << uint32(0) << uint64(0);
592 player->GetSession()->SendPacket(&data);
593 }
594
595 // Remove player from group in DB
596 if (!isBGGroup() && !isBFGroup())
597 {
599 stmt->SetData(0, guid.GetCounter());
600 stmt->SetData(1, GetGUID().GetCounter());
601 CharacterDatabase.Execute(stmt);
602 }
603
604 // Remove player from loot rolls
605 for (Rolls::iterator it = RollId.begin(); it != RollId.end();)
606 {
607 Roll* roll = *it;
608 Roll::PlayerVote::iterator itr2 = roll->playerVote.find(guid);
609 if (itr2 == roll->playerVote.end())
610 {
611 ++it;
612 continue;
613 }
614
615 if (itr2->second == GREED || itr2->second == DISENCHANT)
616 --roll->totalGreed;
617 else if (itr2->second == NEED)
618 --roll->totalNeed;
619 else if (itr2->second == PASS)
620 --roll->totalPass;
621
622 if (itr2->second != NOT_VALID)
623 --roll->totalPlayersRolling;
624
625 roll->playerVote.erase(itr2);
626
627 // Xinef: itr can be erased inside
628 // Xinef: player is removed from all vote lists so it will not pass above playerVote == playerVote.end statement during second iteration
629 if (CountRollVote(guid, roll->itemGUID, MAX_ROLL_TYPE))
630 it = RollId.begin();
631 else
632 ++it;
633 }
634
635 // Update subgroups
637 if (slot != m_memberSlots.end())
638 {
639 SubGroupCounterDecrease(slot->group);
640 m_memberSlots.erase(slot);
641
642 if (!isBGGroup() && !isBFGroup())
643 {
644 sCharacterCache->ClearCharacterGroup(guid);
645 }
646 }
647
648 // Reevaluate group enchanter if the leaving player had enchanting skill or the player is offline
649 if (!player || player->GetSkillValue(SKILL_ENCHANTING))
650 {
652 }
653
654 // Pick new leader if necessary
655 bool validLeader = true;
656 if (m_leaderGuid == guid)
657 {
658 validLeader = false;
659 for (member_witerator itr = m_memberSlots.begin(); itr != m_memberSlots.end(); ++itr)
660 {
662 {
663 ChangeLeader(itr->guid);
664 validLeader = true;
665 break;
666 }
667 }
668 }
669
670 _homebindIfInstance(player);
671 if (!isBGGroup() && !isBFGroup())
673
674 sScriptMgr->OnGroupRemoveMember(this, guid, method, kicker, reason);
675
676 SendUpdate();
677
678 if (!validLeader)
679 {
680 // pussywizard: temp do nothing, something causes crashes in MakeNewGroup
681 //Disband();
682 //return false;
683 }
684
685 if (isLFGGroup() && GetMembersCount() == 1)
686 {
688 uint32 mapId = sLFGMgr->GetDungeonMapId(GetGUID());
689 lfg::LfgState state = sLFGMgr->GetState(GetGUID());
690 if (!mapId || !leader || (leader->IsAlive() && leader->GetMapId() != mapId) || state == lfg::LFG_STATE_NONE)
691 {
692 Disband();
693 return false;
694 }
695 }
696
697 if (m_memberMgr.getSize() < ((isLFGGroup() || isBGGroup() || isBFGroup()) ? 1u : 2u))
698 {
699 Disband();
700 return false;
701 }
702
703 return true;
704 }
705 // If group size before player removal <= 2 then disband it
706 else
707 {
708 sScriptMgr->OnGroupRemoveMember(this, guid, method, kicker, reason);
709 Disband();
710 return false;
711 }
712}
@ MAX_ROLL_TYPE
Definition: LootMgr.h:38
@ GROUP_REMOVEMETHOD_KICK_LFG
Definition: SharedDefines.h:3590
@ GROUP_REMOVEMETHOD_KICK
Definition: SharedDefines.h:3588
@ SMSG_GROUP_UNINVITE
Definition: Opcodes.h:149
uint32 getSize() const
Definition: LinkedList.h:115
bool IsAlive() const
Definition: Unit.h:1204
ObjectGuid itemGUID
Definition: Group.h:151
void BroadcastGroupUpdate(void)
Definition: Group.cpp:2199
void Disband(bool hideDestroy=false)
Definition: Group.cpp:755
void ResetMaxEnchantingLevel()
Definition: Group.cpp:2215
void ChangeLeader(ObjectGuid guid)
Definition: Group.cpp:714
bool CountRollVote(ObjectGuid playerGUID, ObjectGuid Guid, uint8 Choise)
Definition: Group.cpp:1360

References _getMemberWSlot(), _homebindIfInstance(), BroadcastGroupUpdate(), ChangeLeader(), CHAR_DEL_GROUP_MEMBER, CharacterDatabase, CountRollVote(), Disband(), DISENCHANT, ObjectAccessor::FindConnectedPlayer(), ObjectGuid::GetCounter(), GetGUID(), GetLeaderGUID(), WorldLocation::GetMapId(), GetMembersCount(), Player::GetOriginalGroup(), Player::GetSession(), LinkedListHead::getSize(), Player::GetSkillValue(), GREED, GROUP_REMOVEMETHOD_KICK, GROUP_REMOVEMETHOD_KICK_LFG, WorldPacket::Initialize(), INSTANCE_RESET_GROUP_LEAVE, Unit::IsAlive(), isBFGroup(), isBGGroup(), isLFGGroup(), Roll::itemGUID, lfg::LFG_STATE_NONE, m_counter, m_guid, m_leaderGuid, m_memberMgr, m_memberSlots, MAX_ROLL_TYPE, NEED, NOT_VALID, PASS, Roll::playerVote, Player::RemoveFromBattlegroundOrBattlefieldRaid(), Player::ResetInstances(), ResetMaxEnchantingLevel(), RollId, sCharacterCache, WorldSession::SendPacket(), SendUpdate(), PreparedStatementBase::SetData(), Player::SetGroup(), Player::SetOriginalGroup(), SKILL_ENCHANTING, sLFGMgr, SMSG_GROUP_LIST, SMSG_GROUP_UNINVITE, sScriptMgr, SubGroupCounterDecrease(), Roll::totalGreed, Roll::totalNeed, Roll::totalPass, Roll::totalPlayersRolling, and Player::UpdateForQuestWorldObjects().

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

◆ RemoveUniqueGroupMemberFlag()

void Group::RemoveUniqueGroupMemberFlag ( GroupMemberFlags  flag)
2518{
2519 for (member_witerator itr = m_memberSlots.begin(); itr != m_memberSlots.end(); ++itr)
2520 if (itr->flags & flag)
2521 itr->flags &= ~flag;
2522}

References m_memberSlots.

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

◆ ResetInstances()

void Group::ResetInstances ( uint8  method,
bool  isRaid,
Player leader 
)
2116{
2117 if (isBGGroup() || isBFGroup() || isLFGGroup())
2118 return;
2119
2120 switch (method)
2121 {
2122 case INSTANCE_RESET_ALL:
2123 {
2124 if (leader->GetDifficulty(false) != DUNGEON_DIFFICULTY_NORMAL)
2125 break;
2126 std::vector<InstanceSave*> toUnbind;
2127 BoundInstancesMap const& m_boundInstances = sInstanceSaveMgr->PlayerGetBoundInstances(leader->GetGUID(), Difficulty(DUNGEON_DIFFICULTY_NORMAL));
2128 for (BoundInstancesMap::const_iterator itr = m_boundInstances.begin(); itr != m_boundInstances.end(); ++itr)
2129 {
2130 InstanceSave* instanceSave = itr->second.save;
2131 MapEntry const* entry = sMapStore.LookupEntry(itr->first);
2132 if (!entry || entry->IsRaid() || !instanceSave->CanReset())
2133 continue;
2134
2135 Map* map = sMapMgr->FindMap(instanceSave->GetMapId(), instanceSave->GetInstanceId());
2136 if (!map || map->ToInstanceMap()->Reset(method))
2137 {
2138 leader->SendResetInstanceSuccess(instanceSave->GetMapId());
2139 toUnbind.push_back(instanceSave);
2140 }
2141 else
2142 {
2143 leader->SendResetInstanceFailed(0, instanceSave->GetMapId());
2144 }
2145
2146 sInstanceSaveMgr->DeleteInstanceSavedData(instanceSave->GetInstanceId());
2147 }
2148 for (std::vector<InstanceSave*>::const_iterator itr = toUnbind.begin(); itr != toUnbind.end(); ++itr)
2149 sInstanceSaveMgr->UnbindAllFor(*itr);
2150 }
2151 break;
2153 {
2154 std::vector<InstanceSave*> toUnbind;
2155 BoundInstancesMap const& m_boundInstances = sInstanceSaveMgr->PlayerGetBoundInstances(leader->GetGUID(), leader->GetDifficulty(isRaid));
2156 for (BoundInstancesMap::const_iterator itr = m_boundInstances.begin(); itr != m_boundInstances.end(); ++itr)
2157 {
2158 InstanceSave* instanceSave = itr->second.save;
2159 MapEntry const* entry = sMapStore.LookupEntry(itr->first);
2160 if (!entry || entry->IsRaid() != isRaid || !instanceSave->CanReset())
2161 continue;
2162
2163 Map* map = sMapMgr->FindMap(instanceSave->GetMapId(), instanceSave->GetInstanceId());
2164 if (!map || map->ToInstanceMap()->Reset(method))
2165 {
2166 leader->SendResetInstanceSuccess(instanceSave->GetMapId());
2167 toUnbind.push_back(instanceSave);
2168 }
2169 else
2170 {
2171 leader->SendResetInstanceFailed(0, instanceSave->GetMapId());
2172 }
2173
2174 sInstanceSaveMgr->DeleteInstanceSavedData(instanceSave->GetInstanceId());
2175 }
2176 for (std::vector<InstanceSave*>::const_iterator itr = toUnbind.begin(); itr != toUnbind.end(); ++itr)
2177 sInstanceSaveMgr->UnbindAllFor(*itr);
2178 }
2179 break;
2180 }
2181}
std::unordered_map< uint32, InstancePlayerBind > BoundInstancesMap
Definition: InstanceSaveMgr.h:46
#define sMapMgr
Definition: MapMgr.h:221
@ INSTANCE_RESET_CHANGE_DIFFICULTY
Definition: Map.h:812
@ INSTANCE_RESET_ALL
Definition: Map.h:811
void SendResetInstanceSuccess(uint32 MapId)
Definition: PlayerMisc.cpp:326
void SendResetInstanceFailed(uint32 reason, uint32 MapId)
Definition: PlayerMisc.cpp:333
Definition: InstanceSaveMgr.h:56
uint32 GetMapId() const
Definition: InstanceSaveMgr.h:62
bool CanReset() const
Definition: InstanceSaveMgr.h:81
Definition: Map.h:313
InstanceMap * ToInstanceMap()
Definition: Map.h:546
bool Reset(uint8 method, GuidList *globalSkipList=nullptr)
Definition: Map.cpp:3105
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, 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 ( )
2216{
2218 Player* pMember = nullptr;
2219 for (member_citerator citr = m_memberSlots.begin(); citr != m_memberSlots.end(); ++citr)
2220 {
2221 pMember = ObjectAccessor::FindPlayer(citr->guid);
2222 if (pMember && pMember->GetSession() && !pMember->GetSession()->IsSocketClosed()
2223 && m_maxEnchantingLevel < pMember->GetSkillValue(SKILL_ENCHANTING))
2224 {
2226 }
2227 }
2228}
bool IsSocketClosed() const
Definition: WorldSession.cpp:537

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
2372{
2373 member_citerator mslot1 = _getMemberCSlot(guid1);
2374 if (mslot1 == m_memberSlots.end() || !slot2)
2375 return false;
2376 return (mslot1->group == slot2->group);
2377}

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

◆ SameSubGroup() [2/3]

bool Group::SameSubGroup ( ObjectGuid  guid1,
ObjectGuid  guid2 
) const
2364{
2365 member_citerator mslot2 = _getMemberCSlot(guid2);
2366 if (mslot2 == m_memberSlots.end())
2367 return false;
2368 return SameSubGroup(guid1, &*mslot2);
2369}
bool SameSubGroup(ObjectGuid guid1, ObjectGuid guid2) const
Definition: Group.cpp:2363

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
1797{
1798 if (!member1 || !member2)
1799 return false;
1800
1801 if (member1->GetGroup() != this || member2->GetGroup() != this)
1802 return false;
1803 else
1804 return member1->GetSubGroup() == member2->GetSubGroup();
1805}

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

◆ SendLootAllPassed()

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

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

Referenced by CountTheRoll().

◆ SendLooter()

void Group::SendLooter ( Creature creature,
Player pLooter 
)
970{
971 ASSERT(creature);
972
973 WorldPacket data(SMSG_LOOT_LIST, (8 + 8));
974 data << creature->GetGUID();
975
976 if (GetLootMethod() == MASTER_LOOT && creature->loot.hasOverThresholdItem())
978 else
979 data << uint8(0);
980
981 if (groupLooter)
982 data << groupLooter->GetPackGUID();
983 else
984 data << uint8(0);
985
986 BroadcastPacket(&data, false);
987}
@ MASTER_LOOT
Definition: LootMgr.h:61
@ SMSG_LOOT_LIST
Definition: Opcodes.h:1047
Loot loot
Definition: Creature.h:227
PackedGuid WriteAsPacked() const
Definition: ObjectGuid.h:316
ObjectGuid GetMasterLooterGuid() const
Definition: Group.cpp:2326
LootMethod GetLootMethod() const
Definition: Group.cpp:2316
bool hasOverThresholdItem() const
Definition: LootMgr.cpp:973

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

Referenced by Unit::Kill().

◆ SendLootRoll()

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

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

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

◆ SendLootRollWon()

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

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

Referenced by CountTheRoll().

◆ SendLootStartRoll()

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

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

Referenced by GroupLoot().

◆ SendLootStartRollToPlayer()

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

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

Referenced by NeedBeforeGreed().

◆ SendTargetIconList()

void Group::SendTargetIconList ( WorldSession session)
1646{
1647 if (!session)
1648 return;
1649
1651 data << uint8(1); // list targets
1652
1653 for (uint8 i = 0; i < TARGETICONCOUNT; ++i)
1654 {
1655 if (!m_targetIcons[i])
1656 continue;
1657
1658 data << uint8(i);
1659 data << m_targetIcons[i];
1660 }
1661
1662 session->SendPacket(&data);
1663}
@ MSG_RAID_TARGET_UPDATE
Definition: Opcodes.h:831

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

Referenced by WorldSession::HandleRaidTargetUpdateOpcode().

◆ SendUpdate()

◆ SendUpdateToPlayer()

void Group::SendUpdateToPlayer ( ObjectGuid  playerGUID,
MemberSlot slot = nullptr 
)
1672{
1673 Player* player = ObjectAccessor::FindConnectedPlayer(playerGUID);
1674
1675 if (!player || player->GetGroup() != this)
1676 return;
1677
1678 // if MemberSlot wasn't provided
1679 if (!slot)
1680 {
1681 member_witerator witr = _getMemberWSlot(playerGUID);
1682
1683 if (witr == m_memberSlots.end()) // if there is no MemberSlot for such a player
1684 return;
1685
1686 slot = &(*witr);
1687 }
1688
1689 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));
1690 data << uint8(m_groupType); // group type (flags in 3.3)
1691 data << uint8(slot->group);
1692 data << uint8(slot->flags);
1693 data << uint8(slot->roles);
1694 if (isLFGGroup())
1695 {
1696 data << uint8(sLFGMgr->GetState(m_guid) == lfg::LFG_STATE_FINISHED_DUNGEON ? 2 : 0); // FIXME - Dungeon save status? 2 = done
1697 data << uint32(sLFGMgr->GetDungeon(m_guid));
1698 }
1699
1700 data << m_guid;
1701 data << uint32(m_counter++); // 3.3, value increases every time this packet gets sent
1702 data << uint32(GetMembersCount() - 1);
1703 for (member_citerator citr = m_memberSlots.begin(); citr != m_memberSlots.end(); ++citr)
1704 {
1705 if (slot->guid == citr->guid)
1706 continue;
1707
1708 Player* member = ObjectAccessor::FindConnectedPlayer(citr->guid);
1709
1710 uint8 onlineState = (member && !member->GetSession()->PlayerLogout()) ? MEMBER_STATUS_ONLINE : MEMBER_STATUS_OFFLINE;
1711 onlineState = onlineState | ((isBGGroup() || isBFGroup()) ? MEMBER_STATUS_PVP : 0);
1712
1713 data << citr->name;
1714 data << citr->guid; // guid
1715 data << uint8(onlineState); // online-state
1716 data << uint8(citr->group); // groupid
1717 data << uint8(citr->flags); // See enum GroupMemberFlags
1718 data << uint8(citr->roles); // Lfg Roles
1719 }
1720
1721 data << m_leaderGuid; // leader guid
1722
1723 if (GetMembersCount() - 1)
1724 {
1725 data << uint8(m_lootMethod); // loot method
1726
1728 data << m_masterLooterGuid; // master looter guid
1729 else
1730 data << uint64(0); // looter guid
1731
1732 data << uint8(m_lootThreshold); // loot threshold
1733 data << uint8(m_dungeonDifficulty); // Dungeon Difficulty
1734 data << uint8(m_raidDifficulty); // Raid Difficulty
1735 data << uint8(m_raidDifficulty >= RAID_DIFFICULTY_10MAN_HEROIC); // 3.3 Dynamic Raid Difficulty - 0 normal/1 heroic
1736 }
1737
1738 player->GetSession()->SendPacket(&data);
1739}
@ MEMBER_STATUS_OFFLINE
Definition: Group.h:60
@ MEMBER_STATUS_PVP
Definition: Group.h:62
@ MEMBER_STATUS_ONLINE
Definition: Group.h:61
@ RAID_DIFFICULTY_10MAN_HEROIC
Definition: DBCEnums.h:275
@ LFG_STATE_FINISHED_DUNGEON
Definition: LFG.h:77
bool PlayerLogout() const
Definition: WorldSession.h:338

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, WorldSession::SendPacket(), sLFGMgr, and SMSG_GROUP_LIST.

Referenced by SendUpdate().

◆ SetBattlefieldGroup()

void Group::SetBattlefieldGroup ( Battlefield bf)
2398{
2399 m_bfGroup = bg;
2400}

References m_bfGroup.

Referenced by Battlefield::AddOrSetPlayerToCorrectBfGroup().

◆ SetBattlegroundGroup()

void Group::SetBattlegroundGroup ( Battleground bg)
2393{
2394 m_bgGroup = bg;
2395}

References m_bgGroup.

Referenced by Battleground::SetBgRaid().

◆ SetDifficultyChangePrevention()

◆ SetDungeonDifficulty()

void Group::SetDungeonDifficulty ( Difficulty  difficulty)
2074{
2075 m_dungeonDifficulty = difficulty;
2076 if (!isBGGroup() && !isBFGroup())
2077 {
2079
2081 stmt->SetData(1, GetGUID().GetCounter());
2082
2083 CharacterDatabase.Execute(stmt);
2084 }
2085
2086 for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next())
2087 {
2088 Player* player = itr->GetSource();
2089 player->SetDungeonDifficulty(difficulty);
2090 player->SendDungeonDifficulty(true);
2091 }
2092}
@ CHAR_UPD_GROUP_DIFFICULTY
Definition: CharacterDatabase.h:288

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

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

◆ SetGroupMemberFlag()

void Group::SetGroupMemberFlag ( ObjectGuid  guid,
bool  apply,
GroupMemberFlags  flag 
)
2403{
2404 // Assistants, main assistants and main tanks are only available in raid groups
2405 if (!isRaidGroup())
2406 return;
2407
2408 // Check if player is really in the raid
2409 member_witerator slot = _getMemberWSlot(guid);
2410 if (slot == m_memberSlots.end())
2411 return;
2412
2413 // Do flag specific actions, e.g ensure uniqueness
2414 switch (flag)
2415 {
2417 RemoveUniqueGroupMemberFlag(MEMBER_FLAG_MAINASSIST); // Remove main assist flag from current if any.
2418 break;
2420 RemoveUniqueGroupMemberFlag(MEMBER_FLAG_MAINTANK); // Remove main tank flag from current if any.
2421 break;
2423 break;
2424 default:
2425 return; // This should never happen
2426 }
2427
2428 // Switch the actual flag
2429 ToggleGroupMemberFlag(slot, flag, apply);
2430
2431 // Preserve the new setting in the db
2433
2434 stmt->SetData(0, slot->flags);
2435 stmt->SetData(1, guid.GetCounter());
2436
2437 CharacterDatabase.Execute(stmt);
2438
2439 // Broadcast the changes to the group
2440 SendUpdate();
2441}
@ MEMBER_FLAG_MAINASSIST
Definition: Group.h:75
@ MEMBER_FLAG_MAINTANK
Definition: Group.h:74
@ CHAR_UPD_GROUP_MEMBER_FLAG
Definition: CharacterDatabase.h:287
void RemoveUniqueGroupMemberFlag(GroupMemberFlags flag)
Definition: Group.cpp:2517

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 
)
2251{
2252 member_witerator slot = _getMemberWSlot(guid);
2253 if (slot == m_memberSlots.end())
2254 return;
2255
2256 slot->roles = roles;
2257 SendUpdate();
2258}

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

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

◆ SetLooterGuid()

void Group::SetLooterGuid ( ObjectGuid  guid)
2236{
2237 m_looterGuid = guid;
2238}

References m_looterGuid.

Referenced by UpdateLooterGuid().

◆ SetLootMethod()

void Group::SetLootMethod ( LootMethod  method)
2231{
2232 m_lootMethod = method;
2233}

References m_lootMethod.

Referenced by WorldSession::HandleLootMethodOpcode().

◆ SetLootThreshold()

void Group::SetLootThreshold ( ItemQualities  threshold)
2246{
2247 m_lootThreshold = threshold;
2248}

References m_lootThreshold.

Referenced by WorldSession::HandleLootMethodOpcode().

◆ SetMasterLooterGuid()

void Group::SetMasterLooterGuid ( ObjectGuid  guid)
2241{
2242 m_masterLooterGuid = guid;
2243}

References m_masterLooterGuid.

Referenced by WorldSession::HandleLootMethodOpcode().

◆ SetRaidDifficulty()

void Group::SetRaidDifficulty ( Difficulty  difficulty)
2095{
2096 m_raidDifficulty = difficulty;
2097 if (!isBGGroup() && !isBFGroup())
2098 {
2100
2101 stmt->SetData(0, uint8(m_raidDifficulty));
2102 stmt->SetData(1, GetGUID().GetCounter());
2103
2104 CharacterDatabase.Execute(stmt);
2105 }
2106
2107 for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next())
2108 {
2109 Player* player = itr->GetSource();
2110 player->SetRaidDifficulty(difficulty);
2111 player->SendRaidDifficulty(true);
2112 }
2113}
@ CHAR_UPD_GROUP_RAID_DIFFICULTY
Definition: CharacterDatabase.h:289

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

Referenced by WorldSession::HandleSetRaidDifficultyOpcode().

◆ SetTargetIcon()

void Group::SetTargetIcon ( uint8  id,
ObjectGuid  whoGuid,
ObjectGuid  targetGuid 
)
1625{
1626 if (id >= TARGETICONCOUNT)
1627 return;
1628
1629 // clean other icons
1630 if (targetGuid)
1631 for (int i = 0; i < TARGETICONCOUNT; ++i)
1632 if (m_targetIcons[i] == targetGuid)
1634
1635 m_targetIcons[id] = targetGuid;
1636
1637 WorldPacket data(MSG_RAID_TARGET_UPDATE, (1 + 8 + 1 + 8));
1638 data << uint8(0); // set targets
1639 data << whoGuid;
1640 data << uint8(id);
1641 data << targetGuid;
1642 BroadcastPacket(&data, true);
1643}
void SetTargetIcon(uint8 id, ObjectGuid whoGuid, ObjectGuid targetGuid)
Definition: Group.cpp:1624

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
2512{
2514 --m_subGroupsCounts[subgroup];
2515}

References m_subGroupsCounts.

Referenced by ChangeMembersGroup(), and RemoveMember().

◆ SubGroupCounterIncrease()

void Group::SubGroupCounterIncrease ( uint8  subgroup)
protected
2506{
2508 ++m_subGroupsCounts[subgroup];
2509}

References m_subGroupsCounts.

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

◆ ToggleGroupMemberFlag()

void Group::ToggleGroupMemberFlag ( member_witerator  slot,
uint8  flag,
bool  apply 
)
protected
2525{
2526 if (apply)
2527 slot->flags |= flag;
2528 else
2529 slot->flags &= ~flag;
2530}

Referenced by ChangeLeader(), and SetGroupMemberFlag().

◆ UpdateLooterGuid()

void Group::UpdateLooterGuid ( WorldObject pLootedObject,
bool  ifneed = false 
)
1869{
1870 // round robin style looting applies for all low
1871 // quality items in each loot method except free for all
1872 if (GetLootMethod() == FREE_FOR_ALL)
1873 return;
1874
1875 ObjectGuid oldLooterGUID = GetLooterGuid();
1876 member_citerator guid_itr = _getMemberCSlot(oldLooterGUID);
1877 if (guid_itr != m_memberSlots.end())
1878 {
1879 if (ifneed)
1880 {
1881 // not update if only update if need and ok
1882 Player* looter = ObjectAccessor::FindPlayer(guid_itr->guid);
1883 if (looter && looter->IsAtLootRewardDistance(pLootedObject))
1884 return;
1885 }
1886 ++guid_itr;
1887 }
1888
1889 // search next after current
1890 Player* pNewLooter = nullptr;
1891 for (member_citerator itr = guid_itr; itr != m_memberSlots.end(); ++itr)
1892 {
1893 if (Player* player = ObjectAccessor::FindPlayer(itr->guid))
1894 if (player->IsAtLootRewardDistance(pLootedObject))
1895 {
1896 pNewLooter = player;
1897 break;
1898 }
1899 }
1900
1901 if (!pNewLooter)
1902 {
1903 // search from start
1904 for (member_citerator itr = m_memberSlots.begin(); itr != guid_itr; ++itr)
1905 {
1906 if (Player* player = ObjectAccessor::FindPlayer(itr->guid))
1907 if (player->IsAtLootRewardDistance(pLootedObject))
1908 {
1909 pNewLooter = player;
1910 break;
1911 }
1912 }
1913 }
1914
1915 if (pNewLooter)
1916 {
1917 if (oldLooterGUID != pNewLooter->GetGUID())
1918 {
1919 SetLooterGuid(pNewLooter->GetGUID());
1920 SendUpdate();
1921 }
1922 }
1923 else
1924 {
1926 SendUpdate();
1927 }
1928}
ObjectGuid GetLooterGuid() const
Definition: Group.cpp:2321
void SetLooterGuid(ObjectGuid guid)
Definition: Group.cpp:2235

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)
1742{
1743 if (!player || !player->IsInWorld())
1744 return;
1745
1746 WorldPacket data;
1747 player->GetSession()->BuildPartyMemberStatsChangedPacket(player, &data);
1748
1749 for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next())
1750 {
1751 Player* member = itr->GetSource();
1752 if (member && (!member->IsInMap(player) || !member->IsWithinDist(player, member->GetSightRange(player), false)))
1753 member->GetSession()->SendPacket(&data);
1754 }
1755}
bool IsWithinDist(WorldObject const *obj, float dist2compare, bool is3D=true, bool useBoundingRadius=true) const
Definition: Object.cpp:1316
bool IsInMap(WorldObject const *obj) const
Definition: Object.cpp:1285
float GetSightRange(WorldObject const *target=nullptr) const override
Definition: Player.cpp:16286
void BuildPartyMemberStatsChangedPacket(Player *player, WorldPacket *data)
Definition: GroupHandler.cpp:767

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

Referenced by AddMember().

Member Data Documentation

◆ _difficultyChangePreventionTime

uint32 Group::_difficultyChangePreventionTime
protected

◆ _difficultyChangePreventionType

DifficultyPreventionChangeType Group::_difficultyChangePreventionType
protected

◆ CustomData

DataMap Group::CustomData

◆ m_bfGroup

Battlefield* Group::m_bfGroup
protected

Referenced by isBFGroup(), and SetBattlefieldGroup().

◆ m_bgGroup

Battleground* Group::m_bgGroup
protected

◆ m_counter

uint32 Group::m_counter
protected

◆ m_dungeonDifficulty

◆ m_groupType

◆ m_guid

◆ m_invitees

InvitesList Group::m_invitees
protected

◆ m_leaderGuid

◆ m_leaderName

std::string Group::m_leaderName
protected

◆ m_lfgGroupFlags

◆ m_looterGuid

ObjectGuid Group::m_looterGuid
protected

◆ m_lootMethod

◆ m_lootThreshold

◆ m_masterLooterGuid

ObjectGuid Group::m_masterLooterGuid
protected

◆ m_maxEnchantingLevel

uint32 Group::m_maxEnchantingLevel
protected

◆ m_memberMgr

GroupRefMgr Group::m_memberMgr
protected

◆ m_memberSlots

◆ m_raidDifficulty

◆ m_subGroupsCounts

◆ m_targetIcons

◆ RollId