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 ( )
69{
70 sScriptMgr->OnConstructGroup(this);
71}
@ RAID_DIFFICULTY_10MAN_NORMAL
Definition: DBCEnums.h:273
@ DUNGEON_DIFFICULTY_NORMAL
Definition: DBCEnums.h:269
@ ITEM_QUALITY_UNCOMMON
Definition: SharedDefines.h:331
@ GROUPTYPE_NORMAL
Definition: Group.h:86
@ DIFFICULTY_PREVENTION_CHANGE_NONE
Definition: Group.h:133
@ FREE_FOR_ALL
Definition: LootMgr.h:58
#define sScriptMgr
Definition: ScriptMgr.h:709
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 ( )
74{
75 sScriptMgr->OnDestructGroup(this);
76
77 if (m_bgGroup)
78 {
79 LOG_DEBUG("bg.battleground", "Group::~Group: battleground group being deleted.");
80
81 if (m_bgGroup->GetBgRaid(TEAM_ALLIANCE) == this)
82 {
84 }
85 else if (m_bgGroup->GetBgRaid(TEAM_HORDE) == this)
86 {
88 }
89 else
90 LOG_ERROR("bg.battleground", "Group::~Group: battleground group is not linked to the correct battleground.");
91 }
92
93 Rolls::iterator itr;
94 while (!RollId.empty())
95 {
96 itr = RollId.begin();
97 Roll* r = *itr;
98 RollId.erase(itr);
99 delete(r);
100 }
101
102 // Sub group counters clean up
103 delete[] m_subGroupsCounts;
104}
#define LOG_ERROR(filterType__,...)
Definition: Log.h:157
#define LOG_DEBUG(filterType__,...)
Definition: Log.h:169
@ TEAM_ALLIANCE
Definition: SharedDefines.h:760
@ TEAM_HORDE
Definition: SharedDefines.h:761
Group * GetBgRaid(TeamId teamId) const
Definition: Battleground.h:491
void SetBgRaid(TeamId teamId, Group *bg_raid)
Definition: Battleground.cpp:1809
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
2186{
2187 // if player is reinvited to group and in the instance - cancel homebind timer
2188 if (!player->FindMap() || !player->FindMap()->IsDungeon())
2189 return;
2190 InstancePlayerBind* bind = sInstanceSaveMgr->PlayerGetBoundInstance(player->GetGUID(), player->FindMap()->GetId(), player->GetDifficulty(player->FindMap()->IsRaid()));
2191 if (bind && bind->save->GetInstanceId() == player->GetInstanceId())
2192 player->m_InstanceValid = true;
2193}
#define sInstanceSaveMgr
Definition: InstanceSaveMgr.h:202
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:112
Map * FindMap() const
Definition: Object.h:537
uint32 GetInstanceId() const
Definition: Object.h:448
bool m_InstanceValid
Definition: Player.h:2436
Difficulty GetDifficulty(bool isRaid) const
Definition: Player.h:1920
Definition: InstanceSaveMgr.h:39
InstanceSave * save
Definition: InstanceSaveMgr.h:40
uint32 GetInstanceId() const
Definition: InstanceSaveMgr.h:61
bool IsDungeon() const
Definition: Map.h:446
bool IsRaid() const
Definition: Map.h:448
uint32 GetId() const
Definition: Map.h:377

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
2486{
2487 for (member_citerator itr = m_memberSlots.begin(); itr != m_memberSlots.end(); ++itr)
2488 if (itr->guid == Guid)
2489 return itr;
2490 return m_memberSlots.end();
2491}
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
2494{
2495 for (member_witerator itr = m_memberSlots.begin(); itr != m_memberSlots.end(); ++itr)
2496 if (itr->guid == Guid)
2497 return itr;
2498 return m_memberSlots.end();
2499}
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
2180{
2181 if (player && !player->IsGameMaster() && player->FindMap() && sMapStore.LookupEntry(player->GetMapId())->IsDungeon())
2182 player->m_InstanceValid = false;
2183}
DBCStorage< MapEntry > sMapStore(MapEntryfmt)
uint32 GetMapId() const
Definition: Position.h:275
bool IsGameMaster() const
Definition: Player.h:1175

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

Referenced by Disband(), and RemoveMember().

◆ _initRaidSubGroupsCounter()

void Group::_initRaidSubGroupsCounter ( )
protected
2474{
2475 // Sub group counters initialization
2476 if (!m_subGroupsCounts)
2478
2479 memset((void*)m_subGroupsCounts, 0, (MAX_RAID_SUBGROUPS)*sizeof(uint8));
2480
2481 for (member_citerator itr = m_memberSlots.begin(); itr != m_memberSlots.end(); ++itr)
2482 ++m_subGroupsCounts[itr->group];
2483}
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)
319{
320 if (!player || player->GetGroupInvite())
321 return false;
322 Group* group = player->GetGroup();
323 if (group && (group->isBGGroup() || group->isBFGroup()))
324 group = player->GetOriginalGroup();
325 if (group)
326 return false;
327
328 RemoveInvite(player);
329
330 m_invitees.insert(player);
331
332 player->SetGroupInvite(this);
333
334 sScriptMgr->OnGroupInviteMember(this, player->GetGUID());
335
336 return true;
337}
void SetGroupInvite(Group *group)
Definition: Player.h:2467
Group * GetGroup()
Definition: Player.h:2468
Group * GetGroupInvite()
Definition: Player.h:2466
Group * GetOriginalGroup()
Definition: Player.h:2483
Definition: Group.h:169
InvitesList m_invitees
Definition: Group.h:338
void RemoveInvite(Player *player)
Definition: Group.cpp:349
bool isBGGroup() const
Definition: Group.cpp:2272
bool isBFGroup() const
Definition: Group.cpp:2277

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)
340{
341 if (!AddInvite(player))
342 return false;
343
344 m_leaderGuid = player->GetGUID();
345 m_leaderName = player->GetName();
346 return true;
347}
std::string const & GetName() const
Definition: Object.h:463
ObjectGuid m_leaderGuid
Definition: Group.h:339
bool AddInvite(Player *player)
Definition: Group.cpp:318

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

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

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

◆ BroadcastGroupUpdate()

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

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 
)
1754{
1755 for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next())
1756 {
1757 Player* player = itr->GetSource();
1758 if (!player || (ignore && player->GetGUID() == ignore) || (ignorePlayersInBGRaid && player->GetGroup() != this))
1759 continue;
1760
1761 if (group == -1 || itr->getSubGroup() == group)
1762 player->GetSession()->SendPacket(packet);
1763 }
1764}
WorldSession * GetSession() const
Definition: Player.h:1998
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)
1767{
1768 for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next())
1769 {
1770 Player* player = itr->GetSource();
1771 if (player)
1772 if (IsLeader(player->GetGUID()) || IsAssistant(player->GetGUID()))
1773 player->GetSession()->SendPacket(packet);
1774 }
1775}
bool IsAssistant(ObjectGuid guid) const
Definition: Group.cpp:2351

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 
)
1927{
1928 // check if this group is LFG group
1929 if (isLFGGroup())
1931
1932 BattlemasterListEntry const* bgEntry = sBattlemasterListStore.LookupEntry(bgTemplate->GetBgTypeID());
1933 if (!bgEntry)
1935
1936 // too many players in the group
1937 if (GetMembersCount() > bgEntry->maxGroupSize)
1938 return ERR_BATTLEGROUND_NONE;
1939
1940 // get a player as reference, to compare other players' stats to (arena team id, level bracket, etc.)
1941 Player* reference = GetFirstMember()->GetSource();
1942 if (!reference)
1944
1945 PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bgTemplate->GetMapId(), reference->GetLevel());
1946 if (!bracketEntry)
1948
1949 uint32 arenaTeamId = reference->GetArenaTeamId(arenaSlot);
1950 TeamId teamId = reference->GetTeamId();
1951
1953
1954 // check every member of the group to be able to join
1955 uint32 memberscount = 0;
1956 for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next(), ++memberscount)
1957 {
1958 Player* member = itr->GetSource();
1959
1960 // don't let join with offline members
1961 if (!member)
1963
1964 if (!sScriptMgr->CanGroupJoinBattlegroundQueue(this, member, bgTemplate, MinPlayerCount, isRated, arenaSlot))
1966
1967 // don't allow cross-faction groups to join queue
1968 if (member->GetTeamId() != teamId && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP))
1970
1971 // don't let join rated matches if the arena team id doesn't match
1972 if (isRated && member->GetArenaTeamId(arenaSlot) != arenaTeamId)
1974
1975 // not in the same battleground level braket, don't let join
1976 PvPDifficultyEntry const* memberBracketEntry = GetBattlegroundBracketByLevel(bracketEntry->mapId, member->GetLevel());
1977 if (memberBracketEntry != bracketEntry)
1979
1980 // check for deserter debuff in case not arena queue
1981 if (bgTemplate->GetBgTypeID() != BATTLEGROUND_AA && !member->CanJoinToBattleground())
1983
1984 // check if someone in party is using dungeon system
1985 lfg::LfgState lfgState = sLFGMgr->GetState(member->GetGUID());
1986 if (lfgState > lfg::LFG_STATE_NONE && (lfgState != lfg::LFG_STATE_QUEUED || !sWorld->getBoolConfig(CONFIG_ALLOW_JOIN_BG_AND_LFG)))
1987 {
1989 }
1990
1991 // pussywizard: prevent joining when any member is in bg/arena
1992 if (member->InBattleground())
1994
1995 // pussywizard: check for free slot, this is actually ensured before calling this function, but just in case
1996 if (!member->HasFreeBattlegroundQueueId())
1998
1999 // don't let join if someone from the group is already in that bg queue
2000 if (member->InBattlegroundQueueForBattlegroundQueueType(bgQueueTypeId))
2001 {
2003 }
2004
2005 // don't let join if someone from the group is in bg queue random
2006 if (member->InBattlegroundQueueForBattlegroundQueueType(bgQueueTypeIdRandom))
2007 return ERR_IN_RANDOM_BG;
2008
2009 // don't let join to bg queue random if someone from the group is already in bg queue
2010 if (bgTemplate->GetBgTypeID() == BATTLEGROUND_RB && member->InBattlegroundQueue())
2011 return ERR_IN_NON_RANDOM_BG;
2012
2013 // don't let Death Knights join BG queues when they are not allowed to be teleported yet
2014 if (member->IsClass(CLASS_DEATH_KNIGHT, CLASS_CONTEXT_TELEPORT) && member->GetMapId() == 609 && !member->IsGameMaster() && !member->HasSpell(50977))
2016
2017 if (!member->GetBGAccessByLevel(bgTemplate->GetBgTypeID()))
2018 {
2020 }
2021 }
2022
2023 // for arenas: check party size is proper
2024 if (bgTemplate->isArena() && memberscount != MinPlayerCount)
2026
2027 //check against other arena team members
2028 if (isRated)
2029 {
2030 ArenaTeam* arenaTeam = sArenaTeamMgr->GetArenaTeamById(arenaTeamId);
2031 for (auto const& itr : arenaTeam->GetMembers())
2032 {
2033 Player* teamMember = ObjectAccessor::FindConnectedPlayer(itr.Guid);
2034 //are they online and not a member of this current group?
2035 if (teamMember && !IsMember(teamMember->GetGUID()))
2036 {
2037 //are they already in queue for a rated arena?
2038 if (teamMember->InBattlegroundQueueForBattlegroundQueueType(bgQueueTypeId))
2039 {
2040 GroupQueueInfo ginfo;
2041 BattlegroundQueue& queue = sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId);
2042 if (queue.GetPlayerGroupInfoData(teamMember->GetGUID(), &ginfo))
2043 {
2044 if (ginfo.IsRated)
2046 }
2047 }
2048 //are they currently in an arena match?
2049 Battleground* bg = teamMember->GetBattleground(false);
2050 if (bg && bg->isRated() && bg->GetMinPlayersPerTeam() == MinPlayerCount)
2052 }
2053 }
2054 }
2055
2056 return GroupJoinBattlegroundResult(bgTemplate->GetBgTypeID());
2057}
std::uint32_t uint32
Definition: Define.h:107
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 sLFGMgr
Definition: LFGMgr.h:641
@ CONFIG_ALLOW_JOIN_BG_AND_LFG
Definition: IWorld.h:172
@ CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP
Definition: IWorld.h:75
@ CLASS_CONTEXT_TELEPORT
Definition: UnitDefines.h:207
DBCStorage< BattlemasterListEntry > sBattlemasterListStore(BattlemasterListEntryfmt)
PvPDifficultyEntry const * GetBattlegroundBracketByLevel(uint32 mapid, uint32 level)
Definition: DBCStores.cpp:793
#define sBattlegroundMgr
Definition: BattlegroundMgr.h:186
#define sArenaTeamMgr
Definition: ArenaTeamMgr.h:67
#define sWorld
Definition: World.h:443
LfgState
Definition: LFG.h:67
@ LFG_STATE_NONE
Definition: LFG.h:68
@ LFG_STATE_QUEUED
Definition: LFG.h:70
Player * FindConnectedPlayer(ObjectGuid const guid)
Definition: ObjectAccessor.cpp:257
FROM * GetSource() const
Definition: Reference.h:97
Definition: ArenaTeam.h:137
MemberList & GetMembers()
Definition: ArenaTeam.h:173
Definition: Battleground.h:303
uint32 GetMinPlayersPerTeam() const
Definition: Battleground.h:350
bool isRated() const
Definition: Battleground.h:415
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:385
bool InBattlegroundQueueForBattlegroundQueueType(BattlegroundQueueTypeId bgQueueTypeId) const
Definition: Player.cpp:12271
bool InBattleground() const
Definition: Player.h:2252
TeamId GetTeamId(bool original=false) const
Definition: Player.h:2108
Battleground * GetBattleground(bool create=false) const
Definition: Player.cpp:12228
bool InBattlegroundQueue(bool ignoreArena=false) const
Definition: Player.cpp:12237
uint32 GetArenaTeamId(uint8 slot) const
Definition: Player.cpp:16242
bool CanJoinToBattleground() const
Definition: Player.cpp:11391
bool HasFreeBattlegroundQueueId() const
Definition: Player.cpp:12291
bool IsClass(Classes playerClass, ClassContext context=CLASS_CONTEXT_NONE) const override
Definition: Player.cpp:1284
bool HasSpell(uint32 spell) const override
Definition: Player.cpp:3892
bool GetBGAccessByLevel(BattlegroundTypeId bgTypeId) const
Definition: Player.cpp:12350
uint8 GetLevel() const
Definition: Unit.h:1024
uint32 GetMembersCount() const
Definition: Group.h:245
bool IsMember(ObjectGuid guid) const
Definition: Group.cpp:2332
Definition: DBCStructure.h:603
uint32 maxGroupSize
Definition: DBCStructure.h:610
Definition: DBCStructure.h:1430
uint32 mapId
Definition: DBCStructure.h:1432

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)
711{
712 member_witerator slot = _getMemberWSlot(newLeaderGuid);
713
714 if (slot == m_memberSlots.end())
715 return;
716
717 Player* newLeader = ObjectAccessor::FindConnectedPlayer(slot->guid);
718
719 // Don't allow switching leader to offline players
720 if (!newLeader)
721 return;
722
723 if (!isBGGroup() && !isBFGroup())
724 {
725 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
726 // Update the group leader
728 stmt->SetData(0, newLeader->GetGUID().GetCounter());
729 stmt->SetData(1, GetGUID().GetCounter());
730 trans->Append(stmt);
731 CharacterDatabase.CommitTransaction(trans);
732
733 sInstanceSaveMgr->CopyBinds(m_leaderGuid, newLeaderGuid, newLeader);
734 }
735
737 oldLeader->RemovePlayerFlag(PLAYER_FLAGS_GROUP_LEADER);
738
740 m_leaderGuid = newLeader->GetGUID();
741 m_leaderName = newLeader->GetName();
743
745 data << slot->name;
746 BroadcastPacket(&data, true);
747
748 sScriptMgr->OnGroupChangeLeader(this, newLeaderGuid, m_leaderGuid); // This hook should be executed at the end - Not used anywhere in the original core
749}
@ MEMBER_FLAG_ASSISTANT
Definition: Group.h:73
@ PLAYER_FLAGS_GROUP_LEADER
Definition: Player.h:479
@ CHAR_UPD_GROUP_LEADER
Definition: CharacterDatabase.h:284
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
Definition: DatabaseEnvFwd.h:69
@ SMSG_GROUP_SET_LEADER
Definition: Opcodes.h:151
LowType GetCounter() const
Definition: ObjectGuid.h:145
void SetPlayerFlag(PlayerFlags flags)
Definition: Player.h:1126
void BroadcastPacket(WorldPacket const *packet, bool ignorePlayersInBGRaid, int group=-1, ObjectGuid ignore=ObjectGuid::Empty)
Definition: Group.cpp:1753
void ToggleGroupMemberFlag(member_witerator slot, uint8 flag, bool apply)
Definition: Group.cpp:2520
member_witerator _getMemberWSlot(ObjectGuid Guid)
Definition: Group.cpp:2493

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

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 ( )
281{
282 for (member_citerator citr = m_memberSlots.begin(); citr != m_memberSlots.end(); ++citr)
283 if (Player* player = ObjectAccessor::FindPlayer(citr->guid))
284 if (player->GetLevel() < sConfigMgr->GetOption<int32>("Group.Raid.LevelRestriction", 10))
285 return true;
286
287 return false;
288}
#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)
259{
261 if (restricted)
262 {
265 }
266
267 if (!isBGGroup() && !isBFGroup())
268 {
270
271 stmt->SetData(0, uint8(m_groupType));
272 stmt->SetData(1, GetGUID().GetCounter());
273
274 CharacterDatabase.Execute(stmt);
275 }
276
277 SendUpdate();
278}
GroupType
Definition: Group.h:85
@ GROUPTYPE_LFG_RESTRICTED
Definition: Group.h:90
@ GROUPTYPE_LFG
Definition: Group.h:91
@ NEED_BEFORE_GREED
Definition: LootMgr.h:62
@ 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 ( )
291{
293
295
296 if (!isBGGroup() && !isBFGroup())
297 {
299
300 stmt->SetData(0, uint8(m_groupType));
301 stmt->SetData(1, GetGUID().GetCounter());
302
303 CharacterDatabase.Execute(stmt);
304 }
305
306 SendUpdate();
307
308 // update quest related GO states (quest activity dependent from raid membership)
309 for (member_citerator citr = m_memberSlots.begin(); citr != m_memberSlots.end(); ++citr)
310 if (Player* player = ObjectAccessor::FindPlayer(citr->guid))
311 player->UpdateForQuestWorldObjects();
312
313 // pussywizard: client automatically clears df "eye" near minimap, so remove from raid browser
315 sLFGMgr->LeaveLfg(GetLeaderGUID());
316}
@ GROUPTYPE_RAID
Definition: Group.h:88
@ LFG_STATE_RAIDBROWSER
Definition: LFG.h:75
void _initRaidSubGroupsCounter()
Definition: Group.cpp:2473
ObjectGuid GetLeaderGUID() const
Definition: Group.cpp:2292

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 
)
1357{
1358 Rolls::iterator rollI = GetRoll(Guid);
1359 if (rollI == RollId.end())
1360 return false;
1361 Roll* roll = *rollI;
1362
1363 Roll::PlayerVote::iterator itr = roll->playerVote.find(playerGUID);
1364 // this condition means that player joins to the party after roll begins
1365 // Xinef: if choice == MAX_ROLL_TYPE, player was removed from the map in removefromgroup
1366 // Xinef: itr can be invalid as it is not used below
1367 if (Choice < MAX_ROLL_TYPE && itr == roll->playerVote.end())
1368 return false;
1369
1370 if (roll->getLoot())
1371 if (roll->getLoot()->items.empty())
1372 return false;
1373
1374 switch (Choice)
1375 {
1376 case ROLL_PASS: // Player choose pass
1377 SendLootRoll(ObjectGuid::Empty, playerGUID, 128, ROLL_PASS, *roll);
1378 ++roll->totalPass;
1379 itr->second = PASS;
1380 break;
1381 case ROLL_NEED: // player choose Need
1382 SendLootRoll(ObjectGuid::Empty, playerGUID, 0, 0, *roll);
1383 ++roll->totalNeed;
1384 itr->second = NEED;
1385 break;
1386 case ROLL_GREED: // player choose Greed
1387 SendLootRoll(ObjectGuid::Empty, playerGUID, 128, ROLL_GREED, *roll);
1388 ++roll->totalGreed;
1389 itr->second = GREED;
1390 break;
1391 case ROLL_DISENCHANT: // player choose Disenchant
1392 SendLootRoll(ObjectGuid::Empty, playerGUID, 128, ROLL_DISENCHANT, *roll);
1393 ++roll->totalGreed;
1394 itr->second = DISENCHANT;
1395 break;
1396 }
1397
1398 if (roll->totalPass + roll->totalNeed + roll->totalGreed >= roll->totalPlayersRolling)
1399 {
1400 CountTheRoll(rollI, nullptr);
1401 return true;
1402 }
1403 return false;
1404}
@ PASS
Definition: Group.h:50
@ NEED
Definition: Group.h:51
@ DISENCHANT
Definition: Group.h:53
@ GREED
Definition: Group.h:52
@ ROLL_PASS
Definition: LootMgr.h:33
@ ROLL_GREED
Definition: LootMgr.h:35
@ ROLL_NEED
Definition: LootMgr.h:34
@ ROLL_DISENCHANT
Definition: LootMgr.h:36
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:59
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:897
Rolls::iterator GetRoll(ObjectGuid Guid)
Definition: Group.cpp:2459
void CountTheRoll(Rolls::iterator roll, Map *allowedMap)
Definition: Group.cpp:1421
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 
)
1422{
1423 Roll* roll = *rollI;
1424 if (!roll->isValid()) // is loot already deleted ?
1425 {
1426 RollId.erase(rollI);
1427 delete roll;
1428 return;
1429 }
1430
1431 //end of the roll
1432 if (roll->totalNeed > 0)
1433 {
1434 if (!roll->playerVote.empty())
1435 {
1436 uint8 maxresul = 0;
1437 ObjectGuid maxguid; // pussywizard: start with 0 >_>
1438 Player* player = nullptr;
1439
1440 for (Roll::PlayerVote::const_iterator itr = roll->playerVote.begin(); itr != roll->playerVote.end(); ++itr)
1441 {
1442 if (itr->second != NEED)
1443 continue;
1444
1445 player = ObjectAccessor::FindPlayer(itr->first);
1446 if (!player || (allowedMap != nullptr && player->FindMap() != allowedMap))
1447 {
1448 --roll->totalNeed;
1449 continue;
1450 }
1451
1452 uint8 randomN = urand(1, 100);
1453 SendLootRoll(ObjectGuid::Empty, itr->first, randomN, ROLL_NEED, *roll);
1454 if (maxresul < randomN)
1455 {
1456 maxguid = itr->first;
1457 maxresul = randomN;
1458 }
1459 }
1460
1461 if (maxguid) // pussywizard: added condition
1462 {
1463 SendLootRollWon(ObjectGuid::Empty, maxguid, maxresul, ROLL_NEED, *roll);
1464 player = ObjectAccessor::FindPlayer(maxguid);
1465
1466 if (player)
1467 {
1469
1470 ItemPosCountVec dest;
1471 LootItem* item = &(roll->itemSlot >= roll->getLoot()->items.size() ? roll->getLoot()->quest_items[roll->itemSlot - roll->getLoot()->items.size()] : roll->getLoot()->items[roll->itemSlot]);
1472 InventoryResult msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, roll->itemid, item->count);
1473 if (msg == EQUIP_ERR_OK)
1474 {
1475 item->is_looted = true;
1476 roll->getLoot()->NotifyItemRemoved(roll->itemSlot);
1477 roll->getLoot()->unlootedCount--;
1478 AllowedLooterSet looters = item->GetAllowedLooters();
1479 Item* _item = player->StoreNewItem(dest, roll->itemid, true, item->randomPropertyId, looters);
1480 if (_item)
1481 sScriptMgr->OnGroupRollRewardItem(player, _item, _item->GetCount(), NEED, roll);
1482 player->UpdateLootAchievements(item, roll->getLoot());
1483 }
1484 else
1485 {
1486 item->is_blocked = false;
1487 item->rollWinnerGUID = player->GetGUID();
1488 player->SendEquipError(msg, nullptr, nullptr, roll->itemid);
1489 }
1490 }
1491 }
1492 else
1493 roll->totalNeed = 0;
1494 }
1495 }
1496 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
1497 {
1498 if (!roll->playerVote.empty())
1499 {
1500 uint8 maxresul = 0;
1501 ObjectGuid maxguid; // pussywizard: start with 0
1502 Player* player = nullptr;
1503 RollVote rollvote = NOT_VALID;
1504
1505 Roll::PlayerVote::iterator itr;
1506 for (itr = roll->playerVote.begin(); itr != roll->playerVote.end(); ++itr)
1507 {
1508 if (itr->second != GREED && itr->second != DISENCHANT)
1509 continue;
1510
1511 player = ObjectAccessor::FindPlayer(itr->first);
1512 if (!player || (allowedMap != nullptr && player->FindMap() != allowedMap))
1513 {
1514 --roll->totalGreed;
1515 continue;
1516 }
1517
1518 uint8 randomN = urand(1, 100);
1519 SendLootRoll(ObjectGuid::Empty, itr->first, randomN, itr->second, *roll);
1520 if (maxresul < randomN)
1521 {
1522 maxguid = itr->first;
1523 maxresul = randomN;
1524 rollvote = itr->second;
1525 }
1526 }
1527
1528 if (maxguid) // pussywizard: added condition
1529 {
1530 SendLootRollWon(ObjectGuid::Empty, maxguid, maxresul, rollvote, *roll);
1531 player = ObjectAccessor::FindPlayer(maxguid);
1532
1533 if (player)
1534 {
1536
1537 LootItem* item = &(roll->itemSlot >= roll->getLoot()->items.size() ? roll->getLoot()->quest_items[roll->itemSlot - roll->getLoot()->items.size()] : roll->getLoot()->items[roll->itemSlot]);
1538
1539 if (rollvote == GREED)
1540 {
1541 ItemPosCountVec dest;
1542 InventoryResult msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, roll->itemid, item->count);
1543 if (msg == EQUIP_ERR_OK)
1544 {
1545 item->is_looted = true;
1546 roll->getLoot()->NotifyItemRemoved(roll->itemSlot);
1547 roll->getLoot()->unlootedCount--;
1548 AllowedLooterSet looters = item->GetAllowedLooters();
1549 Item* _item = player->StoreNewItem(dest, roll->itemid, true, item->randomPropertyId, looters);
1550 if (_item)
1551 sScriptMgr->OnGroupRollRewardItem(player, _item, _item->GetCount(), GREED, roll);
1552 player->UpdateLootAchievements(item, roll->getLoot());
1553 }
1554 else
1555 {
1556 item->is_blocked = false;
1557 item->rollWinnerGUID = player->GetGUID();
1558 player->SendEquipError(msg, nullptr, nullptr, roll->itemid);
1559 }
1560 }
1561 else if (rollvote == DISENCHANT)
1562 {
1563 item->is_looted = true;
1564 roll->getLoot()->NotifyItemRemoved(roll->itemSlot);
1565 roll->getLoot()->unlootedCount--;
1566 ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(roll->itemid);
1568
1569 ItemPosCountVec dest;
1570 InventoryResult msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, roll->itemid, item->count);
1571
1572 if (msg == EQUIP_ERR_OK)
1573 {
1574 player->AutoStoreLoot(pProto->DisenchantID, LootTemplates_Disenchant, true);
1575 }
1576 else
1577 {
1578 Loot loot;
1579 loot.FillLoot(pProto->DisenchantID, LootTemplates_Disenchant, player, true);
1580
1581 uint32 max_slot = loot.GetMaxSlotInLootFor(player);
1582 for(uint32 i = 0; i < max_slot; i++)
1583 {
1584 LootItem* lootItem = loot.LootItemInSlot(i, player);
1585 player->SendEquipError(msg, nullptr, nullptr, lootItem->itemid);
1586 player->SendItemRetrievalMail(lootItem->itemid, lootItem->count);
1587 }
1588 }
1589 }
1590 }
1591 }
1592 else
1593 roll->totalGreed = 0;
1594 }
1595 }
1596 if (roll->totalNeed == 0 && roll->totalGreed == 0) // pussywizard: if, not else, because numbers can be modified above if player is on a different map
1597 {
1598 SendLootAllPassed(*roll);
1599
1600 // remove is_blocked so that the item is lootable by all players
1601 LootItem* item = &(roll->itemSlot >= roll->getLoot()->items.size() ? roll->getLoot()->quest_items[roll->itemSlot - roll->getLoot()->items.size()] : roll->getLoot()->items[roll->itemSlot]);
1602 if (item)
1603 item->is_blocked = false;
1604 }
1605
1606 if (Loot* loot = roll->getLoot(); loot && loot->isLooted() && loot->sourceGameObject)
1607 {
1608 const GameObjectTemplate* goInfo = loot->sourceGameObject->GetGOInfo();
1609 if (goInfo && goInfo->type == GAMEOBJECT_TYPE_CHEST)
1610 {
1611 // Deactivate chest if the last item was rolled in group
1613 }
1614 }
1615
1616 RollId.erase(rollI);
1617 delete roll;
1618}
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:44
@ 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
@ GAMEOBJECT_TYPE_CHEST
Definition: SharedDefines.h:1563
#define sObjectMgr
Definition: ObjectMgr.h:1635
RollVote
Definition: Group.h:49
@ NOT_VALID
Definition: Group.h:55
std::vector< ItemPosCount > ItemPosCountVec
Definition: Player.h:776
InventoryResult
Definition: Item.h:46
@ EQUIP_ERR_OK
Definition: Item.h:47
@ NULL_BAG
Definition: Item.h:40
@ NULL_SLOT
Definition: Item.h:41
@ GO_JUST_DEACTIVATED
Definition: GameObject.h:113
LootStore LootTemplates_Disenchant("disenchant_loot_template", "item disenchant id", true)
GuidSet AllowedLooterSet
Definition: LootMgr.h:151
bool isValid() const
Definition: Reference.h:79
GameObjectTemplate const * GetGOInfo() const
Definition: GameObject.h:136
void SetLootState(LootState s, Unit *unit=nullptr)
Definition: GameObject.cpp:2444
Definition: GameObjectData.h:31
uint32 type
Definition: GameObjectData.h:33
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:2131
void AutoStoreLoot(uint8 bag, uint8 slot, uint32 loot_id, LootStore const &store, bool broadcast=false)
Definition: Player.cpp:13524
void SendItemRetrievalMail(uint32 itemEntry, uint32 count)
Definition: PlayerMisc.cpp:439
void UpdateLootAchievements(LootItem *item, Loot *loot)
Definition: PlayerUpdates.cpp:2121
Item * StoreNewItem(ItemPosCountVec const &pos, uint32 item, bool update, int32 randomPropertyId=0)
Definition: PlayerStorage.cpp:2524
void SendEquipError(InventoryResult msg, Item *pItem, Item *pItem2=nullptr, uint32 itemid=0)
Definition: PlayerStorage.cpp:4021
InventoryResult CanStoreNewItem(uint8 bag, uint8 slot, ItemPosCountVec &dest, uint32 item, uint32 count, uint32 *no_space_count=nullptr) const
Definition: Player.h:1291
uint8 itemSlot
Definition: Group.h:162
uint32 itemid
Definition: Group.h:152
void SendLootAllPassed(Roll const &roll)
Definition: Group.cpp:944
void SendLootRollWon(ObjectGuid SourceGuid, ObjectGuid TargetGuid, uint8 RollNumber, uint8 RollType, const Roll &r)
Definition: Group.cpp:921
Definition: LootMgr.h:154
uint32 itemid
Definition: LootMgr.h:155
bool is_blocked
Definition: LootMgr.h:164
ObjectGuid rollWinnerGUID
Definition: LootMgr.h:161
int32 randomPropertyId
Definition: LootMgr.h:158
uint8 count
Definition: LootMgr.h:162
bool is_looted
Definition: LootMgr.h:163
const AllowedLooterSet & GetAllowedLooters() const
Definition: LootMgr.h:181
Definition: LootMgr.h:313
uint32 GetMaxSlotInLootFor(Player *player) const
Definition: LootMgr.cpp:915
LootItem * LootItemInSlot(uint32 lootslot, Player *player, QuestItem **qitem=nullptr, QuestItem **ffaitem=nullptr, QuestItem **conditem=nullptr)
Definition: LootMgr.cpp:850
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:570
GameObject * sourceGameObject
Definition: LootMgr.h:331
void NotifyItemRemoved(uint8 lootIndex)
Definition: LootMgr.cpp:772
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)
107{
108 ObjectGuid leaderGuid = leader->GetGUID();
109 ObjectGuid::LowType lowguid = sGroupMgr->GenerateGroupId();
110
111 m_guid = ObjectGuid::Create<HighGuid::Group>(lowguid);
112 m_leaderGuid = leaderGuid;
113 m_leaderName = leader->GetName();
115
116 if (isBGGroup() || isBFGroup())
118
121
122 if (!isLFGGroup())
124
126 m_looterGuid = leaderGuid;
128
131
132 if (!isBGGroup() && !isBFGroup())
133 {
136
137 // Store group in database
139
140 uint8 index = 0;
141
142 stmt->SetData(index++, lowguid);
143 stmt->SetData(index++, m_leaderGuid.GetCounter());
144 stmt->SetData(index++, uint8(m_lootMethod));
145 stmt->SetData(index++, m_looterGuid.GetCounter());
146 stmt->SetData(index++, uint8(m_lootThreshold));
147 stmt->SetData(index++, m_targetIcons[0].GetRawValue());
148 stmt->SetData(index++, m_targetIcons[1].GetRawValue());
149 stmt->SetData(index++, m_targetIcons[2].GetRawValue());
150 stmt->SetData(index++, m_targetIcons[3].GetRawValue());
151 stmt->SetData(index++, m_targetIcons[4].GetRawValue());
152 stmt->SetData(index++, m_targetIcons[5].GetRawValue());
153 stmt->SetData(index++, m_targetIcons[6].GetRawValue());
154 stmt->SetData(index++, m_targetIcons[7].GetRawValue());
155 stmt->SetData(index++, uint8(m_groupType));
156 stmt->SetData(index++, uint8(m_dungeonDifficulty));
157 stmt->SetData(index++, uint8(m_raidDifficulty));
158 stmt->SetData(index++, m_masterLooterGuid.GetCounter());
159
160 CharacterDatabase.Execute(stmt);
161
162 ASSERT(AddMember(leader)); // If the leader can't be added to a new group because it appears full, something is clearly wrong.
163
164 sScriptMgr->OnCreate(this, leader);
165 }
166 else if (!AddMember(leader))
167 return false;
168
169 return true;
170}
#define ASSERT
Definition: Errors.h:68
#define sGroupMgr
Definition: GroupMgr.h:51
@ GROUPTYPE_BGRAID
Definition: Group.h:89
@ GROUP_LOOT
Definition: LootMgr.h:61
@ 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:388
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)
752{
753 sScriptMgr->OnGroupDisband(this);
754
755 Player* player;
756 uint32 instanceId = 0;
757
758 for (member_citerator citr = m_memberSlots.begin(); citr != m_memberSlots.end(); ++citr)
759 {
760 if (!isBGGroup() && !isBFGroup())
761 {
762 sCharacterCache->ClearCharacterGroup(citr->guid);
763 }
764
765 player = ObjectAccessor::FindConnectedPlayer(citr->guid);
766
767 if (player && !instanceId && !isBGGroup() && !isBFGroup())
768 {
769 instanceId = player->GetInstanceId();
770 }
771
772 _homebindIfInstance(player);
773 if (!isBGGroup() && !isBFGroup())
775
776 if (!player)
777 continue;
778
779 //we cannot call _removeMember because it would invalidate member iterator
780 //if we are removing player from battleground raid
781 if (isBGGroup() || isBFGroup())
783 else
784 {
785 //we can remove player who is in battleground from his original group
786 if (player->GetOriginalGroup() == this)
787 player->SetOriginalGroup(nullptr);
788 else
789 player->SetGroup(nullptr);
790 }
791
792 // quest related GO state dependent from raid membership
793 if (isRaidGroup())
795
796 WorldPacket data;
797 if (!hideDestroy)
798 {
800 player->GetSession()->SendPacket(&data);
801 }
802
803 //we already removed player from group and in player->GetGroup() is his original group, send update
804 if (Group* group = player->GetGroup())
805 {
806 group->SendUpdate();
807 }
808 else
809 {
810 data.Initialize(SMSG_GROUP_LIST, 1 + 1 + 1 + 1 + 8 + 4 + 4 + 8);
811 data << uint8(0x10) << uint8(0) << uint8(0) << uint8(0);
812 data << m_guid << uint32(m_counter) << uint32(0) << uint64(0);
813 player->GetSession()->SendPacket(&data);
814 }
815 }
816 RollId.clear();
817 m_memberSlots.clear();
818
820
821 if (!isBGGroup() && !isBFGroup())
822 {
823 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
824
826 stmt->SetData(0, GetGUID().GetCounter());
827 trans->Append(stmt);
828
829 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GROUP_MEMBER_ALL);
830 stmt->SetData(0, GetGUID().GetCounter());
831 trans->Append(stmt);
832
833 CharacterDatabase.CommitTransaction(trans);
834
835 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_LFG_DATA);
836 stmt->SetData(0, GetGUID().GetCounter());
837 CharacterDatabase.Execute(stmt);
838 }
839
840 // Cleaning up instance saved data for gameobjects when a group is disbanded
841 sInstanceSaveMgr->DeleteInstanceSavedData(instanceId);
842
843 sGroupMgr->RemoveGroup(this);
844 delete this;
845}
std::uint64_t uint64
Definition: Define.h:106
@ INSTANCE_RESET_GROUP_LEAVE
Definition: Map.h:813
@ 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:13135
void RemoveAllInvites()
Definition: Group.cpp:359
void _homebindIfInstance(Player *player)
Definition: Group.cpp:2179
void Initialize(uint16 opcode, std::size_t newres=200)
Definition: WorldPacket.h:68

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)
2540{
2541 for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next())
2542 {
2543 Player* member = itr->GetSource();
2544 if (!member)
2545 continue;
2546
2547 worker(member);
2548 }
2549}

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

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

◆ EndRoll()

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

References CountTheRoll(), and RollId.

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

◆ GetDifficulty()

Difficulty Group::GetDifficulty ( bool  isRaid) const
2440{
2441 return isRaid ? m_raidDifficulty : m_dungeonDifficulty;
2442}

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
2445{
2446 return m_dungeonDifficulty;
2447}

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
2288{
2289 return m_groupType;
2290}

References m_groupType.

◆ GetGUID()

◆ GetInvited() [1/2]

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

References m_invitees.

◆ GetInvited() [2/2]

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

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
2308{
2309 return m_leaderName.c_str();
2310}

References m_leaderName.

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

◆ GetLooterGuid()

ObjectGuid Group::GetLooterGuid ( ) const
2318{
2319 return m_looterGuid;
2320}

References m_looterGuid.

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

◆ GetLootMethod()

◆ GetLootThreshold()

ItemQualities Group::GetLootThreshold ( ) const
2328{
2329 return m_lootThreshold;
2330}

References m_lootThreshold.

Referenced by Loot::FillLoot().

◆ GetMasterLooterGuid()

ObjectGuid Group::GetMasterLooterGuid ( ) const

◆ GetMemberGroup()

uint8 Group::GetMemberGroup ( ObjectGuid  guid) const
2381{
2382 member_citerator mslot = _getMemberCSlot(guid);
2383 if (mslot == m_memberSlots.end())
2384 return (MAX_RAID_SUBGROUPS + 1);
2385 return mslot->group;
2386}
member_citerator _getMemberCSlot(ObjectGuid Guid) const
Definition: Group.cpp:2485

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)
2343{
2344 for (member_citerator itr = m_memberSlots.begin(); itr != m_memberSlots.end(); ++itr)
2345 if (itr->name == name)
2346 return itr->guid;
2347
2348 return ObjectGuid::Empty;
2349}

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
2450{
2451 return m_raidDifficulty;
2452}

References m_raidDifficulty.

Referenced by AddMember().

◆ GetRoll()

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

References RollId.

Referenced by CountRollVote().

◆ GroupLoot()

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

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
2283{
2284 return GetMembersCount() > 0;
2285}

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
2455{
2456 return !RollId.empty();
2457}

References RollId.

Referenced by Player::CanUninviteFromGroup().

◆ LinkMember()

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

References LinkedListHead::insertFirst(), and m_memberMgr.

Referenced by GroupReference::targetObjectBuildLink().

◆ LoadGroupFromDB()

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

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 
)
228{
229 MemberSlot member;
230 member.guid = ObjectGuid::Create<HighGuid::Player>(guidLow);
231
232 // skip non-existed member
233 if (!sCharacterCache->GetCharacterNameByGuid(member.guid, member.name))
234 {
236 stmt->SetData(0, guidLow);
237 stmt->SetData(1, GetGUID().GetCounter());
238 CharacterDatabase.Execute(stmt);
239 return;
240 }
241
242 member.group = subgroup;
243 member.flags = memberFlags;
244 member.roles = roles;
245
246 m_memberSlots.push_back(member);
247
248 if (!isBGGroup() && !isBFGroup())
249 {
250 sCharacterCache->UpdateCharacterGroup(ObjectGuid(HighGuid::Player, guidLow), GetGUID());
251 }
252
253 SubGroupCounterIncrease(subgroup);
254
255 sLFGMgr->SetupGroupMember(member.guid, GetGUID());
256}
@ 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 
)
1308{
1309 LOG_DEBUG("network", "Group::MasterLoot (SMSG_LOOT_MASTER_LIST, 330)");
1310
1311 for (std::vector<LootItem>::iterator i = loot->items.begin(); i != loot->items.end(); ++i)
1312 {
1313 if (i->freeforall)
1314 continue;
1315
1316 i->is_blocked = !i->is_underthreshold;
1317 }
1318
1319 for (std::vector<LootItem>::iterator i = loot->quest_items.begin(); i != loot->quest_items.end(); ++i)
1320 {
1321 if (!i->follow_loot_rules)
1322 continue;
1323
1324 i->is_blocked = !i->is_underthreshold;
1325 }
1326
1327 std::vector<Player*> looters;
1328 for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next())
1329 {
1330 Player* looter = itr->GetSource();
1331 if (!looter->IsInWorld())
1332 {
1333 continue;
1334 }
1335
1336 if (looter->IsAtLootRewardDistance(pLootedObject))
1337 {
1338 looters.push_back(looter);
1339 }
1340 }
1341
1342 WorldPacket data(SMSG_LOOT_MASTER_LIST, 1 + looters.size() * (1 + 8));
1343 data << uint8(looters.size());
1344
1345 for (Player* looter : looters)
1346 {
1347 data << looter->GetGUID();
1348 }
1349
1350 for (Player* looter : looters)
1351 {
1352 looter->GetSession()->SendPacket(&data);
1353 }
1354}
@ SMSG_LOOT_MASTER_LIST
Definition: Opcodes.h:706
bool IsInWorld() const
Definition: Object.h:107

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

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 ( )
1778{
1779 for (member_citerator citr = m_memberSlots.begin(); citr != m_memberSlots.end(); ++citr)
1780 {
1781 Player* player = ObjectAccessor::FindConnectedPlayer(citr->guid);
1782 if (!player)
1783 {
1785 data << citr->guid;
1786 data << uint8(0);
1787 BroadcastReadyCheck(&data);
1788 }
1789 }
1790}
@ MSG_RAID_READY_CHECK_CONFIRM
Definition: Opcodes.h:972
void BroadcastReadyCheck(WorldPacket const *packet)
Definition: Group.cpp:1766

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

Referenced by WorldSession::HandleRaidReadyCheckOpcode().

◆ RemoveAllInvites()

void Group::RemoveAllInvites ( )
360{
361 for (InvitesList::iterator itr = m_invitees.begin(); itr != m_invitees.end(); ++itr)
362 if (*itr)
363 (*itr)->SetGroupInvite(nullptr);
364
365 m_invitees.clear();
366}

References m_invitees.

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

◆ RemoveInvite()

void Group::RemoveInvite ( Player player)
350{
351 if (player)
352 {
353 if (!m_invitees.empty())
354 m_invitees.erase(player);
355 player->SetGroupInvite(nullptr);
356 }
357}

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

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)
2514{
2515 for (member_witerator itr = m_memberSlots.begin(); itr != m_memberSlots.end(); ++itr)
2516 if (itr->flags & flag)
2517 itr->flags &= ~flag;
2518}

References m_memberSlots.

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

◆ ResetInstances()

void Group::ResetInstances ( uint8  method,
bool  isRaid,
Player leader 
)
2112{
2113 if (isBGGroup() || isBFGroup() || isLFGGroup())
2114 return;
2115
2116 switch (method)
2117 {
2118 case INSTANCE_RESET_ALL:
2119 {
2120 if (leader->GetDifficulty(false) != DUNGEON_DIFFICULTY_NORMAL)
2121 break;
2122 std::vector<InstanceSave*> toUnbind;
2123 BoundInstancesMap const& m_boundInstances = sInstanceSaveMgr->PlayerGetBoundInstances(leader->GetGUID(), Difficulty(DUNGEON_DIFFICULTY_NORMAL));
2124 for (BoundInstancesMap::const_iterator itr = m_boundInstances.begin(); itr != m_boundInstances.end(); ++itr)
2125 {
2126 InstanceSave* instanceSave = itr->second.save;
2127 MapEntry const* entry = sMapStore.LookupEntry(itr->first);
2128 if (!entry || entry->IsRaid() || !instanceSave->CanReset())
2129 continue;
2130
2131 Map* map = sMapMgr->FindMap(instanceSave->GetMapId(), instanceSave->GetInstanceId());
2132 if (!map || map->ToInstanceMap()->Reset(method))
2133 {
2134 leader->SendResetInstanceSuccess(instanceSave->GetMapId());
2135 toUnbind.push_back(instanceSave);
2136 }
2137 else
2138 {
2139 leader->SendResetInstanceFailed(0, instanceSave->GetMapId());
2140 }
2141
2142 sInstanceSaveMgr->DeleteInstanceSavedData(instanceSave->GetInstanceId());
2143 }
2144 for (std::vector<InstanceSave*>::const_iterator itr = toUnbind.begin(); itr != toUnbind.end(); ++itr)
2145 sInstanceSaveMgr->UnbindAllFor(*itr);
2146 }
2147 break;
2149 {
2150 std::vector<InstanceSave*> toUnbind;
2151 BoundInstancesMap const& m_boundInstances = sInstanceSaveMgr->PlayerGetBoundInstances(leader->GetGUID(), leader->GetDifficulty(isRaid));
2152 for (BoundInstancesMap::const_iterator itr = m_boundInstances.begin(); itr != m_boundInstances.end(); ++itr)
2153 {
2154 InstanceSave* instanceSave = itr->second.save;
2155 MapEntry const* entry = sMapStore.LookupEntry(itr->first);
2156 if (!entry || entry->IsRaid() != isRaid || !instanceSave->CanReset())
2157 continue;
2158
2159 Map* map = sMapMgr->FindMap(instanceSave->GetMapId(), instanceSave->GetInstanceId());
2160 if (!map || map->ToInstanceMap()->Reset(method))
2161 {
2162 leader->SendResetInstanceSuccess(instanceSave->GetMapId());
2163 toUnbind.push_back(instanceSave);
2164 }
2165 else
2166 {
2167 leader->SendResetInstanceFailed(0, instanceSave->GetMapId());
2168 }
2169
2170 sInstanceSaveMgr->DeleteInstanceSavedData(instanceSave->GetInstanceId());
2171 }
2172 for (std::vector<InstanceSave*>::const_iterator itr = toUnbind.begin(); itr != toUnbind.end(); ++itr)
2173 sInstanceSaveMgr->UnbindAllFor(*itr);
2174 }
2175 break;
2176 }
2177}
#define sMapMgr
Definition: MapMgr.h:219
@ INSTANCE_RESET_CHANGE_DIFFICULTY
Definition: Map.h:810
@ INSTANCE_RESET_ALL
Definition: Map.h:809
std::unordered_map< uint32, InstancePlayerBind > BoundInstancesMap
Definition: InstanceSaveMgr.h:46
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:311
InstanceMap * ToInstanceMap()
Definition: Map.h:544
bool Reset(uint8 method, GuidList *globalSkipList=nullptr)
Definition: Map.cpp:3108
Definition: DBCStructure.h:1324
bool IsRaid() const
Definition: DBCStructure.h:1353

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 ( )
2212{
2214 Player* pMember = nullptr;
2215 for (member_citerator citr = m_memberSlots.begin(); citr != m_memberSlots.end(); ++citr)
2216 {
2217 pMember = ObjectAccessor::FindPlayer(citr->guid);
2218 if (pMember && pMember->GetSession() && !pMember->GetSession()->IsSocketClosed()
2219 && m_maxEnchantingLevel < pMember->GetSkillValue(SKILL_ENCHANTING))
2220 {
2222 }
2223 }
2224}
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
2368{
2369 member_citerator mslot1 = _getMemberCSlot(guid1);
2370 if (mslot1 == m_memberSlots.end() || !slot2)
2371 return false;
2372 return (mslot1->group == slot2->group);
2373}

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

◆ SameSubGroup() [2/3]

bool Group::SameSubGroup ( ObjectGuid  guid1,
ObjectGuid  guid2 
) const
2360{
2361 member_citerator mslot2 = _getMemberCSlot(guid2);
2362 if (mslot2 == m_memberSlots.end())
2363 return false;
2364 return SameSubGroup(guid1, &*mslot2);
2365}
bool SameSubGroup(ObjectGuid guid1, ObjectGuid guid2) const
Definition: Group.cpp:2359

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
1793{
1794 if (!member1 || !member2)
1795 return false;
1796
1797 if (member1->GetGroup() != this || member2->GetGroup() != this)
1798 return false;
1799 else
1800 return member1->GetSubGroup() == member2->GetSubGroup();
1801}

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

◆ SendLootAllPassed()

void Group::SendLootAllPassed ( Roll const &  roll)
945{
946 WorldPacket data(SMSG_LOOT_ALL_PASSED, (8 + 4 + 4 + 4 + 4));
947 data << roll.itemGUID; // Guid of the item rolled
948 data << uint32(roll.itemSlot); // Item loot slot
949 data << uint32(roll.itemid); // The itemEntryId for the item that shall be rolled for
950 data << uint32(roll.itemRandomPropId); // Item random property ID
951 data << uint32(roll.itemRandomSuffix); // Item random suffix ID
952
953 for (Roll::PlayerVote::const_iterator itr = roll.playerVote.begin(); itr != roll.playerVote.end(); ++itr)
954 {
955 Player* player = ObjectAccessor::FindConnectedPlayer(itr->first);
956 if (!player)
957 continue;
958
959 if (itr->second != NOT_VALID)
960 player->GetSession()->SendPacket(&data);
961 }
962}
@ 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 
)
966{
967 ASSERT(creature);
968
969 WorldPacket data(SMSG_LOOT_LIST, (8 + 8));
970 data << creature->GetGUID();
971
972 if (GetLootMethod() == MASTER_LOOT && creature->loot.hasOverThresholdItem())
974 else
975 data << uint8(0);
976
977 if (groupLooter)
978 data << groupLooter->GetPackGUID();
979 else
980 data << uint8(0);
981
982 BroadcastPacket(&data, false);
983}
@ MASTER_LOOT
Definition: LootMgr.h:60
@ SMSG_LOOT_LIST
Definition: Opcodes.h:1047
Loot loot
Definition: Creature.h:226
PackedGuid WriteAsPacked() const
Definition: ObjectGuid.h:316
ObjectGuid GetMasterLooterGuid() const
Definition: Group.cpp:2322
LootMethod GetLootMethod() const
Definition: Group.cpp:2312
bool hasOverThresholdItem() const
Definition: LootMgr.cpp:981

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 
)
898{
899 WorldPacket data(SMSG_LOOT_ROLL, (8 + 4 + 8 + 4 + 4 + 4 + 1 + 1 + 1));
900 data << sourceGuid; // guid of the item rolled
901 data << uint32(roll.itemSlot); // slot
902 data << targetGuid;
903 data << uint32(roll.itemid); // the itemEntryId for the item that shall be rolled for
904 data << uint32(roll.itemRandomSuffix); // randomSuffix
905 data << uint32(roll.itemRandomPropId); // Item random property ID
906 data << uint8(rollNumber); // 0: "Need for: [item name]" > 127: "you passed on: [item name]" Roll number
907 data << uint8(rollType); // 0: "Need for: [item name]" 0: "You have selected need for [item name] 1: need roll 2: greed roll
908 data << uint8(autoPass); // 1: "You automatically passed on: %s because you cannot loot that item."
909
910 for (Roll::PlayerVote::const_iterator itr = roll.playerVote.begin(); itr != roll.playerVote.end(); ++itr)
911 {
913 if (!p)
914 continue;
915
916 if (itr->second != NOT_VALID)
917 p->GetSession()->SendPacket(&data);
918 }
919}
@ 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 
)
922{
923 WorldPacket data(SMSG_LOOT_ROLL_WON, (8 + 4 + 4 + 4 + 4 + 8 + 1 + 1));
924 data << sourceGuid; // guid of the item rolled
925 data << uint32(roll.itemSlot); // slot
926 data << uint32(roll.itemid); // the itemEntryId for the item that shall be rolled for
927 data << uint32(roll.itemRandomSuffix); // randomSuffix
928 data << uint32(roll.itemRandomPropId); // Item random property
929 data << targetGuid; // guid of the player who won.
930 data << uint8(rollNumber); // rollnumber realted to SMSG_LOOT_ROLL
931 data << uint8(rollType); // rollType related to SMSG_LOOT_ROLL
932
933 for (Roll::PlayerVote::const_iterator itr = roll.playerVote.begin(); itr != roll.playerVote.end(); ++itr)
934 {
936 if (!p)
937 continue;
938
939 if (itr->second != NOT_VALID)
940 p->GetSession()->SendPacket(&data);
941 }
942}
@ 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 
)
852{
853 WorldPacket data(SMSG_LOOT_START_ROLL, (8 + 4 + 4 + 4 + 4 + 4 + 4 + 1));
854 data << r.itemGUID; // guid of rolled item
855 data << uint32(mapid); // 3.3.3 mapid
856 data << uint32(r.itemSlot); // itemslot
857 data << uint32(r.itemid); // the itemEntryId for the item that shall be rolled for
858 data << uint32(r.itemRandomSuffix); // randomSuffix
859 data << uint32(r.itemRandomPropId); // item random property ID
860 data << uint32(r.itemCount); // items in stack
861 data << uint32(CountDown); // the countdown time to choose "need" or "greed"
862 data << uint8(r.rollVoteMask); // roll type mask
863
864 for (Roll::PlayerVote::const_iterator itr = r.playerVote.begin(); itr != r.playerVote.end(); ++itr)
865 {
867 if (!p)
868 continue;
869
870 if (itr->second == NOT_EMITED_YET)
871 p->GetSession()->SendPacket(&data);
872 }
873}
@ 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 
)
876{
877 if (!p)
878 return;
879
880 WorldPacket data(SMSG_LOOT_START_ROLL, (8 + 4 + 4 + 4 + 4 + 4 + 4 + 1));
881 data << r.itemGUID; // guid of rolled item
882 data << uint32(mapId); // 3.3.3 mapid
883 data << uint32(r.itemSlot); // itemslot
884 data << uint32(r.itemid); // the itemEntryId for the item that shall be rolled for
885 data << uint32(r.itemRandomSuffix); // randomSuffix
886 data << uint32(r.itemRandomPropId); // item random property ID
887 data << uint32(r.itemCount); // items in stack
888 data << uint32(countDown); // the countdown time to choose "need" or "greed"
889 uint8 voteMask = r.rollVoteMask;
890 if (!canNeed)
891 voteMask &= ~ROLL_FLAG_TYPE_NEED;
892 data << uint8(voteMask); // roll type mask
893
894 p->GetSession()->SendPacket(&data);
895}

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)
1642{
1643 if (!session)
1644 return;
1645
1647 data << uint8(1); // list targets
1648
1649 for (uint8 i = 0; i < TARGETICONCOUNT; ++i)
1650 {
1651 if (!m_targetIcons[i])
1652 continue;
1653
1654 data << uint8(i);
1655 data << m_targetIcons[i];
1656 }
1657
1658 session->SendPacket(&data);
1659}
@ 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 
)
1668{
1669 Player* player = ObjectAccessor::FindConnectedPlayer(playerGUID);
1670
1671 if (!player || player->GetGroup() != this)
1672 return;
1673
1674 // if MemberSlot wasn't provided
1675 if (!slot)
1676 {
1677 member_witerator witr = _getMemberWSlot(playerGUID);
1678
1679 if (witr == m_memberSlots.end()) // if there is no MemberSlot for such a player
1680 return;
1681
1682 slot = &(*witr);
1683 }
1684
1685 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));
1686 data << uint8(m_groupType); // group type (flags in 3.3)
1687 data << uint8(slot->group);
1688 data << uint8(slot->flags);
1689 data << uint8(slot->roles);
1690 if (isLFGGroup())
1691 {
1692 data << uint8(sLFGMgr->GetState(m_guid) == lfg::LFG_STATE_FINISHED_DUNGEON ? 2 : 0); // FIXME - Dungeon save status? 2 = done
1693 data << uint32(sLFGMgr->GetDungeon(m_guid));
1694 }
1695
1696 data << m_guid;
1697 data << uint32(m_counter++); // 3.3, value increases every time this packet gets sent
1698 data << uint32(GetMembersCount() - 1);
1699 for (member_citerator citr = m_memberSlots.begin(); citr != m_memberSlots.end(); ++citr)
1700 {
1701 if (slot->guid == citr->guid)
1702 continue;
1703
1704 Player* member = ObjectAccessor::FindConnectedPlayer(citr->guid);
1705
1706 uint8 onlineState = (member && !member->GetSession()->PlayerLogout()) ? MEMBER_STATUS_ONLINE : MEMBER_STATUS_OFFLINE;
1707 onlineState = onlineState | ((isBGGroup() || isBFGroup()) ? MEMBER_STATUS_PVP : 0);
1708
1709 data << citr->name;
1710 data << citr->guid; // guid
1711 data << uint8(onlineState); // online-state
1712 data << uint8(citr->group); // groupid
1713 data << uint8(citr->flags); // See enum GroupMemberFlags
1714 data << uint8(citr->roles); // Lfg Roles
1715 }
1716
1717 data << m_leaderGuid; // leader guid
1718
1719 if (GetMembersCount() - 1)
1720 {
1721 data << uint8(m_lootMethod); // loot method
1722
1724 data << m_masterLooterGuid; // master looter guid
1725 else
1726 data << uint64(0); // looter guid
1727
1728 data << uint8(m_lootThreshold); // loot threshold
1729 data << uint8(m_dungeonDifficulty); // Dungeon Difficulty
1730 data << uint8(m_raidDifficulty); // Raid Difficulty
1731 data << uint8(m_raidDifficulty >= RAID_DIFFICULTY_10MAN_HEROIC); // 3.3 Dynamic Raid Difficulty - 0 normal/1 heroic
1732 }
1733
1734 player->GetSession()->SendPacket(&data);
1735}
@ RAID_DIFFICULTY_10MAN_HEROIC
Definition: DBCEnums.h:275
@ MEMBER_STATUS_OFFLINE
Definition: Group.h:60
@ MEMBER_STATUS_PVP
Definition: Group.h:62
@ MEMBER_STATUS_ONLINE
Definition: Group.h:61
@ LFG_STATE_FINISHED_DUNGEON
Definition: LFG.h:74
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)
2394{
2395 m_bfGroup = bg;
2396}

References m_bfGroup.

Referenced by Battlefield::AddOrSetPlayerToCorrectBfGroup().

◆ SetBattlegroundGroup()

void Group::SetBattlegroundGroup ( Battleground bg)
2389{
2390 m_bgGroup = bg;
2391}

References m_bgGroup.

Referenced by Battleground::SetBgRaid().

◆ SetDifficultyChangePrevention()

◆ SetDungeonDifficulty()

void Group::SetDungeonDifficulty ( Difficulty  difficulty)
2070{
2071 m_dungeonDifficulty = difficulty;
2072 if (!isBGGroup() && !isBFGroup())
2073 {
2075
2077 stmt->SetData(1, GetGUID().GetCounter());
2078
2079 CharacterDatabase.Execute(stmt);
2080 }
2081
2082 for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next())
2083 {
2084 Player* player = itr->GetSource();
2085 player->SetDungeonDifficulty(difficulty);
2086 player->SendDungeonDifficulty(true);
2087 }
2088}
@ 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 
)
2399{
2400 // Assistants, main assistants and main tanks are only available in raid groups
2401 if (!isRaidGroup())
2402 return;
2403
2404 // Check if player is really in the raid
2405 member_witerator slot = _getMemberWSlot(guid);
2406 if (slot == m_memberSlots.end())
2407 return;
2408
2409 // Do flag specific actions, e.g ensure uniqueness
2410 switch (flag)
2411 {
2413 RemoveUniqueGroupMemberFlag(MEMBER_FLAG_MAINASSIST); // Remove main assist flag from current if any.
2414 break;
2416 RemoveUniqueGroupMemberFlag(MEMBER_FLAG_MAINTANK); // Remove main tank flag from current if any.
2417 break;
2419 break;
2420 default:
2421 return; // This should never happen
2422 }
2423
2424 // Switch the actual flag
2425 ToggleGroupMemberFlag(slot, flag, apply);
2426
2427 // Preserve the new setting in the db
2429
2430 stmt->SetData(0, slot->flags);
2431 stmt->SetData(1, guid.GetCounter());
2432
2433 CharacterDatabase.Execute(stmt);
2434
2435 // Broadcast the changes to the group
2436 SendUpdate();
2437}
@ 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:2513

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 
)
2247{
2248 member_witerator slot = _getMemberWSlot(guid);
2249 if (slot == m_memberSlots.end())
2250 return;
2251
2252 slot->roles = roles;
2253 SendUpdate();
2254}

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

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

◆ SetLooterGuid()

void Group::SetLooterGuid ( ObjectGuid  guid)
2232{
2233 m_looterGuid = guid;
2234}

References m_looterGuid.

Referenced by UpdateLooterGuid().

◆ SetLootMethod()

void Group::SetLootMethod ( LootMethod  method)
2227{
2228 m_lootMethod = method;
2229}

References m_lootMethod.

Referenced by WorldSession::HandleLootMethodOpcode().

◆ SetLootThreshold()

void Group::SetLootThreshold ( ItemQualities  threshold)
2242{
2243 m_lootThreshold = threshold;
2244}

References m_lootThreshold.

Referenced by WorldSession::HandleLootMethodOpcode().

◆ SetMasterLooterGuid()

void Group::SetMasterLooterGuid ( ObjectGuid  guid)
2237{
2238 m_masterLooterGuid = guid;
2239}

References m_masterLooterGuid.

Referenced by WorldSession::HandleLootMethodOpcode().

◆ SetRaidDifficulty()

void Group::SetRaidDifficulty ( Difficulty  difficulty)
2091{
2092 m_raidDifficulty = difficulty;
2093 if (!isBGGroup() && !isBFGroup())
2094 {
2096
2097 stmt->SetData(0, uint8(m_raidDifficulty));
2098 stmt->SetData(1, GetGUID().GetCounter());
2099
2100 CharacterDatabase.Execute(stmt);
2101 }
2102
2103 for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next())
2104 {
2105 Player* player = itr->GetSource();
2106 player->SetRaidDifficulty(difficulty);
2107 player->SendRaidDifficulty(true);
2108 }
2109}
@ 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 
)
1621{
1622 if (id >= TARGETICONCOUNT)
1623 return;
1624
1625 // clean other icons
1626 if (targetGuid)
1627 for (int i = 0; i < TARGETICONCOUNT; ++i)
1628 if (m_targetIcons[i] == targetGuid)
1630
1631 m_targetIcons[id] = targetGuid;
1632
1633 WorldPacket data(MSG_RAID_TARGET_UPDATE, (1 + 8 + 1 + 8));
1634 data << uint8(0); // set targets
1635 data << whoGuid;
1636 data << uint8(id);
1637 data << targetGuid;
1638 BroadcastPacket(&data, true);
1639}
void SetTargetIcon(uint8 id, ObjectGuid whoGuid, ObjectGuid targetGuid)
Definition: Group.cpp:1620

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
2508{
2510 --m_subGroupsCounts[subgroup];
2511}

References m_subGroupsCounts.

Referenced by ChangeMembersGroup(), and RemoveMember().

◆ SubGroupCounterIncrease()

void Group::SubGroupCounterIncrease ( uint8  subgroup)
protected
2502{
2504 ++m_subGroupsCounts[subgroup];
2505}

References m_subGroupsCounts.

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

◆ ToggleGroupMemberFlag()

void Group::ToggleGroupMemberFlag ( member_witerator  slot,
uint8  flag,
bool  apply 
)
protected
2521{
2522 if (apply)
2523 slot->flags |= flag;
2524 else
2525 slot->flags &= ~flag;
2526}

Referenced by ChangeLeader(), and SetGroupMemberFlag().

◆ UpdateLooterGuid()

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

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)
1738{
1739 if (!player || !player->IsInWorld())
1740 return;
1741
1742 WorldPacket data;
1743 player->GetSession()->BuildPartyMemberStatsChangedPacket(player, &data);
1744
1745 for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next())
1746 {
1747 Player* member = itr->GetSource();
1748 if (member && (!member->IsInMap(player) || !member->IsWithinDist(player, member->GetSightRange(player), false)))
1749 member->GetSession()->SendPacket(&data);
1750 }
1751}
bool IsWithinDist(WorldObject const *obj, float dist2compare, bool is3D=true, bool useBoundingRadius=true) const
Definition: Object.cpp:1327
bool IsInMap(WorldObject const *obj) const
Definition: Object.cpp:1296
float GetSightRange(WorldObject const *target=nullptr) const override
Definition: Player.cpp:16316
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