AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
lfg::LFGMgr Class Reference

#include "LFGMgr.h"

Public Member Functions

void Update (uint32 diff, uint8 task)
 
void FinishDungeon (ObjectGuid gguid, uint32 dungeonId, Map const *currMap)
 Finish the dungeon for the given group. All check are performed using internal lfg data.
 
void LoadRewards ()
 Loads rewards for random dungeons.
 
void LoadLFGDungeons (bool reload=false)
 Loads dungeons from dbc and adds teleport coords.
 
LfgDungeonSet FilterCooldownDungeons (LfgDungeonSet const &dungeons, LfgRolesMap const &players)
 Filters out recently completed dungeons from the proposal set for the given players.
 
void ClearDungeonCooldowns ()
 Clears all dungeon cooldowns for all players.
 
bool selectedRandomLfgDungeon (ObjectGuid guid)
 Check if given guid applied for random dungeon.
 
bool inLfgDungeonMap (ObjectGuid guid, uint32 map, Difficulty difficulty)
 Check if given guid applied for given map and difficulty. Used to know.
 
LfgDungeonSet const & GetSelectedDungeons (ObjectGuid guid)
 Get selected dungeons.
 
LfgState GetState (ObjectGuid guid)
 Get current lfg state.
 
uint32 GetDungeon (ObjectGuid guid, bool asId=true)
 Get current dungeon.
 
uint32 GetDungeonMapId (ObjectGuid guid)
 Get the map id of the current dungeon.
 
uint8 GetKicksLeft (ObjectGuid gguid)
 Get kicks left in current group.
 
void _LoadFromDB (Field *fields, ObjectGuid guid)
 Load Lfg group info from DB.
 
void SetupGroupMember (ObjectGuid guid, ObjectGuid gguid)
 Initializes player data after loading group data from DB.
 
uint32 GetLFGDungeonEntry (uint32 id)
 Return Lfg dungeon entry for given dungeon id.
 
uint8 GetRoles (ObjectGuid guid)
 Get current player roles.
 
std::string const & GetComment (ObjectGuid gguid)
 Get current player comment (used for LFR)
 
uint32 GetOptions ()
 Gets current lfg options.
 
void SetOptions (uint32 options)
 Sets new lfg options.
 
bool isOptionEnabled (uint32 option)
 Checks if given lfg option is enabled.
 
void Clean ()
 Clears queue - Only for internal testing.
 
ObjectGuid GetLeader (ObjectGuid guid)
 Get leader of the group (using internal data)
 
void InitializeLockedDungeons (Player *player, Group const *group=nullptr)
 Initializes locked dungeons for given player (called at login or level change)
 
void SetTeam (ObjectGuid guid, TeamId teamId)
 Sets player team.
 
void SetGroup (ObjectGuid guid, ObjectGuid group)
 Sets player group.
 
ObjectGuid GetGroup (ObjectGuid guid)
 Gets player group.
 
void SetLeader (ObjectGuid gguid, ObjectGuid leader)
 Sets the leader of the group.
 
void RemoveGroupData (ObjectGuid guid)
 Removes saved group data.
 
uint8 RemovePlayerFromGroup (ObjectGuid gguid, ObjectGuid guid)
 Removes a player from a group.
 
void AddPlayerToGroup (ObjectGuid gguid, ObjectGuid guid)
 Adds player to group.
 
void AddPlayerQueuedForRandomDungeonToGroup (ObjectGuid gguid, ObjectGuid guid)
 Store player that selected random queue to group.
 
bool IsPlayerQueuedForRandomDungeon (ObjectGuid guid)
 
void SetRandomPlayersCount (ObjectGuid guid, uint8 count)
 Xinef: Set Random Players Count.
 
uint8 GetRandomPlayersCount (ObjectGuid guid)
 Xinef: Get Random Players Count.
 
LfgLockMap const & GetLockedDungeons (ObjectGuid guid)
 Get locked dungeons.
 
LfgUpdateData GetLfgStatus (ObjectGuid guid)
 Returns current lfg status.
 
bool IsSeasonActive (uint32 dungeonId)
 Checks if Seasonal dungeon is active.
 
bool IsDungeonDisabled (uint32 mapId, Difficulty difficulty) const
 Checks if given dungeon map is disabled.
 
LfgReward const * GetRandomDungeonReward (uint32 dungeon, uint8 level)
 Gets the random dungeon reward corresponding to given dungeon and player level.
 
LfgDungeonSet GetRandomAndSeasonalDungeons (uint8 level, uint8 expansion)
 Returns all random and seasonal dungeons for given level and expansion.
 
void TeleportPlayer (Player *player, bool out, WorldLocation const *teleportLocation=nullptr)
 Teleport a player to/from selected dungeon.
 
void InitBoot (ObjectGuid gguid, ObjectGuid kicker, ObjectGuid victim, std::string const &reason)
 Inits new proposal to boot a player.
 
void UpdateBoot (ObjectGuid guid, bool accept)
 Updates player boot proposal with new player answer.
 
void UpdateProposal (uint32 proposalId, ObjectGuid guid, bool accept)
 Updates proposal to join dungeon with player answer.
 
void UpdateRoleCheck (ObjectGuid gguid, ObjectGuid guid=ObjectGuid::Empty, uint8 roles=PLAYER_ROLE_NONE)
 Updates the role check with player answer.
 
void SetRoles (ObjectGuid guid, uint8 roles)
 Sets player lfg roles.
 
void SetComment (ObjectGuid guid, std::string const &comment)
 Sets player lfr comment.
 
void JoinLfg (Player *player, uint8 roles, LfgDungeonSet &dungeons, std::string const &comment)
 Join Lfg with selected roles, dungeons and comment.
 
void LeaveLfg (ObjectGuid guid)
 Leaves lfg.
 
void LeaveAllLfgQueues (ObjectGuid guid, bool allowgroup, ObjectGuid groupguid=ObjectGuid::Empty)
 pussywizard: cleans all queues' data
 
void JoinRaidBrowser (Player *player, uint8 roles, LfgDungeonSet &dungeons, std::string comment)
 pussywizard: Raid Browser
 
void LeaveRaidBrowser (ObjectGuid guid)
 
void LfrSearchAdd (Player *p, uint32 dungeonId)
 
void LfrSearchRemove (Player *p)
 
void SendRaidBrowserCachedList (Player *player, uint32 dungeonId)
 
void UpdateRaidBrowser (uint32 diff)
 
void LfrSetComment (Player *p, std::string comment)
 
void SendRaidBrowserJoinedPacket (Player *p, LfgDungeonSet &dungeons, std::string comment)
 
void RBPacketAppendGroup (RBInternalInfo const &info, ByteBuffer &buffer)
 
void RBPacketAppendPlayer (RBInternalInfo const &info, ByteBuffer &buffer)
 
void RBPacketBuildDifference (WorldPacket &differencePacket, uint32 dungeonId, uint32 deletedCounter, ByteBuffer const &bufferDeleted, uint32 groupCounter, ByteBuffer const &bufferGroups, uint32 playerCounter, ByteBuffer const &bufferPlayers)
 
void RBPacketBuildFull (WorldPacket &fullPacket, uint32 dungeonId, RBInternalInfoMap const &infoMap)
 
LfgState GetOldState (ObjectGuid guid)
 Get last lfg state (NONE, DUNGEON or FINISHED_DUNGEON)
 
bool IsLfgGroup (ObjectGuid guid)
 Check if given group guid is lfg.
 
uint8 GetPlayerCount (ObjectGuid guid)
 Gets the player count of given group.
 
uint32 AddProposal (LfgProposal &proposal)
 Add a new Proposal.
 
bool AllQueued (Lfg5Guids const &check)
 Checks if all players are queued.
 
void ToggleTesting ()
 
bool IsTesting () const
 For 1 player queue testing.
 
void SetDungeon (ObjectGuid guid, uint32 dungeon)
 
LFGDungeonData const * GetLFGDungeon (uint32 id)
 

Static Public Member Functions

static LFGMgr * instance ()
 
static uint8 CheckGroupRoles (LfgRolesMap &groles)
 Checks if given roles match, modifies given roles map with new roles.
 
static bool HasIgnore (ObjectGuid guid1, ObjectGuid guid2)
 Checks if given players are ignoring each other.
 
static void SendLfgQueueStatus (ObjectGuid guid, LfgQueueStatusData const &data)
 Sends queue status to player.
 

Private Types

typedef std::unordered_map< ObjectGuid, RBEntryInfo > RBEntryInfoMap
 
typedef std::unordered_map< uint32, RBEntryInfoMap > RBStoreMap
 
typedef std::unordered_map< ObjectGuid, uint32 > RBSearchersMap
 
typedef std::unordered_map< uint32, WorldPacket > RBCacheMap
 
typedef std::unordered_map< ObjectGuid, RBInternalInfo > RBInternalInfoMap
 
typedef std::unordered_map< uint32, RBInternalInfoMap > RBInternalInfoMapMap
 
typedef std::set< uint32 > RBUsedDungeonsSet
 
typedef std::unordered_map< uint32, TimePoint > LfgDungeonCooldownMap
 
typedef std::unordered_map< ObjectGuid, LfgDungeonCooldownMap > LfgDungeonCooldownContainer
 

Private Member Functions

 LFGMgr ()
 
 ~LFGMgr ()
 
TeamId GetTeam (ObjectGuid guid)
 
void RestoreState (ObjectGuid guid, char const *debugMsg)
 
void ClearState (ObjectGuid guid, char const *debugMsg)
 
void SetSelectedDungeons (ObjectGuid guid, LfgDungeonSet const &dungeons)
 
void SetLockedDungeons (ObjectGuid guid, LfgLockMap const &lock)
 
void DecreaseKicksLeft (ObjectGuid guid)
 
void SetState (ObjectGuid guid, LfgState state)
 
void SetCanOverrideRBState (ObjectGuid guid, bool val)
 
void GetCompatibleDungeons (LfgDungeonSet &dungeons, LfgGuidSet const &players, LfgLockPartyMap &lockMap, uint32 randomDungeonId=0)
 
void _SaveToDB (ObjectGuid guid)
 
void RemoveProposal (LfgProposalContainer::iterator itProposal, LfgUpdateType type)
 
void MakeNewGroup (LfgProposal const &proposal)
 
LFGQueue & GetQueue (ObjectGuid guid)
 
LfgDungeonSet const & GetDungeonsByRandom (uint32 randomdungeon)
 
LfgType GetDungeonType (uint32 dungeon)
 
void SendLfgBootProposalUpdate (ObjectGuid guid, LfgPlayerBoot const &boot)
 
void SendLfgJoinResult (ObjectGuid guid, LfgJoinResultData const &data)
 
void SendLfgRoleChosen (ObjectGuid guid, ObjectGuid pguid, uint8 roles)
 
void SendLfgRoleCheckUpdate (ObjectGuid guid, LfgRoleCheck const &roleCheck)
 
void SendLfgUpdateParty (ObjectGuid guid, LfgUpdateData const &data)
 
void SendLfgUpdatePlayer (ObjectGuid guid, LfgUpdateData const &data)
 
void SendLfgUpdateProposal (ObjectGuid guid, LfgProposal const &proposal)
 
LfgGuidSet const & GetPlayers (ObjectGuid guid)
 
void AddDungeonCooldown (ObjectGuid guid, uint32 dungeonId)
 
void CleanupDungeonCooldowns ()
 
Seconds GetDungeonCooldownDuration () const
 

Private Attributes

RBStoreMap RaidBrowserStore [2]
 
RBSearchersMap RBSearchersStore [2]
 
RBCacheMap RBCacheStore [2]
 
RBInternalInfoMapMap RBInternalInfoStorePrev [2]
 
RBInternalInfoMapMap RBInternalInfoStoreCurr [2]
 
RBUsedDungeonsSet RBUsedDungeonsStore [2]
 
uint32 m_lfgProposalId
 used as internal counter for proposals
 
uint32 m_options
 Stores config options.
 
uint32 lastProposalId
 pussywizard, store it here because of splitting LFGMgr update into tasks
 
uint32 m_raidBrowserUpdateTimer [2]
 pussywizard
 
uint32 m_raidBrowserLastUpdatedDungeonId [2]
 pussywizard: for 2 factions
 
ByteBuffer _rbBufferDeleted
 
ByteBuffer _rbBufferGroups
 
ByteBuffer _rbBufferPlayers
 
GuidSet _rbPrevGroups
 
GuidSet _rbDroppedGroups
 
RBInternalInfoMap _rbCopy
 
LfgQueueContainer QueuesStore
 Queues.
 
LfgCachedDungeonContainer CachedDungeonMapStore
 Stores all dungeons by groupType.
 
LfgRewardContainer RewardMapStore
 Stores rewards for random dungeons.
 
LFGDungeonContainer LfgDungeonStore
 
LfgRoleCheckContainer RoleChecksStore
 Current Role checks.
 
LfgProposalContainer ProposalsStore
 Current Proposals.
 
LfgPlayerBootContainer BootsStore
 Current player kicks.
 
LfgPlayerDataContainer PlayersStore
 Player data.
 
LfgGroupDataContainer GroupsStore
 Group data.
 
bool m_Testing
 
LfgDungeonCooldownContainer DungeonCooldownStore
 Stores dungeon cooldowns per player.
 

Detailed Description

Member Typedef Documentation

◆ LfgDungeonCooldownContainer

◆ LfgDungeonCooldownMap

typedef std::unordered_map<uint32 , TimePoint > lfg::LFGMgr::LfgDungeonCooldownMap
private

◆ RBCacheMap

typedef std::unordered_map<uint32 , WorldPacket> lfg::LFGMgr::RBCacheMap
private

◆ RBEntryInfoMap

typedef std::unordered_map<ObjectGuid , RBEntryInfo> lfg::LFGMgr::RBEntryInfoMap
private

◆ RBInternalInfoMap

typedef std::unordered_map<ObjectGuid , RBInternalInfo> lfg::LFGMgr::RBInternalInfoMap
private

◆ RBInternalInfoMapMap

typedef std::unordered_map<uint32 , RBInternalInfoMap> lfg::LFGMgr::RBInternalInfoMapMap
private

◆ RBSearchersMap

typedef std::unordered_map<ObjectGuid , uint32 > lfg::LFGMgr::RBSearchersMap
private

◆ RBStoreMap

typedef std::unordered_map<uint32 , RBEntryInfoMap> lfg::LFGMgr::RBStoreMap
private

◆ RBUsedDungeonsSet

typedef std::set<uint32 > lfg::LFGMgr::RBUsedDungeonsSet
private

Constructor & Destructor Documentation

◆ LFGMgr()

lfg::LFGMgr::LFGMgr ( )
private
47 {
48 for (uint8 team = 0; team < 2; ++team)
49 {
50 m_raidBrowserUpdateTimer[team] = 10000;
52 }
53 }
std::uint8_t uint8
Definition Define.h:109
@ CONFIG_LFG_OPTIONSMASK
Definition WorldConfig.h:331
@ CONFIG_DEBUG_LFG
Definition WorldConfig.h:125
bool m_Testing
Definition LFGMgr.h:649
uint32 m_lfgProposalId
used as internal counter for proposals
Definition LFGMgr.h:626
uint32 m_raidBrowserLastUpdatedDungeonId[2]
pussywizard: for 2 factions
Definition LFGMgr.h:630
uint32 m_options
Stores config options.
Definition LFGMgr.h:627
uint32 m_raidBrowserUpdateTimer[2]
pussywizard
Definition LFGMgr.h:629
#define sWorld
Definition World.h:337

References m_raidBrowserLastUpdatedDungeonId, and m_raidBrowserUpdateTimer.

◆ ~LFGMgr()

lfg::LFGMgr::~LFGMgr ( )
private
56 {
57 for (LfgRewardContainer::iterator itr = RewardMapStore.begin(); itr != RewardMapStore.end(); ++itr)
58 delete itr->second;
59 }
LfgRewardContainer RewardMapStore
Stores rewards for random dungeons.
Definition LFGMgr.h:641

References RewardMapStore.

Member Function Documentation

◆ _LoadFromDB()

void lfg::LFGMgr::_LoadFromDB ( Field *  fields,
ObjectGuid  guid 
)

Load Lfg group info from DB.

68 {
69 if (!fields)
70 return;
71
72 if (!guid.IsGroup())
73 return;
74
75 SetLeader(guid, ObjectGuid::Create<HighGuid::Player>(fields[0].Get<uint32>()));
76
77 uint32 dungeon = fields[17].Get<uint32>();
78 uint8 state = fields[18].Get<uint8>();
79
80 if (!dungeon || !state)
81 return;
82
83 SetDungeon(guid, dungeon);
84
85 switch (state)
86 {
89 SetState(guid, (LfgState)state);
90 break;
91 default:
92 break;
93 }
94 }
std::uint32_t uint32
Definition Define.h:107
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition Field.h:113
bool IsGroup() const
Definition ObjectGuid.h:182
void SetDungeon(ObjectGuid guid, uint32 dungeon)
Definition LFGMgr.cpp:2629
void SetState(ObjectGuid guid, LfgState state)
Definition LFGMgr.cpp:2602
void SetLeader(ObjectGuid gguid, ObjectGuid leader)
Sets the leader of the group.
Definition LFGMgr.cpp:2728
LfgState
Definition LFG.h:67
@ LFG_STATE_FINISHED_DUNGEON
Definition LFG.h:74
@ LFG_STATE_DUNGEON
Definition LFG.h:73

References Field::Get(), ObjectGuid::IsGroup(), lfg::LFG_STATE_DUNGEON, lfg::LFG_STATE_FINISHED_DUNGEON, SetDungeon(), SetLeader(), and SetState().

◆ _SaveToDB()

void lfg::LFGMgr::_SaveToDB ( ObjectGuid  guid)
private
97 {
98 if (!guid.IsGroup())
99 return;
100
102 stmt->SetData(0, guid.GetCounter());
103 stmt->SetData(1, GetDungeon(guid));
104 stmt->SetData(2, GetState(guid));
105 CharacterDatabase.Execute(stmt);
106 }
@ CHAR_REP_LFG_DATA
Definition CharacterDatabase.h:329
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition DatabaseEnv.cpp:21
LowType GetCounter() const
Definition ObjectGuid.h:149
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition PreparedStatement.h:77
Definition PreparedStatement.h:157
LfgState GetState(ObjectGuid guid)
Get current lfg state.
Definition LFGMgr.cpp:2498
uint32 GetDungeon(ObjectGuid guid, bool asId=true)
Get current dungeon.
Definition LFGMgr.cpp:2522

References CHAR_REP_LFG_DATA, CharacterDatabase, ObjectGuid::GetCounter(), GetDungeon(), GetState(), ObjectGuid::IsGroup(), and PreparedStatementBase::SetData().

Referenced by FinishDungeon(), and MakeNewGroup().

◆ AddDungeonCooldown()

void lfg::LFGMgr::AddDungeonCooldown ( ObjectGuid  guid,
uint32  dungeonId 
)
private
170 {
172 return;
173
174 DungeonCooldownStore[guid][dungeonId] = GameTime::Now();
175 }
@ CONFIG_LFG_DUNGEON_SELECTION_COOLDOWN
Definition WorldConfig.h:332
LfgDungeonCooldownContainer DungeonCooldownStore
Stores dungeon cooldowns per player.
Definition LFGMgr.h:654
TimePoint Now()
Current chrono steady_clock time point.
Definition GameTime.cpp:54

References CONFIG_LFG_DUNGEON_SELECTION_COOLDOWN, DungeonCooldownStore, GameTime::Now(), and sWorld.

Referenced by FinishDungeon().

◆ AddPlayerQueuedForRandomDungeonToGroup()

void lfg::LFGMgr::AddPlayerQueuedForRandomDungeonToGroup ( ObjectGuid  gguid,
ObjectGuid  guid 
)

Store player that selected random queue to group.

2717 {
2718 LfgDungeonSet const& dungeons = GetSelectedDungeons(guid);
2719 if (dungeons.empty())
2720 return;
2721
2722 uint32 dungeonId = *dungeons.begin();
2723 LFGDungeonData const* dungeon = GetLFGDungeon(dungeonId);
2724 if (dungeon && (dungeon->type == LFG_TYPE_RANDOM))
2725 GroupsStore[gguid].AddRandomQueuedPlayer(guid);
2726 }
LFGDungeonData const * GetLFGDungeon(uint32 id)
Definition LFGMgr.cpp:250
LfgGroupDataContainer GroupsStore
Group data.
Definition LFGMgr.h:648
LfgDungeonSet const & GetSelectedDungeons(ObjectGuid guid)
Get selected dungeons.
Definition LFGMgr.cpp:2554
@ LFG_TYPE_RANDOM
Definition LFGMgr.h:75
std::set< uint32 > LfgDungeonSet
Definition LFG.h:114

References GetLFGDungeon(), GetSelectedDungeons(), GroupsStore, lfg::LFG_TYPE_RANDOM, and lfg::LFGDungeonData::type.

◆ AddPlayerToGroup()

void lfg::LFGMgr::AddPlayerToGroup ( ObjectGuid  gguid,
ObjectGuid  guid 
)

Adds player to group.

2712 {
2713 GroupsStore[gguid].AddPlayer(guid);
2714 }

References GroupsStore.

Referenced by SetupGroupMember().

◆ AddProposal()

uint32 lfg::LFGMgr::AddProposal ( LfgProposal &  proposal)

Add a new Proposal.

1925 {
1926 proposal.id = ++m_lfgProposalId;
1927 ProposalsStore[m_lfgProposalId] = proposal;
1928 return m_lfgProposalId;
1929 }
LfgProposalContainer ProposalsStore
Current Proposals.
Definition LFGMgr.h:645

References lfg::LfgProposal::id, m_lfgProposalId, and ProposalsStore.

◆ AllQueued()

bool lfg::LFGMgr::AllQueued ( Lfg5Guids const &  check)

Checks if all players are queued.

2854 {
2855 bool ok = true;
2856
2857 if (check.empty())
2858 return false;
2859
2860 for (uint8 i = 0; i < 5 && check.guids[i]; ++i)
2861 {
2862 ObjectGuid guid = check.guids[i];
2863 if (GetState(guid) != LFG_STATE_QUEUED)
2864 {
2865 LFGQueue& queue = GetQueue(guid);
2866 queue.RemoveFromQueue(guid);
2867 ok = false;
2868 }
2869 }
2870
2871 return ok;
2872 }
Definition ObjectGuid.h:121
LFGQueue & GetQueue(ObjectGuid guid)
Definition LFGMgr.cpp:2836
@ LFG_STATE_QUEUED
Definition LFG.h:70

References lfg::Lfg5Guids::empty(), GetQueue(), GetState(), lfg::Lfg5Guids::guids, lfg::LFG_STATE_QUEUED, and lfg::LFGQueue::RemoveFromQueue().

◆ CheckGroupRoles()

uint8 lfg::LFGMgr::CheckGroupRoles ( LfgRolesMap &  groles)
static

Checks if given roles match, modifies given roles map with new roles.

1623 {
1624 if (groles.empty())
1625 return 0;
1626
1627 uint8 damage = 0;
1628 uint8 tank = 0;
1629 uint8 healer = 0;
1630
1631 for (LfgRolesMap::iterator it = groles.begin(); it != groles.end(); ++it)
1632 {
1633 uint8 const role = it->second & ~PLAYER_ROLE_LEADER;
1634 if (role == PLAYER_ROLE_NONE)
1635 return 0;
1636
1637 if (role & PLAYER_ROLE_DAMAGE)
1638 {
1639 if (role != PLAYER_ROLE_DAMAGE)
1640 {
1641 it->second -= PLAYER_ROLE_DAMAGE;
1642 if (uint8 x = CheckGroupRoles(groles))
1643 return x;
1644 it->second += PLAYER_ROLE_DAMAGE;
1645 }
1646 else if (damage == LFG_DPS_NEEDED)
1647 return 0;
1648 else
1649 damage++;
1650 }
1651
1652 if (role & PLAYER_ROLE_HEALER)
1653 {
1654 if (role != PLAYER_ROLE_HEALER)
1655 {
1656 it->second -= PLAYER_ROLE_HEALER;
1657 if (uint8 x = CheckGroupRoles(groles))
1658 return x;
1659 it->second += PLAYER_ROLE_HEALER;
1660 }
1661 else if (healer == LFG_HEALERS_NEEDED)
1662 return 0;
1663 else
1664 healer++;
1665 }
1666
1667 if (role & PLAYER_ROLE_TANK)
1668 {
1669 if (role != PLAYER_ROLE_TANK)
1670 {
1671 it->second -= PLAYER_ROLE_TANK;
1672 if (uint8 x = CheckGroupRoles(groles))
1673 return x;
1674 it->second += PLAYER_ROLE_TANK;
1675 }
1676 else if (tank == LFG_TANKS_NEEDED)
1677 return 0;
1678 else
1679 tank++;
1680 }
1681 }
1682 if ((tank + healer + damage) == uint8(groles.size()))
1683 return (8 * tank + 4 * healer + damage);
1684 return 0;
1685 }
static uint8 CheckGroupRoles(LfgRolesMap &groles)
Checks if given roles match, modifies given roles map with new roles.
Definition LFGMgr.cpp:1622
@ LFG_HEALERS_NEEDED
Definition LFG.h:33
@ LFG_TANKS_NEEDED
Definition LFG.h:32
@ LFG_DPS_NEEDED
Definition LFG.h:34
@ PLAYER_ROLE_DAMAGE
Definition LFG.h:43
@ PLAYER_ROLE_TANK
Definition LFG.h:41
@ PLAYER_ROLE_NONE
Definition LFG.h:39
@ PLAYER_ROLE_HEALER
Definition LFG.h:42

References CheckGroupRoles(), lfg::LFG_DPS_NEEDED, lfg::LFG_HEALERS_NEEDED, lfg::LFG_TANKS_NEEDED, lfg::PLAYER_ROLE_DAMAGE, lfg::PLAYER_ROLE_HEALER, lfg::PLAYER_ROLE_NONE, and lfg::PLAYER_ROLE_TANK.

Referenced by lfg::LFGQueue::CheckCompatibility(), CheckGroupRoles(), and UpdateRoleCheck().

◆ Clean()

void lfg::LFGMgr::Clean ( )

Clears queue - Only for internal testing.

2876 {
2877 QueuesStore.clear();
2878 }
LfgQueueContainer QueuesStore
Queues.
Definition LFGMgr.h:638

References QueuesStore.

◆ CleanupDungeonCooldowns()

void lfg::LFGMgr::CleanupDungeonCooldowns ( )
private
178 {
180 return;
181
182 Seconds cooldownDuration = GetDungeonCooldownDuration();
183
184 for (auto itPlayer = DungeonCooldownStore.begin(); itPlayer != DungeonCooldownStore.end(); )
185 {
186 for (auto itDungeon = itPlayer->second.begin(); itDungeon != itPlayer->second.end(); )
187 {
188 if (GameTime::HasElapsed(itDungeon->second, cooldownDuration))
189 itDungeon = itPlayer->second.erase(itDungeon);
190 else
191 ++itDungeon;
192 }
193
194 if (itPlayer->second.empty())
195 itPlayer = DungeonCooldownStore.erase(itPlayer);
196 else
197 ++itPlayer;
198 }
199 }
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition Duration.h:30
Seconds GetDungeonCooldownDuration() const
Definition LFGMgr.cpp:206
bool HasElapsed(TimePoint start, T duration)
Check if a duration has elapsed since a given time point.
Definition GameTime.h:52

References CONFIG_LFG_DUNGEON_SELECTION_COOLDOWN, DungeonCooldownStore, GetDungeonCooldownDuration(), GameTime::HasElapsed(), and sWorld.

Referenced by Update().

◆ ClearDungeonCooldowns()

void lfg::LFGMgr::ClearDungeonCooldowns ( )

Clears all dungeon cooldowns for all players.

202 {
203 DungeonCooldownStore.clear();
204 }

References DungeonCooldownStore.

◆ ClearState()

void lfg::LFGMgr::ClearState ( ObjectGuid  guid,
char const *  debugMsg 
)
private

◆ DecreaseKicksLeft()

void lfg::LFGMgr::DecreaseKicksLeft ( ObjectGuid  guid)
private
2673 {
2674 LOG_DEBUG("lfg", "LFGMgr::DecreaseKicksLeft: [{}]", guid.ToString());
2675 GroupsStore[guid].DecreaseKicksLeft();
2676 }
#define LOG_DEBUG(filterType__,...)
Definition Log.h:157
std::string ToString() const
Definition ObjectGuid.cpp:49

References GroupsStore, LOG_DEBUG, and ObjectGuid::ToString().

Referenced by UpdateBoot().

◆ FilterCooldownDungeons()

LfgDungeonSet lfg::LFGMgr::FilterCooldownDungeons ( LfgDungeonSet const &  dungeons,
LfgRolesMap const &  players 
)

Filters out recently completed dungeons from the proposal set for the given players.

212 {
214 return dungeons;
215
216 Seconds cooldownDuration = GetDungeonCooldownDuration();
217
218 LfgDungeonSet filtered;
219 for (uint32 dungeonId : dungeons)
220 {
221 bool onCooldown = false;
222 for (auto const& playerPair : players)
223 {
224 auto itPlayer = DungeonCooldownStore.find(playerPair.first);
225 if (itPlayer != DungeonCooldownStore.end())
226 {
227 auto itDungeon = itPlayer->second.find(dungeonId);
228 if (itDungeon != itPlayer->second.end() && !GameTime::HasElapsed(itDungeon->second, cooldownDuration))
229 {
230 onCooldown = true;
231 break;
232 }
233 }
234 }
235
236 if (!onCooldown)
237 filtered.insert(dungeonId);
238 }
239
240 // If all dungeons are on cooldown, return original set to avoid blocking the queue
241 if (filtered.empty())
242 {
243 LOG_DEBUG("lfg", "LFGMgr::FilterCooldownDungeons: All {} dungeons on cooldown for group, bypassing cooldown filter", dungeons.size());
244 return dungeons;
245 }
246
247 return filtered;
248 }

References CONFIG_LFG_DUNGEON_SELECTION_COOLDOWN, DungeonCooldownStore, GetDungeonCooldownDuration(), GameTime::HasElapsed(), LOG_DEBUG, and sWorld.

◆ FinishDungeon()

void lfg::LFGMgr::FinishDungeon ( ObjectGuid  gguid,
uint32  dungeonId,
Map const *  currMap 
)

Finish the dungeon for the given group. All check are performed using internal lfg data.

Finish a dungeon and give reward, if any.

Parameters
[in]guidGroup guid
[in]dungeonIdDungeonid
2338 {
2339 uint32 gDungeonId = GetDungeon(gguid);
2340 if (gDungeonId != dungeonId)
2341 {
2342 LOG_DEBUG("lfg", "LFGMgr::FinishDungeon: [{}] Finished dungeon {} but group queued for {}. Ignoring", gguid.ToString(), dungeonId, gDungeonId);
2343 return;
2344 }
2345
2346 if (GetState(gguid) == LFG_STATE_FINISHED_DUNGEON) // Shouldn't happen. Do not reward multiple times
2347 {
2348 LOG_DEBUG("lfg", "LFGMgr::FinishDungeon: [{}] Already rewarded group. Ignoring", gguid.ToString());
2349 return;
2350 }
2351
2353 _SaveToDB(gguid); // pussywizard
2354
2355 LfgGuidSet const& players = GetPlayers(gguid);
2356 for (LfgGuidSet::const_iterator it = players.begin(); it != players.end(); ++it)
2357 {
2358 ObjectGuid guid = (*it);
2360 {
2361 LOG_DEBUG("lfg", "LFGMgr::FinishDungeon: [{}] Already rewarded player. Ignoring", guid.ToString());
2362 continue;
2363 }
2364
2365 uint32 rDungeonId = 0;
2366 LfgDungeonSet const& dungeons = GetSelectedDungeons(guid);
2367 if (!dungeons.empty())
2368 rDungeonId = (*dungeons.begin());
2369
2371
2372 // Give rewards only if its a random dungeon
2373 LFGDungeonData const* dungeon = GetLFGDungeon(rDungeonId);
2374
2375 if (!dungeon || (dungeon->type != LFG_TYPE_RANDOM && !dungeon->seasonal))
2376 {
2377 LOG_DEBUG("lfg", "LFGMgr::FinishDungeon: [{}] dungeon {} is not random or seasonal", guid.ToString(), rDungeonId);
2378 continue;
2379 }
2380
2381 // Record dungeon cooldown for this player (the actual dungeon completed, not the random entry)
2382 AddDungeonCooldown(guid, dungeonId);
2383
2384 Player* player = ObjectAccessor::FindPlayer(guid);
2385 if (!player || player->FindMap() != currMap) // pussywizard: currMap - multithreading crash if on other map (map id check is not enough, binding system is not reliable)
2386 {
2387 LOG_DEBUG("lfg", "LFGMgr::FinishDungeon: [{}] not found in world", guid.ToString());
2388 continue;
2389 }
2390
2391 LFGDungeonData const* dungeonDone = GetLFGDungeon(dungeonId);
2392 uint32 mapId = dungeonDone ? uint32(dungeonDone->map) : 0;
2393
2394 if (player->GetMapId() != mapId)
2395 {
2396 LOG_DEBUG("lfg", "LFGMgr::FinishDungeon: [{}] is in map {} and should be in {} to get reward", guid.ToString(), player->GetMapId(), mapId);
2397 continue;
2398 }
2399
2400 // Remove Dungeon Finder Cooldown if still exists
2402 {
2404 }
2405
2406 // Xinef: Update achievements, set correct amount of randomly grouped players
2407 if (dungeon->difficulty == DUNGEON_DIFFICULTY_HEROIC)
2408 if (uint8 count = GetRandomPlayersCount(player->GetGUID()))
2410
2411 LfgReward const* reward = GetRandomDungeonReward(rDungeonId, player->GetLevel());
2412 if (!reward)
2413 continue;
2414
2415 // CAIS full restriction: grant no dungeon reward and leave the daily available for later
2417 continue;
2418
2419 bool done = false;
2420 Quest const* quest = sObjectMgr->GetQuestTemplate(reward->firstQuest);
2421 if (!quest)
2422 continue;
2423
2424 // if we can take the quest, means that we haven't done this kind of "run", IE: First Heroic Random of Day.
2425 if (player->CanRewardQuest(quest, false))
2426 player->RewardQuest(quest, 0, nullptr, false, true);
2427 else
2428 {
2429 done = true;
2430 quest = sObjectMgr->GetQuestTemplate(reward->otherQuest);
2431 if (!quest)
2432 continue;
2433 // we give reward without informing client (retail does this)
2434 player->RewardQuest(quest, 0, nullptr, false, true);
2435 }
2436
2437 // Give rewards
2438 LOG_DEBUG("lfg", "LFGMgr::FinishDungeon: [{}] done dungeon {}, {} previously done.", player->GetGUID().ToString(), GetDungeon(gguid), done ? " " : " not");
2439 LfgPlayerRewardData data = LfgPlayerRewardData(dungeon->Entry(), GetDungeon(gguid, false), done, quest);
2440 player->GetSession()->SendLfgPlayerReward(data);
2441 }
2442 }
@ DUNGEON_DIFFICULTY_HEROIC
Definition DBCEnums.h:270
@ ACHIEVEMENT_CRITERIA_TYPE_USE_LFD_TO_GROUP_WITH_PLAYERS
Definition DBCEnums.h:223
#define sObjectMgr
Definition ObjectMgr.h:1731
@ PLAYER_FLAGS_NO_PLAY_TIME
Definition Player.h:472
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:120
Definition Player.h:1086
void UpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscValue1=0, uint32 miscValue2=0, Unit *unit=nullptr)
Definition PlayerUpdates.cpp:2232
bool CanRewardQuest(Quest const *quest, bool msg)
Definition PlayerQuest.cpp:387
WorldSession * GetSession() const
Definition Player.h:2032
void RewardQuest(Quest const *quest, uint32 reward, Object *questGiver, bool announce=true, bool isLFGReward=false)
Definition PlayerQuest.cpp:675
bool HasPlayerFlag(PlayerFlags flags) const
Definition Player.h:1125
Definition QuestDef.h:210
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
Definition Unit.cpp:5798
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:4969
uint8 GetLevel() const
Definition Unit.h:1117
uint32 GetMapId() const
Definition Position.h:281
Map * FindMap() const
Definition Object.h:638
void SendLfgPlayerReward(lfg::LfgPlayerRewardData const &lfgPlayerRewardData)
Definition LFGHandler.cpp:479
void AddDungeonCooldown(ObjectGuid guid, uint32 dungeonId)
Definition LFGMgr.cpp:169
uint8 GetRandomPlayersCount(ObjectGuid guid)
Xinef: Get Random Players Count.
Definition LFGMgr.cpp:2771
void _SaveToDB(ObjectGuid guid)
Definition LFGMgr.cpp:96
LfgReward const * GetRandomDungeonReward(uint32 dungeon, uint8 level)
Gets the random dungeon reward corresponding to given dungeon and player level.
Definition LFGMgr.cpp:2468
LfgGuidSet const & GetPlayers(ObjectGuid guid)
Definition LFGMgr.cpp:2751
Player * FindPlayer(ObjectGuid const guid)
Definition ObjectAccessor.cpp:269
GuidSet LfgGuidSet
Definition LFG.h:117
@ LFG_SPELL_DUNGEON_COOLDOWN
Definition LFGMgr.h:53

References _SaveToDB(), ACHIEVEMENT_CRITERIA_TYPE_USE_LFD_TO_GROUP_WITH_PLAYERS, AddDungeonCooldown(), Player::CanRewardQuest(), lfg::LFGDungeonData::difficulty, DUNGEON_DIFFICULTY_HEROIC, lfg::LFGDungeonData::Entry(), WorldObject::FindMap(), ObjectAccessor::FindPlayer(), lfg::LfgReward::firstQuest, GetDungeon(), Object::GetGUID(), Unit::GetLevel(), GetLFGDungeon(), WorldLocation::GetMapId(), GetPlayers(), GetRandomDungeonReward(), GetRandomPlayersCount(), GetSelectedDungeons(), Player::GetSession(), GetState(), Unit::HasAura(), Player::HasPlayerFlag(), lfg::LFG_SPELL_DUNGEON_COOLDOWN, lfg::LFG_STATE_FINISHED_DUNGEON, lfg::LFG_TYPE_RANDOM, LOG_DEBUG, lfg::LFGDungeonData::map, lfg::LfgReward::otherQuest, PLAYER_FLAGS_NO_PLAY_TIME, Unit::RemoveAurasDueToSpell(), Player::RewardQuest(), lfg::LFGDungeonData::seasonal, WorldSession::SendLfgPlayerReward(), SetState(), sObjectMgr, ObjectGuid::ToString(), lfg::LFGDungeonData::type, and Player::UpdateAchievementCriteria().

◆ GetComment()

std::string const & lfg::LFGMgr::GetComment ( ObjectGuid  gguid)

Get current player comment (used for LFR)

2549 {
2550 LOG_DEBUG("lfg", "LFGMgr::GetComment: [{}] = {}", guid.ToString(), PlayersStore[guid].GetComment());
2551 return PlayersStore[guid].GetComment();
2552 }
LfgPlayerDataContainer PlayersStore
Player data.
Definition LFGMgr.h:647

References LOG_DEBUG, PlayersStore, and ObjectGuid::ToString().

Referenced by RemoveProposal(), Update(), and UpdateRoleCheck().

◆ GetCompatibleDungeons()

void lfg::LFGMgr::GetCompatibleDungeons ( LfgDungeonSet &  dungeons,
LfgGuidSet const &  players,
LfgLockPartyMap &  lockMap,
uint32  randomDungeonId = 0 
)
private

Given a list of dungeons remove the dungeons players have restrictions.

Parameters
[in,out]dungeonsDungeons to check restrictions
[in]playersSet of players to check their dungeon restrictions
[out]lockMapMap of players Lock status info of given dungeons (Empty if dungeons is not empty)
[in]randomDungeonIdRandom dungeon ID (0 for non-random selections), used to filter disabled maps
1593 {
1594 lockMap.clear();
1595 for (LfgGuidSet::const_iterator it = players.begin(); it != players.end() && !dungeons.empty(); ++it)
1596 {
1597 ObjectGuid guid = (*it);
1598 LfgLockMap const& cachedLockMap = GetLockedDungeons(guid);
1599 for (LfgLockMap::const_iterator it2 = cachedLockMap.begin(); it2 != cachedLockMap.end() && !dungeons.empty(); ++it2)
1600 {
1601 uint32 dungeonId = (it2->first & 0x00FFFFFF); // Compare dungeon ids
1602
1603 LFGDungeonData const* dungeon = GetLFGDungeon(dungeonId);
1604
1605 uint8 difficultyFlag = (randomDungeonId == RANDOM_DUNGEON_NORMAL_TBC || randomDungeonId == RANDOM_DUNGEON_NORMAL_WOTLK) ? 0 : 1;
1606
1607 if (dungeon && !IsDungeonDisabled(dungeon->map, (Difficulty)difficultyFlag) && it2->second == LFG_LOCKSTATUS_RAID_LOCKED && randomDungeonId && sWorld->getBoolConfig(CONFIG_LFG_ALLOW_COMPLETED))
1608 continue;
1609
1610 LfgDungeonSet::iterator itDungeon = dungeons.find(dungeonId);
1611 if (itDungeon != dungeons.end())
1612 {
1613 dungeons.erase(itDungeon);
1614 lockMap[guid][dungeonId] = it2->second;
1615 }
1616 }
1617 }
1618 if (!dungeons.empty())
1619 lockMap.clear();
1620 }
Difficulty
Definition DBCEnums.h:266
@ CONFIG_LFG_ALLOW_COMPLETED
Definition WorldConfig.h:98
bool IsDungeonDisabled(uint32 mapId, Difficulty difficulty) const
Checks if given dungeon map is disabled.
Definition LFGMgr.cpp:2978
LfgLockMap const & GetLockedDungeons(ObjectGuid guid)
Get locked dungeons.
Definition LFGMgr.cpp:2560
@ LFG_LOCKSTATUS_RAID_LOCKED
Definition LFG.h:86
std::map< uint32, uint32 > LfgLockMap
Definition LFG.h:115
@ RANDOM_DUNGEON_NORMAL_TBC
Definition LFG.h:105
@ RANDOM_DUNGEON_NORMAL_WOTLK
Definition LFG.h:107

References CONFIG_LFG_ALLOW_COMPLETED, GetLFGDungeon(), GetLockedDungeons(), IsDungeonDisabled(), lfg::LFG_LOCKSTATUS_RAID_LOCKED, lfg::LFGDungeonData::map, lfg::RANDOM_DUNGEON_NORMAL_TBC, lfg::RANDOM_DUNGEON_NORMAL_WOTLK, and sWorld.

Referenced by JoinLfg().

◆ GetDungeon()

uint32 lfg::LFGMgr::GetDungeon ( ObjectGuid  guid,
bool  asId = true 
)

Get current dungeon.

2523 {
2524 uint32 dungeon = GroupsStore[guid].GetDungeon(asId);
2525 LOG_DEBUG("lfg", "LFGMgr::GetDungeon: [{}] asId: {} = {}", guid.ToString(), asId, dungeon);
2526 return dungeon;
2527 }

References GroupsStore, LOG_DEBUG, and ObjectGuid::ToString().

Referenced by _SaveToDB(), FinishDungeon(), inLfgDungeonMap(), JoinLfg(), LeaveLfg(), SetupGroupMember(), and TeleportPlayer().

◆ GetDungeonCooldownDuration()

Seconds lfg::LFGMgr::GetDungeonCooldownDuration ( ) const
private
207 {
209 }
constexpr auto MINUTE
Definition Common.h:47

References CONFIG_LFG_DUNGEON_SELECTION_COOLDOWN, MINUTE, and sWorld.

Referenced by CleanupDungeonCooldowns(), and FilterCooldownDungeons().

◆ GetDungeonMapId()

uint32 lfg::LFGMgr::GetDungeonMapId ( ObjectGuid  guid)

Get the map id of the current dungeon.

2530 {
2531 uint32 dungeonId = GroupsStore[guid].GetDungeon(true);
2532 uint32 mapId = 0;
2533 if (dungeonId)
2534 if (LFGDungeonData const* dungeon = GetLFGDungeon(dungeonId))
2535 mapId = dungeon->map;
2536
2537 LOG_DEBUG("lfg", "LFGMgr::GetDungeonMapId: [{}] = {} (DungeonId = {})", guid.ToString(), mapId, dungeonId);
2538 return mapId;
2539 }

References GetLFGDungeon(), GroupsStore, LOG_DEBUG, and ObjectGuid::ToString().

◆ GetDungeonsByRandom()

LfgDungeonSet const & lfg::LFGMgr::GetDungeonsByRandom ( uint32  randomdungeon)
private

Get the dungeon list that can be done given a random dungeon entry.

Parameters
[in]randomdungeonRandom dungeon id (if value = 0 will return all dungeons)
Returns
Set of dungeons that can be done.
2455 {
2456 LFGDungeonData const* dungeon = GetLFGDungeon(randomdungeon);
2457 uint32 group = dungeon ? dungeon->group : 0;
2458 return CachedDungeonMapStore[group];
2459 }
LfgCachedDungeonContainer CachedDungeonMapStore
Stores all dungeons by groupType.
Definition LFGMgr.h:639

References CachedDungeonMapStore, GetLFGDungeon(), and lfg::LFGDungeonData::group.

Referenced by InitializeLockedDungeons(), and JoinLfg().

◆ GetDungeonType()

LfgType lfg::LFGMgr::GetDungeonType ( uint32  dungeonId)
private

Given a Dungeon id returns the dungeon Type

Parameters
[in]dungeondungeon id
Returns
Dungeon type
2490 {
2491 LFGDungeonData const* dungeon = GetLFGDungeon(dungeonId);
2492 if (!dungeon)
2493 return LFG_TYPE_NONE;
2494
2495 return LfgType(dungeon->type);
2496 }
LfgType
Determines the type of instance.
Definition LFGMgr.h:69
@ LFG_TYPE_NONE
Definition LFGMgr.h:70

References GetLFGDungeon(), lfg::LFG_TYPE_NONE, and lfg::LFGDungeonData::type.

Referenced by JoinLfg().

◆ GetGroup()

ObjectGuid lfg::LFGMgr::GetGroup ( ObjectGuid  guid)

Gets player group.

2742 {
2743 return PlayersStore[guid].GetGroup();
2744 }

References PlayersStore.

Referenced by inLfgDungeonMap(), IsPlayerQueuedForRandomDungeon(), LeaveAllLfgQueues(), LeaveLfg(), MakeNewGroup(), Update(), and UpdateBoot().

◆ GetKicksLeft()

uint8 lfg::LFGMgr::GetKicksLeft ( ObjectGuid  gguid)

Get kicks left in current group.

2567 {
2568 uint8 kicks = GroupsStore[guid].GetKicksLeft();
2569 LOG_DEBUG("lfg", "LFGMgr::GetKicksLeft: [{}] = {}", guid.ToString(), kicks);
2570 return kicks;
2571 }

References GroupsStore, LOG_DEBUG, and ObjectGuid::ToString().

◆ GetLeader()

ObjectGuid lfg::LFGMgr::GetLeader ( ObjectGuid  guid)

Get leader of the group (using internal data)

2762 {
2763 return GroupsStore[guid].GetLeader();
2764 }

References GroupsStore.

Referenced by GetQueue(), and LeaveLfg().

◆ GetLFGDungeon()

LFGDungeonData const * lfg::LFGMgr::GetLFGDungeon ( uint32  id)
251 {
252 LFGDungeonContainer::const_iterator itr = LfgDungeonStore.find(id);
253 if (itr != LfgDungeonStore.end())
254 return &(itr->second);
255
256 return nullptr;
257 }
LFGDungeonContainer LfgDungeonStore
Definition LFGMgr.h:642

References LfgDungeonStore.

Referenced by AddPlayerQueuedForRandomDungeonToGroup(), FinishDungeon(), GetCompatibleDungeons(), GetDungeonMapId(), GetDungeonsByRandom(), GetDungeonType(), GetLFGDungeonEntry(), InitializeLockedDungeons(), inLfgDungeonMap(), JoinRaidBrowser(), MakeNewGroup(), selectedRandomLfgDungeon(), TeleportPlayer(), and UpdateRaidBrowser().

◆ GetLFGDungeonEntry()

uint32 lfg::LFGMgr::GetLFGDungeonEntry ( uint32  id)

Return Lfg dungeon entry for given dungeon id.

2957 {
2958 if (id)
2959 if (LFGDungeonData const* dungeon = GetLFGDungeon(id))
2960 return dungeon->Entry();
2961
2962 return 0;
2963 }

References GetLFGDungeon().

Referenced by LoadRewards().

◆ GetLfgStatus()

LfgUpdateData lfg::LFGMgr::GetLfgStatus ( ObjectGuid  guid)

Returns current lfg status.

2896 {
2897 LfgPlayerData& playerData = PlayersStore[guid];
2898 return LfgUpdateData(LFG_UPDATETYPE_UPDATE_STATUS, playerData.GetState(), playerData.GetSelectedDungeons());
2899 }
@ LFG_UPDATETYPE_UPDATE_STATUS
Definition LFG.h:61

References lfg::LfgPlayerData::GetSelectedDungeons(), lfg::LfgPlayerData::GetState(), lfg::LFG_UPDATETYPE_UPDATE_STATUS, and PlayersStore.

◆ GetLockedDungeons()

LfgLockMap const & lfg::LFGMgr::GetLockedDungeons ( ObjectGuid  guid)

Get locked dungeons.

2561 {
2562 LOG_DEBUG("lfg", "LFGMgr::GetLockedDungeons: [{}]", guid.ToString());
2563 return PlayersStore[guid].GetLockedDungeons();
2564 }

References LOG_DEBUG, PlayersStore, and ObjectGuid::ToString().

Referenced by GetCompatibleDungeons().

◆ GetOldState()

LfgState lfg::LFGMgr::GetOldState ( ObjectGuid  guid)

Get last lfg state (NONE, DUNGEON or FINISHED_DUNGEON)

2511 {
2512 LfgState state;
2513 if (guid.IsGroup())
2514 state = GroupsStore[guid].GetOldState();
2515 else
2516 state = PlayersStore[guid].GetOldState();
2517
2518 LOG_DEBUG("lfg", "LFGMgr::GetOldState: [{}] = {}", guid.ToString(), state);
2519 return state;
2520 }

References GroupsStore, ObjectGuid::IsGroup(), LOG_DEBUG, PlayersStore, and ObjectGuid::ToString().

◆ GetOptions()

uint32 lfg::LFGMgr::GetOptions ( )

Gets current lfg options.

2886 {
2887 return m_options;
2888 }

References m_options.

◆ GetPlayerCount()

uint8 lfg::LFGMgr::GetPlayerCount ( ObjectGuid  guid)

Gets the player count of given group.

2757 {
2758 return GroupsStore[guid].GetPlayerCount();
2759 }

References GroupsStore.

◆ GetPlayers()

LfgGuidSet const & lfg::LFGMgr::GetPlayers ( ObjectGuid  guid)
private
2752 {
2753 return GroupsStore[guid].GetPlayers();
2754 }

References GroupsStore.

Referenced by FinishDungeon(), GetQueue(), InitBoot(), LeaveAllLfgQueues(), and LeaveLfg().

◆ GetQueue()

LFGQueue & lfg::LFGMgr::GetQueue ( ObjectGuid  guid)
private
2837 {
2838 uint8 queueId = 0;
2839 if (guid.IsGroup())
2840 {
2841 LfgGuidSet const& players = GetPlayers(guid);
2842 ObjectGuid pguid = players.empty() ? ObjectGuid::Empty : (*players.begin());
2843 if (pguid)
2844 queueId = GetTeam(pguid);
2845 else
2846 queueId = GetTeam(GetLeader(guid));
2847 }
2848 else
2849 queueId = GetTeam(guid);
2850 return QueuesStore[queueId];
2851 }
static ObjectGuid const Empty
Definition ObjectGuid.h:123
ObjectGuid GetLeader(ObjectGuid guid)
Get leader of the group (using internal data)
Definition LFGMgr.cpp:2761
TeamId GetTeam(ObjectGuid guid)
Definition LFGMgr.cpp:2701

References ObjectGuid::Empty, GetLeader(), GetPlayers(), GetTeam(), ObjectGuid::IsGroup(), and QueuesStore.

Referenced by AllQueued(), JoinLfg(), LeaveLfg(), RemoveProposal(), UpdateProposal(), and UpdateRoleCheck().

◆ GetRandomAndSeasonalDungeons()

LfgDungeonSet lfg::LFGMgr::GetRandomAndSeasonalDungeons ( uint8  level,
uint8  expansion 
)

Returns all random and seasonal dungeons for given level and expansion.

2966 {
2967 LfgDungeonSet randomDungeons;
2968 for (lfg::LFGDungeonContainer::const_iterator itr = LfgDungeonStore.begin(); itr != LfgDungeonStore.end(); ++itr)
2969 {
2970 lfg::LFGDungeonData const& dungeon = itr->second;
2971 if ((dungeon.type == lfg::LFG_TYPE_RANDOM || (dungeon.seasonal && sLFGMgr->IsSeasonActive(dungeon.id)))
2972 && dungeon.expansion <= expansion && dungeon.minlevel <= level && level <= dungeon.maxlevel)
2973 randomDungeons.insert(dungeon.Entry());
2974 }
2975 return randomDungeons;
2976 }
#define sLFGMgr
Definition LFGMgr.h:665
Definition LFGMgr.h:395
uint8 expansion
Definition LFGMgr.h:408
uint8 minlevel
Definition LFGMgr.h:410
uint8 maxlevel
Definition LFGMgr.h:411
uint8 type
Definition LFGMgr.h:407
uint32 Entry() const
Definition LFGMgr.h:417
bool seasonal
Definition LFGMgr.h:413
uint32 id
Definition LFGMgr.h:404

References lfg::LFGDungeonData::Entry(), lfg::LFGDungeonData::expansion, lfg::LFGDungeonData::id, lfg::LFG_TYPE_RANDOM, LfgDungeonStore, lfg::LFGDungeonData::maxlevel, lfg::LFGDungeonData::minlevel, lfg::LFGDungeonData::seasonal, sLFGMgr, and lfg::LFGDungeonData::type.

◆ GetRandomDungeonReward()

LfgReward const * lfg::LFGMgr::GetRandomDungeonReward ( uint32  dungeon,
uint8  level 
)

Gets the random dungeon reward corresponding to given dungeon and player level.

Get the reward of a given random dungeon at a certain level

Parameters
[in]dungeondungeon id
[in]levelPlayer level
Returns
Reward
2469 {
2470 LfgReward const* rew = nullptr;
2471 LfgRewardContainerBounds bounds = RewardMapStore.equal_range(dungeon & 0x00FFFFFF);
2472 for (LfgRewardContainer::const_iterator itr = bounds.first; itr != bounds.second; ++itr)
2473 {
2474 rew = itr->second;
2475 // ordered properly at loading
2476 if (itr->second->maxLevel >= level)
2477 break;
2478 }
2479
2480 return rew;
2481 }
std::pair< LfgRewardContainer::const_iterator, LfgRewardContainer::const_iterator > LfgRewardContainerBounds
Definition LFGMgr.h:268

References RewardMapStore.

Referenced by FinishDungeon().

◆ GetRandomPlayersCount()

uint8 lfg::LFGMgr::GetRandomPlayersCount ( ObjectGuid  guid)

Xinef: Get Random Players Count.

2772 {
2773 return PlayersStore[guid].GetRandomPlayersCount();
2774 }

References PlayersStore.

Referenced by FinishDungeon().

◆ GetRoles()

uint8 lfg::LFGMgr::GetRoles ( ObjectGuid  guid)

Get current player roles.

2542 {
2543 uint8 roles = PlayersStore[guid].GetRoles();
2544 LOG_DEBUG("lfg", "LFGMgr::GetRoles: [{}] = {}", guid.ToString(), roles);
2545 return roles;
2546 }

References LOG_DEBUG, PlayersStore, and ObjectGuid::ToString().

Referenced by UpdateProposal().

◆ GetSelectedDungeons()

LfgDungeonSet const & lfg::LFGMgr::GetSelectedDungeons ( ObjectGuid  guid)

Get selected dungeons.

2555 {
2556 LOG_DEBUG("lfg", "LFGMgr::GetSelectedDungeons: [{}]", guid.ToString());
2557 return PlayersStore[guid].GetSelectedDungeons();
2558 }

References LOG_DEBUG, PlayersStore, and ObjectGuid::ToString().

Referenced by AddPlayerQueuedForRandomDungeonToGroup(), FinishDungeon(), RemoveProposal(), selectedRandomLfgDungeon(), Update(), and UpdateProposal().

◆ GetState()

LfgState lfg::LFGMgr::GetState ( ObjectGuid  guid)

Get current lfg state.

2499 {
2500 LfgState state;
2501 if (guid.IsGroup())
2502 state = GroupsStore[guid].GetState();
2503 else
2504 state = PlayersStore[guid].GetState();
2505
2506 LOG_DEBUG("lfg", "LFGMgr::GetState: [{}] = {}", guid.ToString(), state);
2507 return state;
2508 }

References GroupsStore, ObjectGuid::IsGroup(), LOG_DEBUG, PlayersStore, and ObjectGuid::ToString().

Referenced by _SaveToDB(), AllQueued(), FinishDungeon(), JoinLfg(), LeaveAllLfgQueues(), LeaveLfg(), RemoveGroupData(), selectedRandomLfgDungeon(), and SetupGroupMember().

◆ GetTeam()

TeamId lfg::LFGMgr::GetTeam ( ObjectGuid  guid)
private
2702 {
2703 return PlayersStore[guid].GetTeam();
2704 }

References PlayersStore.

Referenced by GetQueue().

◆ HasIgnore()

bool lfg::LFGMgr::HasIgnore ( ObjectGuid  guid1,
ObjectGuid  guid2 
)
static

Checks if given players are ignoring each other.

2777 {
2780 return plr1 && plr2 && (plr1->GetSocial()->HasIgnore(guid2) || plr2->GetSocial()->HasIgnore(guid1));
2781 }
bool HasIgnore(ObjectGuid const &ignore_guid) const
Definition SocialMgr.cpp:194
PlayerSocial * GetSocial()
Definition Player.h:1158
Player * FindConnectedPlayer(ObjectGuid const guid)
Definition ObjectAccessor.cpp:281

References ObjectAccessor::FindConnectedPlayer(), Player::GetSocial(), and PlayerSocial::HasIgnore().

◆ InitBoot()

void lfg::LFGMgr::InitBoot ( ObjectGuid  gguid,
ObjectGuid  kicker,
ObjectGuid  victim,
std::string const &  reason 
)

Inits new proposal to boot a player.

Initialize a boot kick vote

Parameters
[in]gguidGroup the vote kicks belongs to
[in]kickerKicker guid
[in]victimVictim guid
[in]reasonKick reason
2151 {
2152 SetState(gguid, LFG_STATE_BOOT);
2153
2154 LfgPlayerBoot& boot = BootsStore[gguid];
2155 boot.inProgress = true;
2156 boot.cancelTime = time_t(GameTime::GetGameTime().count()) + LFG_TIME_BOOT;
2157 boot.reason = reason;
2158 boot.victim = victim;
2159
2160 LfgGuidSet const& players = GetPlayers(gguid);
2161
2162 // Set votes
2163 for (LfgGuidSet::const_iterator itr = players.begin(); itr != players.end(); ++itr)
2164 {
2165 ObjectGuid guid = (*itr);
2166 SetState(guid, LFG_STATE_BOOT);
2167 boot.votes[guid] = LFG_ANSWER_PENDING;
2168 }
2169
2170 boot.votes[victim] = LFG_ANSWER_DENY; // Victim auto vote NO
2171 boot.votes[kicker] = LFG_ANSWER_AGREE; // Kicker auto vote YES
2172
2173 // Notify players
2174 for (LfgGuidSet::const_iterator it = players.begin(); it != players.end(); ++it)
2175 SendLfgBootProposalUpdate(*it, boot);
2176 }
void SendLfgBootProposalUpdate(ObjectGuid guid, LfgPlayerBoot const &boot)
Definition LFGMgr.cpp:2813
LfgPlayerBootContainer BootsStore
Current player kicks.
Definition LFGMgr.h:646
Seconds GetGameTime()
Definition GameTime.cpp:39
@ LFG_STATE_BOOT
Definition LFG.h:72
@ LFG_TIME_BOOT
Definition LFGMgr.h:50
@ LFG_ANSWER_AGREE
Definition LFG.h:100
@ LFG_ANSWER_PENDING
Definition LFG.h:98
@ LFG_ANSWER_DENY
Definition LFG.h:99

References BootsStore, lfg::LfgPlayerBoot::cancelTime, GameTime::GetGameTime(), GetPlayers(), lfg::LfgPlayerBoot::inProgress, lfg::LFG_ANSWER_AGREE, lfg::LFG_ANSWER_DENY, lfg::LFG_ANSWER_PENDING, lfg::LFG_STATE_BOOT, lfg::LFG_TIME_BOOT, lfg::LfgPlayerBoot::reason, SendLfgBootProposalUpdate(), SetState(), lfg::LfgPlayerBoot::victim, and lfg::LfgPlayerBoot::votes.

◆ InitializeLockedDungeons()

void lfg::LFGMgr::InitializeLockedDungeons ( Player *  player,
Group const *  group = nullptr 
)

Initializes locked dungeons for given player (called at login or level change)

Generate the dungeon lock map for a given player

Parameters
[in]playerPlayer we need to initialize the lock status map
475 {
476 ObjectGuid guid = player->GetGUID();
477
478 uint8 level = player->GetLevel();
479 uint8 expansion = player->GetSession()->Expansion();
480 LfgDungeonSet const& dungeons = GetDungeonsByRandom(0);
481 LfgLockMap lock;
482
483 bool onlySeasonalBosses = m_options == LFG_OPTION_ENABLE_SEASONAL_BOSSES;
484
485 float avgItemLevel = player->GetAverageItemLevelForDF();
486
487 for (LfgDungeonSet::const_iterator it = dungeons.begin(); it != dungeons.end(); ++it)
488 {
489 LFGDungeonData const* dungeon = GetLFGDungeon(*it);
490 if (!dungeon) // should never happen - We provide a list from sLFGDungeonStore
491 continue;
492 MapEntry const* mapEntry = sMapStore.LookupEntry(dungeon->map);
493 DungeonProgressionRequirements const* ar = sObjectMgr->GetAccessRequirement(dungeon->map, Difficulty(dungeon->difficulty));
494
495 uint32 lockData = 0;
496
499 else if (dungeon->expansion > expansion || (onlySeasonalBosses && !dungeon->seasonal))
501 else if (IsDungeonDisabled(dungeon->map, dungeon->difficulty))
503 else if (dungeon->difficulty > DUNGEON_DIFFICULTY_NORMAL && (!mapEntry || !mapEntry->IsRaid()) && sInstanceSaveMgr->PlayerIsPermBoundToInstance(player->GetGUID(), dungeon->map, Difficulty(dungeon->difficulty)))
505 else if ((dungeon->minlevel > level && !sWorld->getBoolConfig(CONFIG_DUNGEON_ACCESS_REQUIREMENTS_LFG_DBC_LEVEL_OVERRIDE)) || (sWorld->getBoolConfig(CONFIG_DUNGEON_ACCESS_REQUIREMENTS_LFG_DBC_LEVEL_OVERRIDE) && ar && ar->levelMin > 0 && ar->levelMin > level))
507 else if ((dungeon->maxlevel < level && !sWorld->getBoolConfig(CONFIG_DUNGEON_ACCESS_REQUIREMENTS_LFG_DBC_LEVEL_OVERRIDE)) || (sWorld->getBoolConfig(CONFIG_DUNGEON_ACCESS_REQUIREMENTS_LFG_DBC_LEVEL_OVERRIDE) && ar && ar->levelMax > 0 && ar->levelMax < level))
509 else if (dungeon->seasonal && !IsSeasonActive(dungeon->id))
511 else if (player->IsClass(CLASS_DEATH_KNIGHT) && !player->IsGameMaster() &&!(player->IsQuestRewarded(13188) || player->IsQuestRewarded(13189)))
513 else if (ar)
514 {
515 // Check required items
516 for (ProgressionRequirement const* itemRequirement : ar->items)
517 {
518 if (!itemRequirement->checkLeaderOnly || !group || group->GetLeaderGUID() == player->GetGUID())
519 {
520 if (itemRequirement->faction == TEAM_NEUTRAL || itemRequirement->faction == player->GetTeamId(true))
521 {
522 if (!player->HasItemCount(itemRequirement->id, 1))
523 {
525 break;
526 }
527 }
528 }
529 }
530
531 //Check for quests
532 for (ProgressionRequirement const* questRequirement : ar->quests)
533 {
534 if (!questRequirement->checkLeaderOnly || !group || group->GetLeaderGUID() == player->GetGUID())
535 {
536 if (questRequirement->faction == TEAM_NEUTRAL || questRequirement->faction == player->GetTeamId(true))
537 {
538 if (!player->GetQuestRewardStatus(questRequirement->id))
539 {
541 break;
542 }
543 }
544 }
545 }
546
547 //Check for ilvl
548 if (ar->reqItemLevel && (float)ar->reqItemLevel > avgItemLevel)
549 {
551 }
552
553 //Check if player has the required achievements
554 for (ProgressionRequirement const* achievementRequirement : ar->achievements)
555 {
556 if (!achievementRequirement->checkLeaderOnly || !group || group->GetLeaderGUID() == player->GetGUID())
557 {
558 if (achievementRequirement->faction == TEAM_NEUTRAL || achievementRequirement->faction == player->GetTeamId(true))
559 {
560 if (!player->HasAchieved(achievementRequirement->id))
561 {
563 break;
564 }
565 }
566 }
567 }
568 }
569
570 sScriptMgr->OnInitializeLockedDungeons(player, level, lockData, dungeon);
571
572 /* TODO VoA closed if WG is not under team control (LFG_LOCKSTATUS_RAID_LOCKED)
573 lockData = LFG_LOCKSTATUS_TOO_LOW_GEAR_SCORE;
574 lockData = LFG_LOCKSTATUS_TOO_HIGH_GEAR_SCORE;
575 lockData = LFG_LOCKSTATUS_ATTUNEMENT_TOO_LOW_LEVEL;
576 lockData = LFG_LOCKSTATUS_ATTUNEMENT_TOO_HIGH_LEVEL;
577 */
578
579 if (lockData)
580 lock[dungeon->Entry()] = lockData;
581 }
582
583 sScriptMgr->OnAfterInitializeLockedDungeons(player);
584
585 SetLockedDungeons(guid, lock);
586 }
@ DUNGEON_DIFFICULTY_NORMAL
Definition DBCEnums.h:269
DBCStorage< MapEntry > sMapStore(MapEntryfmt)
#define sInstanceSaveMgr
Definition InstanceSaveMgr.h:233
#define sScriptMgr
Definition ScriptMgr.h:769
@ CLASS_DEATH_KNIGHT
Definition SharedDefines.h:131
@ TEAM_NEUTRAL
Definition SharedDefines.h:750
@ CONFIG_DUNGEON_ACCESS_REQUIREMENTS_LFG_DBC_LEVEL_OVERRIDE
Definition WorldConfig.h:127
float GetAverageItemLevelForDF()
Definition Player.cpp:16282
bool GetQuestRewardStatus(uint32 quest_id) const
Definition PlayerQuest.cpp:1489
bool HasItemCount(uint32 item, uint32 count=1, bool inBankAlso=false) const
Definition PlayerStorage.cpp:659
TeamId GetTeamId(bool original=false) const
Definition Player.h:2140
bool HasAchieved(uint32 achievementId) const
Definition Player.cpp:14319
bool IsClass(Classes playerClass, ClassContext context=CLASS_CONTEXT_NONE) const override
Definition Player.cpp:1351
bool IsGameMaster() const
Definition Player.h:1178
bool IsQuestRewarded(uint32 quest_id) const
Definition Player.h:1653
uint8 Expansion() const
Definition WorldSession.h:514
bool HasPermission(uint32 permissionId)
Definition WorldSession.cpp:1701
void SetLockedDungeons(ObjectGuid guid, LfgLockMap const &lock)
Definition LFGMgr.cpp:2666
LfgDungeonSet const & GetDungeonsByRandom(uint32 randomdungeon)
Definition LFGMgr.cpp:2454
bool IsSeasonActive(uint32 dungeonId)
Checks if Seasonal dungeon is active.
Definition LFGMgr.cpp:2901
@ LFG_LOCKSTATUS_INSUFFICIENT_EXPANSION
Definition LFG.h:81
@ LFG_LOCKSTATUS_TOO_LOW_LEVEL
Definition LFG.h:82
@ LFG_LOCKSTATUS_TOO_LOW_GEAR_SCORE
Definition LFG.h:84
@ LFG_LOCKSTATUS_MISSING_ITEM
Definition LFG.h:90
@ LFG_LOCKSTATUS_TOO_HIGH_LEVEL
Definition LFG.h:83
@ LFG_LOCKSTATUS_MISSING_ACHIEVEMENT
Definition LFG.h:92
@ LFG_LOCKSTATUS_NOT_IN_SEASON
Definition LFG.h:91
@ LFG_LOCKSTATUS_QUEST_NOT_COMPLETED
Definition LFG.h:89
@ LFG_OPTION_ENABLE_SEASONAL_BOSSES
Definition LFGMgr.h:44
@ RBAC_PERM_JOIN_DUNGEON_FINDER
Definition RBAC.h:57
Definition Player.h:936
uint8 levelMax
Definition Player.h:938
uint8 levelMin
Definition Player.h:937
uint16 reqItemLevel
Definition Player.h:939
Definition DBCStructure.h:1361
bool IsRaid() const
Definition DBCStructure.h:1390
Definition Player.h:927

References DungeonProgressionRequirements::achievements, CLASS_DEATH_KNIGHT, CONFIG_DUNGEON_ACCESS_REQUIREMENTS_LFG_DBC_LEVEL_OVERRIDE, lfg::LFGDungeonData::difficulty, DUNGEON_DIFFICULTY_NORMAL, lfg::LFGDungeonData::Entry(), lfg::LFGDungeonData::expansion, WorldSession::Expansion(), Player::GetAverageItemLevelForDF(), GetDungeonsByRandom(), Object::GetGUID(), Group::GetLeaderGUID(), Unit::GetLevel(), GetLFGDungeon(), Player::GetQuestRewardStatus(), Player::GetSession(), Player::GetTeamId(), Player::HasAchieved(), Player::HasItemCount(), WorldSession::HasPermission(), lfg::LFGDungeonData::id, Player::IsClass(), IsDungeonDisabled(), Player::IsGameMaster(), Player::IsQuestRewarded(), MapEntry::IsRaid(), IsSeasonActive(), DungeonProgressionRequirements::items, DungeonProgressionRequirements::levelMax, DungeonProgressionRequirements::levelMin, lfg::LFG_LOCKSTATUS_INSUFFICIENT_EXPANSION, lfg::LFG_LOCKSTATUS_MISSING_ACHIEVEMENT, lfg::LFG_LOCKSTATUS_MISSING_ITEM, lfg::LFG_LOCKSTATUS_NOT_IN_SEASON, lfg::LFG_LOCKSTATUS_QUEST_NOT_COMPLETED, lfg::LFG_LOCKSTATUS_RAID_LOCKED, lfg::LFG_LOCKSTATUS_TOO_HIGH_LEVEL, lfg::LFG_LOCKSTATUS_TOO_LOW_GEAR_SCORE, lfg::LFG_LOCKSTATUS_TOO_LOW_LEVEL, lfg::LFG_OPTION_ENABLE_SEASONAL_BOSSES, m_options, lfg::LFGDungeonData::map, lfg::LFGDungeonData::maxlevel, lfg::LFGDungeonData::minlevel, DungeonProgressionRequirements::quests, rbac::RBAC_PERM_JOIN_DUNGEON_FINDER, DungeonProgressionRequirements::reqItemLevel, lfg::LFGDungeonData::seasonal, SetLockedDungeons(), sInstanceSaveMgr, sMapStore, sObjectMgr, sScriptMgr, sWorld, and TEAM_NEUTRAL.

Referenced by LoadLFGDungeons().

◆ inLfgDungeonMap()

bool lfg::LFGMgr::inLfgDungeonMap ( ObjectGuid  guid,
uint32  map,
Difficulty  difficulty 
)

Check if given guid applied for given map and difficulty. Used to know.

2944 {
2945 if (!guid.IsGroup())
2946 guid = GetGroup(guid);
2947
2948 if (uint32 dungeonId = GetDungeon(guid, true))
2949 if (LFGDungeonData const* dungeon = GetLFGDungeon(dungeonId))
2950 if (uint32(dungeon->map) == map && dungeon->difficulty == difficulty)
2951 return true;
2952
2953 return false;
2954 }
ObjectGuid GetGroup(ObjectGuid guid)
Gets player group.
Definition LFGMgr.cpp:2741

References GetDungeon(), GetGroup(), GetLFGDungeon(), and ObjectGuid::IsGroup().

◆ instance()

LFGMgr * lfg::LFGMgr::instance ( )
static
62 {
63 static LFGMgr instance;
64 return &instance;
65 }
static LFGMgr * instance()
Definition LFGMgr.cpp:61
LFGMgr()
Definition LFGMgr.cpp:46

References instance().

Referenced by instance().

◆ IsDungeonDisabled()

bool lfg::LFGMgr::IsDungeonDisabled ( uint32  mapId,
Difficulty  difficulty 
) const

Checks if given dungeon map is disabled.

2979 {
2980 return sDisableMgr->IsDisabledFor(DISABLE_TYPE_MAP, mapId, nullptr, difficulty) ||
2981 sDisableMgr->IsDisabledFor(DISABLE_TYPE_LFG_MAP, mapId, nullptr);
2982 }
#define sDisableMgr
Definition DisableMgr.h:88
@ DISABLE_TYPE_MAP
Definition DisableMgr.h:30
@ DISABLE_TYPE_LFG_MAP
Definition DisableMgr.h:36

References DISABLE_TYPE_LFG_MAP, DISABLE_TYPE_MAP, and sDisableMgr.

Referenced by GetCompatibleDungeons(), and InitializeLockedDungeons().

◆ IsLfgGroup()

bool lfg::LFGMgr::IsLfgGroup ( ObjectGuid  guid)

Check if given group guid is lfg.

2832 {
2833 return guid && guid.IsGroup() && GroupsStore[guid].IsLfgGroup();
2834 }

References GroupsStore, and ObjectGuid::IsGroup().

◆ isOptionEnabled()

bool lfg::LFGMgr::isOptionEnabled ( uint32  option)

Checks if given lfg option is enabled.

2881 {
2882 return m_options & option;
2883 }

References m_options.

Referenced by JoinLfg(), Update(), and UpdateRaidBrowser().

◆ IsPlayerQueuedForRandomDungeon()

bool lfg::LFGMgr::IsPlayerQueuedForRandomDungeon ( ObjectGuid  guid)
2985 {
2986 auto gguid = GetGroup(guid);
2987 if (!gguid)
2988 return false;
2989
2990 return GroupsStore[gguid].IsRandomQueuedPlayer(guid);
2991 }

References GetGroup(), and GroupsStore.

◆ IsSeasonActive()

bool lfg::LFGMgr::IsSeasonActive ( uint32  dungeonId)

Checks if Seasonal dungeon is active.

2902 {
2903 switch (dungeonId)
2904 {
2913 }
2914 return false;
2915 }
bool IsHolidayActive(HolidayIds id)
Definition GameEventMgr.cpp:2054
@ HOLIDAY_HALLOWS_END
Definition SharedDefines.h:2986
@ HOLIDAY_FIRE_FESTIVAL
Definition SharedDefines.h:2989
@ HOLIDAY_LOVE_IS_IN_THE_AIR
Definition SharedDefines.h:3001
@ HOLIDAY_BREWFEST
Definition SharedDefines.h:2991
@ LFG_DUNGEON_FROST_LORD_AHUNE
Definition LFGMgr.h:150
@ LFG_DUNGEON_HEADLESS_HORSEMAN
Definition LFGMgr.h:149
@ LFG_DUNGEON_CROWN_CHEMICAL_CO
Definition LFGMgr.h:152
@ LFG_DUNGEON_COREN_DIREBREW
Definition LFGMgr.h:151

References HOLIDAY_BREWFEST, HOLIDAY_FIRE_FESTIVAL, HOLIDAY_HALLOWS_END, HOLIDAY_LOVE_IS_IN_THE_AIR, IsHolidayActive(), lfg::LFG_DUNGEON_COREN_DIREBREW, lfg::LFG_DUNGEON_CROWN_CHEMICAL_CO, lfg::LFG_DUNGEON_FROST_LORD_AHUNE, and lfg::LFG_DUNGEON_HEADLESS_HORSEMAN.

Referenced by InitializeLockedDungeons().

◆ IsTesting()

bool lfg::LFGMgr::IsTesting ( ) const
inline

For 1 player queue testing.

589{ return m_Testing; }

References m_Testing.

◆ JoinLfg()

void lfg::LFGMgr::JoinLfg ( Player *  player,
uint8  roles,
LfgDungeonSet &  dungeons,
std::string const &  comment 
)

Join Lfg with selected roles, dungeons and comment.

Adds the player/group to lfg queue. If player is in a group then it is the leader of the group tying to join the group. Join conditions are checked before adding to the new queue.

Parameters
[in]playerPlayer trying to join (or leader of group trying to join)
[in]rolesPlayer selected roles
[in]dungeonsDungeons the player/group is applying for
[in]commentPlayer selected comment
599 {
600 if (!player || dungeons.empty())
601 return;
602
603 Group* grp = player->GetGroup();
604 ObjectGuid guid = player->GetGUID();
605 ObjectGuid gguid = grp ? grp->GetGUID() : guid;
606 LfgJoinResultData joinData;
607 LfgGuidSet players;
608 uint32 rDungeonId = 0;
609 bool isContinue = grp && grp->isLFGGroup() && GetState(gguid) != LFG_STATE_FINISHED_DUNGEON;
610
611 if (grp && (grp->isBGGroup() || grp->isBFGroup()))
612 return;
613
614 if (!sScriptMgr->OnPlayerCanJoinLfg(player, roles, dungeons, comment))
615 return;
616
617 // pussywizard: can't join LFG/LFR while using LFR
618 if (GetState(player->GetGUID()) == LFG_STATE_RAIDBROWSER)
619 {
620 LfgDungeonSet tmp;
621 SendRaidBrowserJoinedPacket(player, tmp, ""); // the df "eye" can disappear in various case, resend if needed
622 return;
623 }
624
625 // Do not allow to change dungeon in the middle of a current dungeon
626 if (isContinue)
627 {
628 dungeons.clear();
629 dungeons.insert(GetDungeon(gguid));
630 }
631
632 LfgState state = GetState(gguid);
633 switch (state)
634 {
635 case LFG_STATE_ROLECHECK: // if joining again during rolecheck (eg. many players clicked continue inside instance)
636 if (gguid.IsGroup())
637 UpdateRoleCheck(gguid); // abort role check and remove from RoleChecksStore
638 break;
639 case LFG_STATE_QUEUED: // joining again while in a queue
640 {
641 LFGQueue& queue = GetQueue(gguid);
642 queue.RemoveFromQueue(gguid);
643 }
644 break;
645 case LFG_STATE_PROPOSAL: // if joining again during proposal
646 joinData.result = LFG_JOIN_INTERNAL_ERROR;
647 break;
648 /*case LFG_STATE_FINISHED_DUNGEON:
649 if (grp && grp->isLFGGroup())
650 joinData.result = LFG_JOIN_PARTY_NOT_MEET_REQS;
651 break;
652 */
653 default:
654 break;
655 }
656
657 // Check if all dungeons are valid
658 bool isRaid = false;
659 if (joinData.result == LFG_JOIN_OK)
660 {
661 bool isDungeon = false;
662 for (LfgDungeonSet::const_iterator it = dungeons.begin(); it != dungeons.end() && joinData.result == LFG_JOIN_OK; ++it)
663 {
664 LfgType type = GetDungeonType(*it);
665 switch (type)
666 {
667 case LFG_TYPE_RANDOM:
668 if (dungeons.size() > 1) // Only allow 1 random dungeon
669 {
670 joinData.result = LFG_JOIN_DUNGEON_INVALID;
671 }
672 else
673 {
674 rDungeonId = (*dungeons.begin());
675 sScriptMgr->OnPlayerQueueRandomDungeon(player, rDungeonId);
676 }
677 [[fallthrough]]; // On purpose (Random can only be dungeon or heroic dungeon)
678 case LFG_TYPE_HEROIC:
679 case LFG_TYPE_DUNGEON:
680 if (isRaid)
681 {
682 joinData.result = LFG_JOIN_MIXED_RAID_DUNGEON;
683 }
684 isDungeon = true;
685 break;
686 case LFG_TYPE_RAID:
687 if (isDungeon)
688 {
689 joinData.result = LFG_JOIN_MIXED_RAID_DUNGEON;
690 }
691 isRaid = true;
692 break;
693 default:
694 LOG_ERROR("lfg", "Wrong dungeon type {} for dungeon {}", type, *it);
695 joinData.result = LFG_JOIN_DUNGEON_INVALID;
696 break;
697 }
698 }
699
700 if (isRaid && joinData.result == LFG_JOIN_OK && !isOptionEnabled(LFG_OPTION_ENABLE_RAID_BROWSER))
701 joinData.result = LFG_JOIN_NOT_MEET_REQS;
702 }
703
704 if (!isRaid && joinData.result == LFG_JOIN_OK)
705 {
706 // Check player or group member restrictions
708 {
709 joinData.result = LFG_JOIN_NOT_MEET_REQS;
710 }
711 else if (player->InBattleground() || (player->InBattlegroundQueue() && !sWorld->getBoolConfig(CONFIG_ALLOW_JOIN_BG_AND_LFG)))
712 {
713 joinData.result = LFG_JOIN_USING_BG_SYSTEM;
714 }
715 else if (player->HasAura(LFG_SPELL_DUNGEON_DESERTER))
716 {
717 joinData.result = LFG_JOIN_DESERTER;
718 }
719 else if (dungeons.empty())
720 {
721 joinData.result = LFG_JOIN_NOT_MEET_REQS;
722 }
723 else if (grp)
724 {
725 if (grp->GetMembersCount() > MAXGROUPSIZE)
726 joinData.result = LFG_JOIN_TOO_MUCH_MEMBERS;
727 else
728 {
729 uint8 memberCount = 0;
730 for (GroupReference* itr = grp->GetFirstMember(); itr != nullptr && joinData.result == LFG_JOIN_OK; itr = itr->next())
731 {
732 if (Player* plrg = itr->GetSource())
733 {
734 if (!plrg->GetSession()->HasPermission(rbac::RBAC_PERM_JOIN_DUNGEON_FINDER))
735 {
736 joinData.result = LFG_JOIN_PARTY_NOT_MEET_REQS;
737 }
738 else if (plrg->HasAura(LFG_SPELL_DUNGEON_DESERTER))
739 {
740 joinData.result = LFG_JOIN_PARTY_DESERTER;
741 }
742 else if (plrg->InBattleground() || (plrg->InBattlegroundQueue() && !sWorld->getBoolConfig(CONFIG_ALLOW_JOIN_BG_AND_LFG)))
743 {
744 joinData.result = LFG_JOIN_USING_BG_SYSTEM;
745 }
746
747 ++memberCount;
748 players.insert(plrg->GetGUID());
749 }
750 }
751
752 if (joinData.result == LFG_JOIN_OK && memberCount != grp->GetMembersCount())
753 joinData.result = LFG_JOIN_DISCONNECTED;
754 }
755 }
756 else
757 players.insert(player->GetGUID());
758
759 // Xinef: Check dungeon cooldown only for random dungeons
760 // Xinef: Moreover check this only if dungeon is not started, afterwards its obvious that players will have the cooldown
761 if (joinData.result == LFG_JOIN_OK && !isContinue && rDungeonId)
762 {
763 if (player->HasAura(LFG_SPELL_DUNGEON_COOLDOWN)) // xinef: added !isContinue
764 joinData.result = LFG_JOIN_RANDOM_COOLDOWN;
765 else if (grp)
766 {
767 for (GroupReference* itr = grp->GetFirstMember(); itr != nullptr && joinData.result == LFG_JOIN_OK; itr = itr->next())
768 if (Player* plrg = itr->GetSource())
769 if (plrg->HasAura(LFG_SPELL_DUNGEON_COOLDOWN)) // xinef: added !isContinue
770 joinData.result = LFG_JOIN_PARTY_RANDOM_COOLDOWN;
771 }
772 }
773 }
774
775 if (isRaid)
776 players.insert(player->GetGUID());
777
778 if (joinData.result == LFG_JOIN_OK)
779 {
780 // Expand random dungeons and check restrictions
781 if (rDungeonId)
782 dungeons = GetDungeonsByRandom(rDungeonId);
783
784 // if we have lockmap then there are no compatible dungeons
785 // xinef: dont check compatibile dungeons for already running group (bind problems)
786 if (!isContinue)
787 {
788 GetCompatibleDungeons(dungeons, players, joinData.lockmap, rDungeonId);
789 if (dungeons.empty())
791 }
792 }
793
794 // pussywizard:
795 if (isRaid && grp && (grp->isLFGGroup() || guid != grp->GetLeaderGUID()))
796 return;
797
798 // Do not allow to change dungeon in the middle of a current dungeon
799 if (!isRaid && isContinue && grp->GetMembersCount() == 5)
800 {
801 dungeons.clear();
802 dungeons.insert(GetDungeon(gguid));
803 joinData.result = LFG_JOIN_PARTY_NOT_MEET_REQS;
804 }
805
806 // Can't join. Send result
807 if (joinData.result != LFG_JOIN_OK)
808 {
809 LOG_DEBUG("lfg", "LFGMgr::Join: [{}] joining with {} members. result: {}", guid.ToString(), grp ? grp->GetMembersCount() : 1, joinData.result);
810 if (!dungeons.empty()) // Only should show lockmap when have no dungeons available
811 joinData.lockmap.clear();
812 player->GetSession()->SendLfgJoinResult(joinData);
813 return;
814 }
815
816 SetComment(guid, comment);
817
818 if (isRaid)
819 {
820 if (grp)
821 roles = PLAYER_ROLE_LEADER;
822 else
824 if (!roles)
825 return;
826 JoinRaidBrowser(player, roles, dungeons, comment);
828 SendRaidBrowserJoinedPacket(player, dungeons, comment);
829 return;
830 }
831
832 if (grp) // Begin rolecheck
833 {
834 // Create new rolecheck
835 LfgRoleCheck& roleCheck = RoleChecksStore[gguid];
836 roleCheck.roles.clear(); // pussywizard: NEW rolecheck, not old one with trash data >_>
837 roleCheck.cancelTime = time_t(GameTime::GetGameTime().count()) + LFG_TIME_ROLECHECK;
838 roleCheck.state = LFG_ROLECHECK_INITIALITING;
839 roleCheck.leader = guid;
840 roleCheck.dungeons = dungeons;
841 roleCheck.rDungeonId = rDungeonId;
842
843 if (rDungeonId)
844 {
845 dungeons.clear();
846 dungeons.insert(rDungeonId);
847 }
848
850 // Send update to player
851 LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_JOIN_QUEUE, dungeons, comment);
852 for (GroupReference* itr = grp->GetFirstMember(); itr != nullptr; itr = itr->next())
853 {
854 if (Player* plrg = itr->GetSource())
855 {
856 ObjectGuid pguid = plrg->GetGUID();
857 plrg->GetSession()->SendLfgUpdateParty(updateData);
859 if (!isContinue)
860 SetSelectedDungeons(pguid, dungeons);
861 roleCheck.roles[pguid] = 0;
862 }
863 }
864 // Update leader role
865 UpdateRoleCheck(gguid, guid, roles);
866 }
867 else // Add player to queue
868 {
869 LfgRolesMap rolesMap;
870 rolesMap[guid] = roles;
871 LFGQueue& queue = GetQueue(guid);
872 queue.AddQueueData(guid, GameTime::GetGameTime().count(), dungeons, rolesMap);
873
874 if (!isContinue)
875 {
876 if (rDungeonId)
877 {
878 dungeons.clear();
879 dungeons.insert(rDungeonId);
880 }
881 SetSelectedDungeons(guid, dungeons);
882 }
883 // Send update to player
884 player->GetSession()->SendLfgJoinResult(joinData);
885 player->GetSession()->SendLfgUpdatePlayer(LfgUpdateData(LFG_UPDATETYPE_JOIN_QUEUE, dungeons, comment));
887 SetRoles(guid, roles);
888 }
889 }
#define MAXGROUPSIZE
Definition Group.h:44
#define LOG_ERROR(filterType__,...)
Definition Log.h:145
@ CONFIG_ALLOW_JOIN_BG_AND_LFG
Definition WorldConfig.h:133
Definition GroupReference.h:27
Definition Group.h:178
bool isLFGGroup(bool restricted=false) const
Definition Group.cpp:2507
ObjectGuid GetGUID() const
Definition Group.cpp:2548
bool isBGGroup() const
Definition Group.cpp:2518
uint32 GetMembersCount() const
Definition Group.h:255
bool isBFGroup() const
Definition Group.cpp:2523
GroupReference * GetFirstMember()
Definition Group.h:253
ObjectGuid GetLeaderGUID() const
Definition Group.cpp:2538
bool InBattleground() const
Definition Player.h:2300
bool InBattlegroundQueue(bool ignoreArena=false) const
Definition Player.cpp:12498
Group * GetGroup()
Definition Player.h:2518
void SendLfgJoinResult(lfg::LfgJoinResultData const &joinData)
Definition LFGHandler.cpp:445
void SendLfgUpdatePlayer(lfg::LfgUpdateData const &updateData)
Definition LFGHandler.cpp:306
void SetSelectedDungeons(ObjectGuid guid, LfgDungeonSet const &dungeons)
Definition LFGMgr.cpp:2660
void SetComment(ObjectGuid guid, std::string const &comment)
Sets player lfr comment.
Definition LFGMgr.cpp:2641
void JoinRaidBrowser(Player *player, uint8 roles, LfgDungeonSet &dungeons, std::string comment)
pussywizard: Raid Browser
Definition LFGMgr.cpp:992
void SendRaidBrowserJoinedPacket(Player *p, LfgDungeonSet &dungeons, std::string comment)
Definition LFGMgr.cpp:1014
bool isOptionEnabled(uint32 option)
Checks if given lfg option is enabled.
Definition LFGMgr.cpp:2880
void UpdateRoleCheck(ObjectGuid gguid, ObjectGuid guid=ObjectGuid::Empty, uint8 roles=PLAYER_ROLE_NONE)
Updates the role check with player answer.
Definition LFGMgr.cpp:1506
LfgRoleCheckContainer RoleChecksStore
Current Role checks.
Definition LFGMgr.h:644
void GetCompatibleDungeons(LfgDungeonSet &dungeons, LfgGuidSet const &players, LfgLockPartyMap &lockMap, uint32 randomDungeonId=0)
Definition LFGMgr.cpp:1592
void SetRoles(ObjectGuid guid, uint8 roles)
Sets player lfg roles.
Definition LFGMgr.cpp:2635
LfgType GetDungeonType(uint32 dungeon)
Definition LFGMgr.cpp:2489
@ LFG_OPTION_ENABLE_RAID_BROWSER
Definition LFGMgr.h:43
std::map< ObjectGuid, uint8 > LfgRolesMap
Definition LFG.h:119
@ LFG_STATE_RAIDBROWSER
Definition LFG.h:75
@ LFG_STATE_ROLECHECK
Definition LFG.h:69
@ LFG_STATE_PROPOSAL
Definition LFG.h:71
@ LFG_UPDATETYPE_JOIN_QUEUE
Definition LFG.h:53
@ LFG_TIME_ROLECHECK
Definition LFGMgr.h:49
@ LFG_SPELL_DUNGEON_DESERTER
Definition LFGMgr.h:54
@ LFG_TYPE_RAID
Definition LFGMgr.h:72
@ LFG_TYPE_DUNGEON
Definition LFGMgr.h:71
@ LFG_TYPE_HEROIC
Definition LFGMgr.h:74
@ LFG_ROLECHECK_INITIALITING
Definition LFGMgr.h:127
@ PLAYER_ROLE_LEADER
Definition LFG.h:40
@ LFG_JOIN_TOO_MUCH_MEMBERS
Definition LFGMgr.h:118
@ LFG_JOIN_DISCONNECTED
Definition LFGMgr.h:111
@ LFG_JOIN_DUNGEON_INVALID
Definition LFGMgr.h:113
@ LFG_JOIN_USING_BG_SYSTEM
Definition LFGMgr.h:119
@ LFG_JOIN_INTERNAL_ERROR
Definition LFGMgr.h:106
@ LFG_JOIN_MIXED_RAID_DUNGEON
Definition LFGMgr.h:109
@ LFG_JOIN_PARTY_NOT_MEET_REQS
Definition LFGMgr.h:108
@ LFG_JOIN_DESERTER
Definition LFGMgr.h:114
@ LFG_JOIN_RANDOM_COOLDOWN
Definition LFGMgr.h:116
@ LFG_JOIN_PARTY_RANDOM_COOLDOWN
Definition LFGMgr.h:117
@ LFG_JOIN_OK
Definition LFGMgr.h:103
@ LFG_JOIN_PARTY_DESERTER
Definition LFGMgr.h:115
@ LFG_JOIN_NOT_MEET_REQS
Definition LFGMgr.h:107

References lfg::LFGQueue::AddQueueData(), lfg::LfgRoleCheck::cancelTime, CONFIG_ALLOW_JOIN_BG_AND_LFG, lfg::LfgRoleCheck::dungeons, GetCompatibleDungeons(), GetDungeon(), GetDungeonsByRandom(), GetDungeonType(), Group::GetFirstMember(), GameTime::GetGameTime(), Player::GetGroup(), Group::GetGUID(), Object::GetGUID(), Group::GetLeaderGUID(), Group::GetMembersCount(), GetQueue(), Player::GetSession(), GetState(), Unit::HasAura(), WorldSession::HasPermission(), Player::InBattleground(), Player::InBattlegroundQueue(), Group::isBFGroup(), Group::isBGGroup(), ObjectGuid::IsGroup(), Group::isLFGGroup(), isOptionEnabled(), JoinRaidBrowser(), lfg::LfgRoleCheck::leader, lfg::LFG_JOIN_DESERTER, lfg::LFG_JOIN_DISCONNECTED, lfg::LFG_JOIN_DUNGEON_INVALID, lfg::LFG_JOIN_INTERNAL_ERROR, lfg::LFG_JOIN_MIXED_RAID_DUNGEON, lfg::LFG_JOIN_NOT_MEET_REQS, lfg::LFG_JOIN_OK, lfg::LFG_JOIN_PARTY_DESERTER, lfg::LFG_JOIN_PARTY_NOT_MEET_REQS, lfg::LFG_JOIN_PARTY_RANDOM_COOLDOWN, lfg::LFG_JOIN_RANDOM_COOLDOWN, lfg::LFG_JOIN_TOO_MUCH_MEMBERS, lfg::LFG_JOIN_USING_BG_SYSTEM, lfg::LFG_OPTION_ENABLE_RAID_BROWSER, lfg::LFG_ROLECHECK_INITIALITING, lfg::LFG_SPELL_DUNGEON_COOLDOWN, lfg::LFG_SPELL_DUNGEON_DESERTER, lfg::LFG_STATE_FINISHED_DUNGEON, lfg::LFG_STATE_PROPOSAL, lfg::LFG_STATE_QUEUED, lfg::LFG_STATE_RAIDBROWSER, lfg::LFG_STATE_ROLECHECK, lfg::LFG_TIME_ROLECHECK, lfg::LFG_TYPE_DUNGEON, lfg::LFG_TYPE_HEROIC, lfg::LFG_TYPE_RAID, lfg::LFG_TYPE_RANDOM, lfg::LFG_UPDATETYPE_JOIN_QUEUE, lfg::LfgJoinResultData::lockmap, LOG_DEBUG, LOG_ERROR, MAXGROUPSIZE, lfg::PLAYER_ROLE_DAMAGE, lfg::PLAYER_ROLE_HEALER, lfg::PLAYER_ROLE_LEADER, lfg::PLAYER_ROLE_TANK, rbac::RBAC_PERM_JOIN_DUNGEON_FINDER, lfg::LfgRoleCheck::rDungeonId, lfg::LFGQueue::RemoveFromQueue(), lfg::LfgJoinResultData::result, RoleChecksStore, lfg::LfgRoleCheck::roles, WorldSession::SendLfgJoinResult(), WorldSession::SendLfgUpdatePlayer(), SendRaidBrowserJoinedPacket(), SetComment(), SetRoles(), SetSelectedDungeons(), SetState(), sScriptMgr, lfg::LfgRoleCheck::state, sWorld, ObjectGuid::ToString(), and UpdateRoleCheck().

◆ JoinRaidBrowser()

void lfg::LFGMgr::JoinRaidBrowser ( Player *  player,
uint8  roles,
LfgDungeonSet &  dungeons,
std::string  comment 
)

pussywizard: Raid Browser

993 {
994 // pussywizard: client limit for comment length is 64 @ 3.3.5a
995 if (comment.size() > 64)
996 comment = comment.substr(0, 64);
997
998 RBEntryInfo entry(roles, comment);
999 for (LfgDungeonSet::const_iterator itr = dungeons.begin(); itr != dungeons.end(); ++itr)
1000 if (GetLFGDungeon(*itr)) // ensure dungeon data exists for such dungeon id
1001 {
1002 RaidBrowserStore[player->GetTeamId()][*itr][player->GetGUID()] = entry;
1003 RBUsedDungeonsStore[player->GetTeamId()].insert(*itr);
1004 }
1005 }
RBUsedDungeonsSet RBUsedDungeonsStore[2]
Definition LFGMgr.h:439
RBStoreMap RaidBrowserStore[2]
Definition LFGMgr.h:429

References Object::GetGUID(), GetLFGDungeon(), Player::GetTeamId(), RaidBrowserStore, and RBUsedDungeonsStore.

Referenced by JoinLfg().

◆ LeaveAllLfgQueues()

void lfg::LFGMgr::LeaveAllLfgQueues ( ObjectGuid  guid,
bool  allowgroup,
ObjectGuid  groupguid = ObjectGuid::Empty 
)

pussywizard: cleans all queues' data

1452 {
1453 ObjectGuid pguid, gguid;
1454 if (guid.IsGroup())
1455 gguid = guid;
1456 else if (groupguid && groupguid.IsGroup())
1457 {
1458 pguid = guid;
1459 gguid = groupguid;
1460 }
1461 else
1462 {
1463 pguid = guid;
1464 gguid = GetGroup(guid);
1465 }
1466 if (!allowgroup)
1467 gguid.Clear();
1468
1469 if (pguid)
1470 for (lfg::LfgQueueContainer::iterator itr = QueuesStore.begin(); itr != QueuesStore.end(); ++itr)
1471 itr->second.RemoveFromQueue(pguid);
1472 if (gguid)
1473 for (lfg::LfgQueueContainer::iterator itr = QueuesStore.begin(); itr != QueuesStore.end(); ++itr)
1474 itr->second.RemoveFromQueue(gguid);
1475
1476 if (pguid && !gguid)
1477 {
1478 if (GetState(pguid) == LFG_STATE_QUEUED)
1479 {
1481 SetState(pguid, LFG_STATE_NONE);
1482 }
1483 }
1484 if (gguid)
1485 {
1486 if (GetState(gguid) == LFG_STATE_QUEUED)
1487 {
1488 SetState(gguid, LFG_STATE_NONE);
1489 LfgGuidSet const& players = GetPlayers(gguid);
1490 for (LfgGuidSet::const_iterator it = players.begin(); it != players.end(); ++it)
1491 {
1494 }
1495 }
1496 }
1497 }
void Clear()
Definition ObjectGuid.h:141
void SendLfgUpdateParty(ObjectGuid guid, LfgUpdateData const &data)
Definition LFGMgr.cpp:2801
void SendLfgUpdatePlayer(ObjectGuid guid, LfgUpdateData const &data)
Definition LFGMgr.cpp:2795
@ LFG_STATE_NONE
Definition LFG.h:68
@ LFG_UPDATETYPE_REMOVED_FROM_QUEUE
Definition LFG.h:55

References ObjectGuid::Clear(), GetGroup(), GetPlayers(), GetState(), ObjectGuid::IsGroup(), lfg::LFG_STATE_NONE, lfg::LFG_STATE_QUEUED, lfg::LFG_UPDATETYPE_REMOVED_FROM_QUEUE, QueuesStore, SendLfgUpdateParty(), SendLfgUpdatePlayer(), and SetState().

◆ LeaveLfg()

void lfg::LFGMgr::LeaveLfg ( ObjectGuid  guid)

Leaves lfg.

Leaves Dungeon System. Player/Group is removed from queue, rolechecks, proposals or votekicks. Player or group needs to be not nullptr and using Dungeon System

Parameters
[in]guidPlayer or group guid
912 {
913 LOG_DEBUG("lfg", "LFGMgr::Leave: [{}]", guid.ToString());
914 ObjectGuid gguid = guid.IsGroup() ? guid : GetGroup(guid);
915 LfgState state = GetState(guid);
916 switch (state)
917 {
918 case LFG_STATE_QUEUED:
919 if (gguid)
920 {
921 LFGQueue& queue = GetQueue(gguid);
922 queue.RemoveFromQueue(gguid);
923 uint32 dungeonId = GetDungeon(gguid);
924 SetState(gguid, LFG_STATE_NONE);
925 LfgGuidSet const& players = GetPlayers(gguid);
926 for (LfgGuidSet::const_iterator it = players.begin(); it != players.end(); ++it)
927 {
930 }
931 if (Group* group = sGroupMgr->GetGroupByGUID(gguid.GetCounter()))
932 {
933 if (group->isLFGGroup())
934 {
935 SetDungeon(gguid, dungeonId);
936 }
937 }
938 }
939 else
940 {
941 LFGQueue& queue = GetQueue(guid);
942 queue.RemoveFromQueue(guid);
945 }
946 break;
948 if (gguid)
949 UpdateRoleCheck(gguid); // No player to update role = LFG_ROLECHECK_ABORTED
950 break;
952 {
953 // Remove from Proposals
954 LfgProposalContainer::iterator it = ProposalsStore.begin();
955 ObjectGuid pguid = gguid == guid ? GetLeader(gguid) : guid;
956 while (it != ProposalsStore.end())
957 {
958 LfgProposalPlayerContainer::iterator itPlayer = it->second.players.find(pguid);
959 if (itPlayer != it->second.players.end())
960 {
961 // Mark the player/leader of group who left as didn't accept the proposal
962 itPlayer->second.accept = LFG_ANSWER_DENY;
963 break;
964 }
965 ++it;
966 }
967
968 // Remove from queue - if proposal is found, RemoveProposal will call RemoveFromQueue
969 if (it != ProposalsStore.end())
971 break;
972 }
973 case LFG_STATE_NONE:
974 break;
977 case LFG_STATE_BOOT:
978 if (guid != gguid) // Player
980 break;
982 LeaveRaidBrowser(guid);
983 SetCanOverrideRBState(guid, true);
985 SetCanOverrideRBState(guid, false);
988 break;
989 }
990 }
#define sGroupMgr
Definition GroupMgr.h:51
void LeaveRaidBrowser(ObjectGuid guid)
Definition LFGMgr.cpp:1007
void RemoveProposal(LfgProposalContainer::iterator itProposal, LfgUpdateType type)
Definition LFGMgr.cpp:2041
void SetCanOverrideRBState(ObjectGuid guid, bool val)
Definition LFGMgr.cpp:2624
@ LFG_UPDATETYPE_PROPOSAL_DECLINED
Definition LFG.h:57
@ LFG_UPDATETYPE_LEAVE_RAIDBROWSER
Definition LFG.h:50

References ObjectGuid::GetCounter(), GetDungeon(), GetGroup(), GetLeader(), GetPlayers(), GetQueue(), GetState(), ObjectGuid::IsGroup(), LeaveRaidBrowser(), lfg::LFG_ANSWER_DENY, lfg::LFG_STATE_BOOT, lfg::LFG_STATE_DUNGEON, lfg::LFG_STATE_FINISHED_DUNGEON, lfg::LFG_STATE_NONE, lfg::LFG_STATE_PROPOSAL, lfg::LFG_STATE_QUEUED, lfg::LFG_STATE_RAIDBROWSER, lfg::LFG_STATE_ROLECHECK, lfg::LFG_UPDATETYPE_LEAVE_RAIDBROWSER, lfg::LFG_UPDATETYPE_PROPOSAL_DECLINED, lfg::LFG_UPDATETYPE_REMOVED_FROM_QUEUE, LOG_DEBUG, ProposalsStore, lfg::LFGQueue::RemoveFromQueue(), RemoveProposal(), SendLfgUpdateParty(), SendLfgUpdatePlayer(), SetCanOverrideRBState(), SetDungeon(), SetState(), sGroupMgr, ObjectGuid::ToString(), and UpdateRoleCheck().

◆ LeaveRaidBrowser()

void lfg::LFGMgr::LeaveRaidBrowser ( ObjectGuid  guid)
1008 {
1009 for (uint8 team = 0; team < 2; ++team)
1010 for (RBStoreMap::iterator itr = RaidBrowserStore[team].begin(); itr != RaidBrowserStore[team].end(); ++itr)
1011 itr->second.erase(guid);
1012 }

References RaidBrowserStore.

Referenced by LeaveLfg().

◆ LfrSearchAdd()

void lfg::LFGMgr::LfrSearchAdd ( Player *  p,
uint32  dungeonId 
)
1042 {
1043 RBSearchersStore[p->GetTeamId()][p->GetGUID()] = dungeonId;
1044 }
RBSearchersMap RBSearchersStore[2]
Definition LFGMgr.h:431

References Object::GetGUID(), Player::GetTeamId(), and RBSearchersStore.

◆ LfrSearchRemove()

void lfg::LFGMgr::LfrSearchRemove ( Player *  p)
1047 {
1048 RBSearchersStore[p->GetTeamId()].erase(p->GetGUID());
1049 }

References Object::GetGUID(), Player::GetTeamId(), and RBSearchersStore.

◆ LfrSetComment()

void lfg::LFGMgr::LfrSetComment ( Player *  p,
std::string  comment 
)
2648 {
2649 // pussywizard: client limit for comment length is 64 @ 3.3.5a
2650 if (comment.size() > 64)
2651 comment = comment.substr(0, 64);
2652
2653 uint8 teamId = p->GetTeamId();
2654 RBEntryInfoMap::iterator iter;
2655 for (RBStoreMap::iterator itr = RaidBrowserStore[teamId].begin(); itr != RaidBrowserStore[teamId].end(); ++itr)
2656 if ((iter = itr->second.find(p->GetGUID())) != itr->second.end())
2657 iter->second.comment = comment;
2658 }

References Object::GetGUID(), Player::GetTeamId(), and RaidBrowserStore.

◆ LoadLFGDungeons()

void lfg::LFGMgr::LoadLFGDungeons ( bool  reload = false)

Loads dungeons from dbc and adds teleport coords.

260 {
261 uint32 oldMSTime = getMSTime();
262
263 LfgDungeonStore.clear();
264
265 // Initialize Dungeon map with data from dbcs
266 for (uint32 i = 0; i < sLFGDungeonStore.GetNumRows(); ++i)
267 {
268 LFGDungeonEntry const* dungeon = sLFGDungeonStore.LookupEntry(i);
269 if (!dungeon)
270 continue;
271
272 switch (dungeon->TypeID)
273 {
274 case LFG_TYPE_DUNGEON:
275 case LFG_TYPE_HEROIC:
276 case LFG_TYPE_RAID:
277 case LFG_TYPE_RANDOM:
278 LfgDungeonStore[dungeon->ID] = LFGDungeonData(dungeon);
279 break;
280 }
281 }
282
283 // Fill teleport locations from DB
284 // 0 1 2 3 4
285 QueryResult result = WorldDatabase.Query("SELECT dungeonId, position_x, position_y, position_z, orientation FROM lfg_dungeon_template");
286
287 if (!result)
288 {
289 LOG_ERROR("lfg", ">> Loaded 0 LFG Entrance Positions. DB Table `lfg_dungeon_template` Is Empty!");
290 LOG_INFO("server.loading", " ");
291 return;
292 }
293
294 uint32 count = 0;
295
296 do
297 {
298 Field* fields = result->Fetch();
299 uint32 dungeonId = fields[0].Get<uint32>();
300 LFGDungeonContainer::iterator dungeonItr = LfgDungeonStore.find(dungeonId);
301 if (dungeonItr == LfgDungeonStore.end())
302 {
303 LOG_ERROR("lfg", "table `lfg_dungeon_template` contains coordinates for wrong dungeon {}", dungeonId);
304 continue;
305 }
306
307 LFGDungeonData& data = dungeonItr->second;
308 data.x = fields[1].Get<float>();
309 data.y = fields[2].Get<float>();
310 data.z = fields[3].Get<float>();
311 data.o = fields[4].Get<float>();
312
313 ++count;
314 } while (result->NextRow());
315
316 LOG_INFO("server.loading", ">> Loaded {} LFG Entrance Positions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
317 LOG_INFO("server.loading", " ");
318
319 // Fill all other teleport coords from areatriggers
320 for (LFGDungeonContainer::iterator itr = LfgDungeonStore.begin(); itr != LfgDungeonStore.end(); ++itr)
321 {
322 LFGDungeonData& dungeon = itr->second;
323
324 // No teleport coords in database, load from areatriggers
325 if (dungeon.type != LFG_TYPE_RANDOM && dungeon.x == 0.0f && dungeon.y == 0.0f && dungeon.z == 0.0f)
326 {
327 AreaTriggerTeleport const* at = sObjectMgr->GetMapEntranceTrigger(dungeon.map);
328 if (!at)
329 {
330 LOG_ERROR("lfg", "LFGMgr::LoadLFGDungeons: Failed to load dungeon {}, cant find areatrigger for map {}", dungeon.name, dungeon.map);
331 continue;
332 }
333
334 dungeon.map = at->target_mapId;
335 dungeon.x = at->target_X;
336 dungeon.y = at->target_Y;
337 dungeon.z = at->target_Z;
338 dungeon.o = at->target_Orientation;
339 }
340
341 if (dungeon.type != LFG_TYPE_RANDOM)
342 CachedDungeonMapStore[dungeon.group].insert(dungeon.id);
343 CachedDungeonMapStore[0].insert(dungeon.id);
344 }
345
346 if (reload)
347 {
348 CachedDungeonMapStore.clear();
349 // Recalculate locked dungeons
350 for (LfgPlayerDataContainer::const_iterator it = PlayersStore.begin(); it != PlayersStore.end(); ++it)
351 if (Player* player = ObjectAccessor::FindConnectedPlayer(it->first))
352 InitializeLockedDungeons(player, nullptr);
353 }
354 }
DBCStorage< LFGDungeonEntry > sLFGDungeonStore(LFGDungeonEntryfmt)
std::shared_ptr< ResultSet > QueryResult
Definition DatabaseEnvFwd.h:27
DatabaseWorkerPool< WorldDatabaseConnection > WorldDatabase
Accessor to the world database.
Definition DatabaseEnv.cpp:20
#define LOG_INFO(filterType__,...)
Definition Log.h:153
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
Definition Timer.h:131
uint32 getMSTime()
Definition Timer.h:103
Class used to access individual fields of database query result.
Definition Field.h:99
void InitializeLockedDungeons(Player *player, Group const *group=nullptr)
Initializes locked dungeons for given player (called at login or level change)
Definition LFGMgr.cpp:474
Definition ObjectMgr.h:414
float target_Z
Definition ObjectMgr.h:418
float target_X
Definition ObjectMgr.h:416
float target_Orientation
Definition ObjectMgr.h:419
float target_Y
Definition ObjectMgr.h:417
uint32 target_mapId
Definition ObjectMgr.h:415
Definition DBCStructure.h:1281
uint32 TypeID
Definition DBCStructure.h:1293
uint32 ID
Definition DBCStructure.h:1282

References CachedDungeonMapStore, ObjectAccessor::FindConnectedPlayer(), Field::Get(), getMSTime(), GetMSTimeDiffToNow(), lfg::LFGDungeonData::group, lfg::LFGDungeonData::id, LFGDungeonEntry::ID, InitializeLockedDungeons(), lfg::LFG_TYPE_DUNGEON, lfg::LFG_TYPE_HEROIC, lfg::LFG_TYPE_RAID, lfg::LFG_TYPE_RANDOM, LfgDungeonStore, LOG_ERROR, LOG_INFO, lfg::LFGDungeonData::map, lfg::LFGDungeonData::name, lfg::LFGDungeonData::o, PlayersStore, sLFGDungeonStore, sObjectMgr, AreaTriggerTeleport::target_mapId, AreaTriggerTeleport::target_Orientation, AreaTriggerTeleport::target_X, AreaTriggerTeleport::target_Y, AreaTriggerTeleport::target_Z, lfg::LFGDungeonData::type, LFGDungeonEntry::TypeID, WorldDatabase, lfg::LFGDungeonData::x, lfg::LFGDungeonData::y, and lfg::LFGDungeonData::z.

◆ LoadRewards()

void lfg::LFGMgr::LoadRewards ( )

Loads rewards for random dungeons.

Load rewards for completing dungeons.

110 {
111 uint32 oldMSTime = getMSTime();
112
113 for (LfgRewardContainer::iterator itr = RewardMapStore.begin(); itr != RewardMapStore.end(); ++itr)
114 delete itr->second;
115 RewardMapStore.clear();
116
117 // ORDER BY is very important for GetRandomDungeonReward!
118 QueryResult result = WorldDatabase.Query("SELECT dungeonId, maxLevel, firstQuestId, otherQuestId FROM lfg_dungeon_rewards ORDER BY dungeonId, maxLevel ASC");
119
120 if (!result)
121 {
122 LOG_ERROR("lfg", ">> Loaded 0 lfg dungeon rewards. DB table `lfg_dungeon_rewards` is empty!");
123 return;
124 }
125
126 uint32 count = 0;
127
128 Field* fields = nullptr;
129 do
130 {
131 fields = result->Fetch();
132 uint32 dungeonId = fields[0].Get<uint32>();
133 uint32 maxLevel = fields[1].Get<uint8>();
134 uint32 firstQuestId = fields[2].Get<uint32>();
135 uint32 otherQuestId = fields[3].Get<uint32>();
136
137 if (!GetLFGDungeonEntry(dungeonId))
138 {
139 LOG_ERROR("lfg", "Dungeon {} specified in table `lfg_dungeon_rewards` does not exist!", dungeonId);
140 continue;
141 }
142
143 if (!maxLevel || maxLevel > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
144 {
145 LOG_ERROR("lfg", "Level {} specified for dungeon {} in table `lfg_dungeon_rewards` can never be reached!", maxLevel, dungeonId);
146 maxLevel = sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL);
147 }
148
149 if (!firstQuestId || !sObjectMgr->GetQuestTemplate(firstQuestId))
150 {
151 LOG_ERROR("lfg", "First quest {} specified for dungeon {} in table `lfg_dungeon_rewards` does not exist!", firstQuestId, dungeonId);
152 continue;
153 }
154
155 if (otherQuestId && !sObjectMgr->GetQuestTemplate(otherQuestId))
156 {
157 LOG_ERROR("lfg", "Other quest {} specified for dungeon {} in table `lfg_dungeon_rewards` does not exist!", otherQuestId, dungeonId);
158 otherQuestId = 0;
159 }
160
161 RewardMapStore.insert(LfgRewardContainer::value_type(dungeonId, new LfgReward(maxLevel, firstQuestId, otherQuestId)));
162 ++count;
163 } while (result->NextRow());
164
165 LOG_INFO("server.loading", ">> Loaded {} LFG Dungeon Rewards in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
166 LOG_INFO("server.loading", " ");
167 }
@ CONFIG_MAX_PLAYER_LEVEL
Definition WorldConfig.h:195
uint32 GetLFGDungeonEntry(uint32 id)
Return Lfg dungeon entry for given dungeon id.
Definition LFGMgr.cpp:2956

References CONFIG_MAX_PLAYER_LEVEL, Field::Get(), GetLFGDungeonEntry(), getMSTime(), GetMSTimeDiffToNow(), LOG_ERROR, LOG_INFO, RewardMapStore, sObjectMgr, sWorld, and WorldDatabase.

◆ MakeNewGroup()

void lfg::LFGMgr::MakeNewGroup ( LfgProposal const &  proposal)
private

Makes a new group given a proposal

Parameters
[in]proposalProposal to get info from
1692 {
1693 LfgGuidList players;
1694 GuidUnorderedSet playersToTeleport;
1695
1696 // Sort players by role, leader first, then tank, healer and dps
1697 std::vector<ObjectGuid> tanks, healers, dps;
1698
1699 if (proposal.leader && proposal.players.contains(proposal.leader))
1700 players.push_back(proposal.leader);
1701
1702 for (auto const& [guid, player] : proposal.players)
1703 {
1704 if (proposal.isNew || GetGroup(guid) != proposal.group)
1705 playersToTeleport.insert(guid);
1706
1707 if (guid == proposal.leader)
1708 continue;
1709
1710 if (player.role & lfg::PLAYER_ROLE_TANK)
1711 tanks.push_back(guid);
1712 else if (player.role & lfg::PLAYER_ROLE_HEALER)
1713 healers.push_back(guid);
1714 else
1715 dps.push_back(guid);
1716 }
1717
1718 players.insert(players.end(), tanks.begin(), tanks.end());
1719 players.insert(players.end(), healers.begin(), healers.end());
1720 players.insert(players.end(), dps.begin(), dps.end());
1721
1722 // Set the dungeon difficulty
1723 LFGDungeonData const* dungeon = GetLFGDungeon(proposal.dungeonId);
1724 ASSERT(dungeon);
1725
1726 bool isPremadeGroup = false;
1727 Group* grp = proposal.group ? sGroupMgr->GetGroupByGUID(proposal.group.GetCounter()) : nullptr;
1728 if (!grp)
1729 {
1730 ObjectGuid groupGUID;
1731 for (ObjectGuid const& guid : players)
1732 {
1733 if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
1734 {
1735 Group* group = player->GetGroup();
1736 if (!group || (groupGUID && groupGUID != group->GetGUID()))
1737 {
1738 isPremadeGroup = false;
1739 break;
1740 }
1741
1742 groupGUID = group->GetGUID();
1743 isPremadeGroup = true;
1744 }
1745 }
1746 }
1747
1748 ObjectGuid oldGroupGUID;
1749 bool hasRandomLfgMember = proposal.group.IsEmpty();
1750 for (LfgGuidList::const_iterator it = players.begin(); it != players.end(); ++it)
1751 {
1752 ObjectGuid pguid = (*it);
1754 if (!player)
1755 continue;
1756
1757 Group* group = player->GetGroup();
1758 if (isPremadeGroup && !grp)
1759 {
1760 oldGroupGUID = group->GetGUID();
1761 grp = group;
1762 grp->ConvertToLFG(false);
1764 }
1765
1766 if (auto const proposalPlayer = proposal.players.find(pguid); proposalPlayer != proposal.players.end())
1767 {
1768 if (!hasRandomLfgMember && (proposalPlayer->second.group.IsEmpty() || proposalPlayer->second.group != proposal.group))
1769 hasRandomLfgMember = true;
1770 }
1771 else
1772 hasRandomLfgMember = true;
1773
1774 // Xinef: Apply Random Buff
1775 if (grp && !grp->IsLfgWithBuff() && hasRandomLfgMember)
1776 {
1777 if (!group || group->GetGUID() != oldGroupGUID)
1778 grp->AddLfgBuffFlag();
1779 else
1780 oldGroupGUID = group->GetGUID();
1781 }
1782
1783 // Xinef: Store amount of random players player grouped with
1784 if (group)
1785 {
1786 SetRandomPlayersCount(pguid, group->GetMembersCount() >= MAXGROUPSIZE ? 0 : MAXGROUPSIZE - group->GetMembersCount());
1787 oldGroupGUID = group->GetGUID();
1788 if (group != grp)
1789 group->RemoveMember(player->GetGUID());
1790 }
1791 else
1793
1794 if (!grp)
1795 {
1796 grp = new Group();
1797 grp->ConvertToLFG();
1798 grp->Create(player);
1799 ObjectGuid gguid = grp->GetGUID();
1801 sGroupMgr->AddGroup(grp);
1802 grp->SetLfgRoles(pguid, proposal.players.find(pguid)->second.role);
1803 }
1804 else if (group != grp)
1805 {
1806 if (!grp->IsFull())
1807 grp->AddMember(player, proposal.players.find(pguid)->second.role);
1808 }
1809 else
1810 {
1811 grp->SetLfgRoles(pguid, proposal.players.find(pguid)->second.role);
1812 }
1813 }
1814
1815 // pussywizard: crashfix, group wasn't created when iterating players (no player found by guid), proposal is deleted by the calling function
1816 if (!grp)
1817 return;
1818
1819 grp->SetDungeonDifficulty(Difficulty(dungeon->difficulty));
1820 ObjectGuid gguid = grp->GetGUID();
1821 SetDungeon(gguid, dungeon->Entry());
1823
1824 _SaveToDB(gguid);
1825
1826 // Select a player inside to be teleported to
1827 WorldLocation const* teleportLocation = nullptr;
1828 bool leaderTeleportIncluded = false;
1829 for (GroupReference* itr = grp->GetFirstMember(); itr != nullptr; itr = itr->next())
1830 {
1831 if (Player* plr = itr->GetSource())
1832 {
1833 if (grp->IsLeader(plr->GetGUID()) && playersToTeleport.find(plr->GetGUID()) != playersToTeleport.end())
1834 {
1835 leaderTeleportIncluded = true;
1836 }
1837
1838 if (plr->GetMapId() == uint32(dungeon->map) && !proposal.isNew)
1839 {
1840 teleportLocation = plr;
1841 break;
1842 }
1843
1844 // Remove from battleground queues
1845 for (uint8 i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
1846 {
1847 if (BattlegroundQueueTypeId bgQueueTypeId = plr->GetBattlegroundQueueTypeId(i))
1848 {
1849 if (bgQueueTypeId != BATTLEGROUND_QUEUE_NONE)
1850 {
1851 plr->RemoveBattlegroundQueueId(bgQueueTypeId);
1852 sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId).RemovePlayer(plr->GetGUID(), true);
1853 }
1854 }
1855 }
1856 }
1857 }
1858
1859 bool randomDungeon = false;
1860 std::vector<Player*> playersTeleported;
1861 // Teleport Player
1862 for (GuidUnorderedSet::const_iterator it = playersToTeleport.begin(); it != playersToTeleport.end(); ++it)
1863 {
1864 if (Player* player = ObjectAccessor::FindPlayer(*it))
1865 {
1866 if (player->GetGroup() != grp) // pussywizard: could not add because group was full
1867 continue;
1868
1869 // Add the cooldown spell if queued for a random dungeon
1870 // xinef: add aura
1871 if ((randomDungeon || selectedRandomLfgDungeon(player->GetGUID())) && !player->HasAura(LFG_SPELL_DUNGEON_COOLDOWN))
1872 {
1873 randomDungeon = true;
1874 // if player is debugging, don't add dungeon cooldown
1875 if (!m_Testing)
1876 {
1877 player->AddAura(LFG_SPELL_DUNGEON_COOLDOWN, player);
1878 }
1879 }
1880
1881 if (player->GetMapId() == uint32(dungeon->map))
1882 {
1883 // check instance id with leader
1884 if (!leaderTeleportIncluded)
1885 {
1886 if (InstancePlayerBind* ilb = sInstanceSaveMgr->PlayerGetBoundInstance(grp->GetLeaderGUID(), dungeon->map, player->GetDungeonDifficulty()))
1887 {
1888 if (player->GetInstanceId() == ilb->save->GetInstanceId())
1889 {
1890 // Do not teleport if in the same map and instance as leader
1891 continue;
1892 }
1893 }
1894 }
1895
1896 // Remove bind to that map
1897 sInstanceSaveMgr->PlayerUnbindInstance(player->GetGUID(), dungeon->map, player->GetDungeonDifficulty(), true);
1898 }
1899 else
1900 {
1901 // RDF removes all binds to that map
1902 if (randomDungeon)
1903 sInstanceSaveMgr->PlayerUnbindInstance(player->GetGUID(), dungeon->map, player->GetDungeonDifficulty(), true);
1904 }
1905
1906 playersTeleported.push_back(player);
1907 }
1908 }
1909
1910 for (Player* player : playersTeleported)
1911 {
1912 TeleportPlayer(player, false, teleportLocation);
1913 }
1914
1915 if (randomDungeon)
1917 if (Difficulty(dungeon->difficulty) == DUNGEON_DIFFICULTY_HEROIC)
1918 grp->AddLfgHeroicFlag();
1919
1920 // Update group info
1921 grp->SendUpdate();
1922 }
#define sBattlegroundMgr
Definition BattlegroundMgr.h:190
#define ASSERT
Definition Errors.h:68
std::unordered_set< ObjectGuid > GuidUnorderedSet
Definition ObjectGuid.h:261
BattlegroundQueueTypeId
Definition SharedDefines.h:3875
@ BATTLEGROUND_QUEUE_NONE
Definition SharedDefines.h:3876
#define PLAYER_MAX_BATTLEGROUND_QUEUES
Definition SharedDefines.h:153
void AddLfgRandomInstanceFlag()
Definition Group.h:329
void SetDungeonDifficulty(Difficulty difficulty)
Definition Group.cpp:2315
void SetLfgRoles(ObjectGuid guid, const uint8 roles)
Definition Group.cpp:2492
bool IsLeader(ObjectGuid guid) const
Definition Group.cpp:2583
void SendUpdate()
Definition Group.cpp:1894
bool IsLfgWithBuff() const
Definition Group.h:331
void AddLfgBuffFlag()
Definition Group.h:328
void ConvertToLFG(bool restricted=true)
Definition Group.cpp:312
bool AddMember(Player *player, uint8 roles=0)
Definition Group.cpp:444
bool RemoveMember(ObjectGuid guid, RemoveMethod const &method=GROUP_REMOVEMETHOD_DEFAULT, ObjectGuid kicker=ObjectGuid::Empty, char const *reason=nullptr)
Definition Group.cpp:649
void AddLfgHeroicFlag()
Definition Group.h:330
bool Create(Player *leader)
Definition Group.cpp:160
bool IsFull() const
Definition Group.cpp:2502
bool IsEmpty() const
Definition ObjectGuid.h:165
Difficulty GetDungeonDifficulty() const
Definition Player.h:1950
Aura * AddAura(uint32 spellId, Unit *target)
Definition Unit.cpp:14825
Definition Position.h:256
uint32 GetInstanceId() const
Definition Object.h:520
void TeleportPlayer(Player *player, bool out, WorldLocation const *teleportLocation=nullptr)
Teleport a player to/from selected dungeon.
Definition LFGMgr.cpp:2247
bool selectedRandomLfgDungeon(ObjectGuid guid)
Check if given guid applied for random dungeon.
Definition LFGMgr.cpp:2927
void SetRandomPlayersCount(ObjectGuid guid, uint8 count)
Xinef: Set Random Players Count.
Definition LFGMgr.cpp:2766
GuidList LfgGuidList
Definition LFG.h:118
Definition InstanceSaveMgr.h:40

References _SaveToDB(), Group::AddLfgBuffFlag(), Group::AddLfgHeroicFlag(), Group::AddLfgRandomInstanceFlag(), Group::AddMember(), ASSERT, BATTLEGROUND_QUEUE_NONE, Group::ConvertToLFG(), Group::Create(), lfg::LFGDungeonData::difficulty, DUNGEON_DIFFICULTY_HEROIC, lfg::LfgProposal::dungeonId, lfg::LFGDungeonData::Entry(), ObjectAccessor::FindConnectedPlayer(), ObjectAccessor::FindPlayer(), ObjectGuid::GetCounter(), Group::GetFirstMember(), Player::GetGroup(), GetGroup(), Group::GetGUID(), Object::GetGUID(), Group::GetLeaderGUID(), GetLFGDungeon(), Group::GetMembersCount(), lfg::LfgProposal::group, ObjectGuid::IsEmpty(), Group::IsFull(), Group::IsLeader(), Group::IsLfgWithBuff(), lfg::LfgProposal::isNew, lfg::LfgProposal::leader, lfg::LFG_SPELL_DUNGEON_COOLDOWN, lfg::LFG_STATE_DUNGEON, lfg::LFG_STATE_PROPOSAL, m_Testing, lfg::LFGDungeonData::map, MAXGROUPSIZE, PLAYER_MAX_BATTLEGROUND_QUEUES, lfg::PLAYER_ROLE_HEALER, lfg::PLAYER_ROLE_TANK, lfg::LfgProposal::players, Group::RemoveMember(), sBattlegroundMgr, selectedRandomLfgDungeon(), Group::SendUpdate(), SetDungeon(), Group::SetDungeonDifficulty(), Group::SetLfgRoles(), SetRandomPlayersCount(), SetState(), sGroupMgr, sInstanceSaveMgr, and TeleportPlayer().

Referenced by UpdateProposal().

◆ RBPacketAppendGroup()

void lfg::LFGMgr::RBPacketAppendGroup ( RBInternalInfo const &  info,
ByteBuffer &  buffer 
)
1339 {
1340 buffer << info.groupGuid;
1342 buffer << (uint32)flags;
1343 if (flags & LFG_UPDATE_FLAG_COMMENT)
1344 buffer << info.comment;
1345 if (flags & LFG_UPDATE_FLAG_ROLES)
1346 for (uint8 j = 0; j < 3; ++j)
1347 buffer << (uint8)0;
1348 if (!(flags & LFG_UPDATE_FLAG_BINDED))
1349 return;
1350 buffer << info.instanceGuid;
1351 buffer << (uint32)info.encounterMask;
1352 }
@ LFG_UPDATE_FLAG_BINDED
Definition LFGMgr.h:144
@ LFG_UPDATE_FLAG_COMMENT
Definition LFGMgr.h:138
@ LFG_UPDATE_FLAG_ROLES
Definition LFGMgr.h:141

References lfg::RBInternalInfo::comment, lfg::RBInternalInfo::encounterMask, lfg::RBInternalInfo::groupGuid, lfg::RBInternalInfo::instanceGuid, lfg::LFG_UPDATE_FLAG_BINDED, lfg::LFG_UPDATE_FLAG_COMMENT, and lfg::LFG_UPDATE_FLAG_ROLES.

Referenced by RBPacketBuildFull(), and UpdateRaidBrowser().

◆ RBPacketAppendPlayer()

void lfg::LFGMgr::RBPacketAppendPlayer ( RBInternalInfo const &  info,
ByteBuffer &  buffer 
)
1355 {
1356 buffer << info.guid;
1359 | (info.isGroupLeader ? LFG_UPDATE_FLAG_GROUPLEADER : 0);
1360 buffer << (uint32)flags;
1361
1363 {
1364 buffer << (uint8)info._level;
1365 buffer << (uint8)info._class;
1366 buffer << (uint8)info._race;
1367 buffer << (uint8)info._talents0;
1368 buffer << (uint8)info._talents1;
1369 buffer << (uint8)info._talents2;
1370 buffer << (uint32)info._armor;
1371 buffer << (uint32)info._spellDamage;
1372 buffer << (uint32)info._spellHeal;
1373 buffer << (uint32)info._critRatingMelee;
1374 buffer << (uint32)info._critRatingRanged;
1375 buffer << (uint32)info._critRatingSpell;
1376 buffer << (float)info._mp5;
1377 buffer << (float)info._mp5combat;
1378 buffer << (uint32)info._attackPower;
1379 buffer << (uint32)info._agility;
1380 buffer << (uint32)info._health;
1381 buffer << (uint32)info._mana;
1382 buffer << uint32(0); // gear rating, Blizzard's formula is unknown
1383 buffer << (float)info._avgItemLevel;
1384 buffer << (uint32)info._defenseRating;
1385 buffer << (uint32)info._dodgeRating;
1386 buffer << (uint32)info._blockRating;
1387 buffer << (uint32)info._parryRating;
1388 buffer << (uint32)info._hasteRating;
1389 buffer << (uint32)info._expertiseRating;
1390 }
1391
1392 if (flags & LFG_UPDATE_FLAG_COMMENT)
1393 buffer << (info.groupGuid ? std::string("") : info.comment);
1394 if (flags & LFG_UPDATE_FLAG_GROUPLEADER)
1395 buffer << (uint8)1; // isLFM
1396 if (flags & LFG_UPDATE_FLAG_GROUPGUID)
1397 buffer << info.groupGuid;
1398 if (flags & LFG_UPDATE_FLAG_ROLES)
1399 buffer << (uint8)(info.groupGuid ? (info.isGroupLeader ? PLAYER_ROLE_LEADER : 0) : info.roles);
1400 if (flags & LFG_UPDATE_FLAG_AREA)
1401 buffer << (uint32)info._area;
1402 if (flags & LFG_UPDATE_FLAG_STATUS)
1403 buffer << (uint8)0;
1404 if (!(flags & LFG_UPDATE_FLAG_BINDED))
1405 return;
1406 buffer << info.instanceGuid;
1407 buffer << (uint32)info.encounterMask;
1408 }
@ LFG_UPDATE_FLAG_AREA
Definition LFGMgr.h:142
@ LFG_UPDATE_FLAG_GROUPLEADER
Definition LFGMgr.h:139
@ LFG_UPDATE_FLAG_STATUS
Definition LFGMgr.h:143
@ LFG_UPDATE_FLAG_CHARACTERINFO
Definition LFGMgr.h:137
@ LFG_UPDATE_FLAG_GROUPGUID
Definition LFGMgr.h:140

References lfg::RBInternalInfo::_agility, lfg::RBInternalInfo::_area, lfg::RBInternalInfo::_armor, lfg::RBInternalInfo::_attackPower, lfg::RBInternalInfo::_avgItemLevel, lfg::RBInternalInfo::_blockRating, lfg::RBInternalInfo::_class, lfg::RBInternalInfo::_critRatingMelee, lfg::RBInternalInfo::_critRatingRanged, lfg::RBInternalInfo::_critRatingSpell, lfg::RBInternalInfo::_defenseRating, lfg::RBInternalInfo::_dodgeRating, lfg::RBInternalInfo::_expertiseRating, lfg::RBInternalInfo::_hasteRating, lfg::RBInternalInfo::_health, lfg::RBInternalInfo::_level, lfg::RBInternalInfo::_mana, lfg::RBInternalInfo::_mp5, lfg::RBInternalInfo::_mp5combat, lfg::RBInternalInfo::_parryRating, lfg::RBInternalInfo::_race, lfg::RBInternalInfo::_spellDamage, lfg::RBInternalInfo::_spellHeal, lfg::RBInternalInfo::_talents0, lfg::RBInternalInfo::_talents1, lfg::RBInternalInfo::_talents2, lfg::RBInternalInfo::comment, lfg::RBInternalInfo::encounterMask, lfg::RBInternalInfo::groupGuid, lfg::RBInternalInfo::guid, lfg::RBInternalInfo::instanceGuid, lfg::RBInternalInfo::isGroupLeader, lfg::LFG_UPDATE_FLAG_AREA, lfg::LFG_UPDATE_FLAG_BINDED, lfg::LFG_UPDATE_FLAG_CHARACTERINFO, lfg::LFG_UPDATE_FLAG_COMMENT, lfg::LFG_UPDATE_FLAG_GROUPGUID, lfg::LFG_UPDATE_FLAG_GROUPLEADER, lfg::LFG_UPDATE_FLAG_ROLES, lfg::LFG_UPDATE_FLAG_STATUS, lfg::PLAYER_ROLE_LEADER, and lfg::RBInternalInfo::roles.

Referenced by RBPacketBuildFull(), and UpdateRaidBrowser().

◆ RBPacketBuildDifference()

void lfg::LFGMgr::RBPacketBuildDifference ( WorldPacket &  differencePacket,
uint32  dungeonId,
uint32  deletedCounter,
ByteBuffer const &  bufferDeleted,
uint32  groupCounter,
ByteBuffer const &  bufferGroups,
uint32  playerCounter,
ByteBuffer const &  bufferPlayers 
)
1411 {
1412 differencePacket << (uint32)LFG_TYPE_RAID;
1413 differencePacket << (uint32)dungeonId;
1414 differencePacket << (uint8)1;
1415 differencePacket << (uint32)deletedCounter;
1416 differencePacket.append(bufferDeleted);
1417 differencePacket << (uint32)groupCounter;
1418 differencePacket << (uint32)0;
1419 differencePacket.append(bufferGroups);
1420 differencePacket << (uint32)playerCounter;
1421 differencePacket << (uint32)0;
1422 differencePacket.append(bufferPlayers);
1423 }
void append(T value)
Definition ByteBuffer.h:129

References ByteBuffer::append(), and lfg::LFG_TYPE_RAID.

Referenced by UpdateRaidBrowser().

◆ RBPacketBuildFull()

void lfg::LFGMgr::RBPacketBuildFull ( WorldPacket &  fullPacket,
uint32  dungeonId,
RBInternalInfoMap const &  infoMap 
)
1426 {
1427 fullPacket << (uint32)LFG_TYPE_RAID;
1428 fullPacket << (uint32)dungeonId;
1429 fullPacket << (uint8)0;
1430 uint32 groupCounter = 0, playerCounter = 0;
1431 ByteBuffer bufferGroups, bufferPlayers;
1432 for (RBInternalInfoMap::const_iterator itr = infoMap.begin(); itr != infoMap.end(); ++itr)
1433 {
1434 if (itr->second.isGroupLeader)
1435 {
1436 ++groupCounter;
1437 RBPacketAppendGroup(itr->second, bufferGroups);
1438 }
1439 ++playerCounter;
1440 RBPacketAppendPlayer(itr->second, bufferPlayers);
1441 }
1442 fullPacket << (uint32)groupCounter;
1443 fullPacket << (uint32)0;
1444 fullPacket.append(bufferGroups);
1445 fullPacket << (uint32)playerCounter;
1446 fullPacket << (uint32)0;
1447 fullPacket.append(bufferPlayers);
1448 }
Definition ByteBuffer.h:70
void RBPacketAppendPlayer(RBInternalInfo const &info, ByteBuffer &buffer)
Definition LFGMgr.cpp:1354
void RBPacketAppendGroup(RBInternalInfo const &info, ByteBuffer &buffer)
Definition LFGMgr.cpp:1338

References ByteBuffer::append(), lfg::LFG_TYPE_RAID, RBPacketAppendGroup(), and RBPacketAppendPlayer().

Referenced by UpdateRaidBrowser().

◆ RemoveGroupData()

void lfg::LFGMgr::RemoveGroupData ( ObjectGuid  guid)

Removes saved group data.

2679 {
2680 LOG_DEBUG("lfg", "LFGMgr::RemoveGroupData: [{}]", guid.ToString());
2681 LfgGroupDataContainer::iterator it = GroupsStore.find(guid);
2682 if (it == GroupsStore.end())
2683 return;
2684
2685 LfgState state = GetState(guid);
2686 // If group is being formed after proposal success do nothing more
2687 LfgGuidSet const& players = it->second.GetPlayers();
2688 for (auto iterator = players.begin(); iterator != players.end(); ++iterator)
2689 {
2690 ObjectGuid objectGuid = (*iterator);
2691 SetGroup(*iterator, ObjectGuid::Empty);
2692 if (state != LFG_STATE_PROPOSAL)
2693 {
2694 SetState(*iterator, LFG_STATE_NONE);
2695 SendLfgUpdateParty(objectGuid, LfgUpdateData(LFG_UPDATETYPE_REMOVED_FROM_QUEUE));
2696 }
2697 }
2698 GroupsStore.erase(it);
2699 }
void SetGroup(ObjectGuid guid, ObjectGuid group)
Sets player group.
Definition LFGMgr.cpp:2746

References ObjectGuid::Empty, GetState(), GroupsStore, lfg::LFG_STATE_NONE, lfg::LFG_STATE_PROPOSAL, lfg::LFG_UPDATETYPE_REMOVED_FROM_QUEUE, LOG_DEBUG, SendLfgUpdateParty(), SetGroup(), SetState(), and ObjectGuid::ToString().

◆ RemovePlayerFromGroup()

uint8 lfg::LFGMgr::RemovePlayerFromGroup ( ObjectGuid  gguid,
ObjectGuid  guid 
)

Removes a player from a group.

2707 {
2708 return GroupsStore[gguid].RemovePlayer(guid);
2709 }

References GroupsStore.

◆ RemoveProposal()

void lfg::LFGMgr::RemoveProposal ( LfgProposalContainer::iterator  itProposal,
LfgUpdateType  type 
)
private

Remove a proposal from the pool, remove the group that didn't accept (if needed) and readd the other members to the queue

Parameters
[in]itProposalIterator to the proposal to remove
[in]typeType of removal (LFG_UPDATETYPE_PROPOSAL_FAILED, LFG_UPDATETYPE_PROPOSAL_DECLINED)
2042 {
2043 LfgProposal& proposal = itProposal->second;
2044 proposal.state = LFG_PROPOSAL_FAILED;
2045
2046 LOG_DEBUG("lfg", "LFGMgr::RemoveProposal: Proposal {}, state FAILED, UpdateType {}", itProposal->first, type);
2047 // Mark all people that didn't answered as no accept
2049 for (LfgProposalPlayerContainer::iterator it = proposal.players.begin(); it != proposal.players.end(); ++it)
2050 if (it->second.accept == LFG_ANSWER_PENDING)
2051 it->second.accept = LFG_ANSWER_DENY;
2052
2053 // pussywizard: add cooldown for not accepting (after 40 secs) or declining
2054 for (LfgProposalPlayerContainer::iterator it = proposal.players.begin(); it != proposal.players.end(); ++it)
2055 if (it->second.accept == LFG_ANSWER_DENY)
2056 if (Player* plr = ObjectAccessor::FindPlayer(it->first))
2057 if (Aura* aura = plr->AddAura(LFG_SPELL_DUNGEON_COOLDOWN, plr))
2058 aura->SetDuration(150 * IN_MILLISECONDS);
2059
2060 // Mark players/groups to be removed
2061 LfgGuidSet toRemove;
2062 for (LfgProposalPlayerContainer::iterator it = proposal.players.begin(); it != proposal.players.end(); ++it)
2063 {
2064 if (it->second.accept == LFG_ANSWER_AGREE)
2065 continue;
2066
2067 ObjectGuid guid = it->second.group ? it->second.group : it->first;
2068 // Player didn't accept or still pending when no secs left
2069 if (it->second.accept == LFG_ANSWER_DENY || type == LFG_UPDATETYPE_PROPOSAL_FAILED)
2070 {
2071 it->second.accept = LFG_ANSWER_DENY;
2072 toRemove.insert(guid);
2073 }
2074 }
2075
2076 // Notify players
2077 for (LfgProposalPlayerContainer::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it)
2078 {
2079 ObjectGuid guid = it->first;
2080 ObjectGuid gguid = it->second.group ? it->second.group : guid;
2081
2082 SendLfgUpdateProposal(guid, proposal);
2083
2084 if (toRemove.find(gguid) != toRemove.end()) // Didn't accept or in same group that someone that didn't accept
2085 {
2086 LfgUpdateData updateData;
2087 if (it->second.accept == LFG_ANSWER_DENY)
2088 {
2089 updateData.updateType = type;
2090 LOG_DEBUG("lfg", "LFGMgr::RemoveProposal: [{}] didn't accept. Removing from queue and compatible cache", guid.ToString());
2091 }
2092 else
2093 {
2094 updateData.updateType = LFG_UPDATETYPE_REMOVED_FROM_QUEUE;
2095 LOG_DEBUG("lfg", "LFGMgr::RemoveProposal: [{}] in same group that someone that didn't accept. Removing from queue and compatible cache", guid.ToString());
2096 }
2097
2098 RestoreState(guid, "Proposal Fail (didn't accepted or in group with someone that didn't accept");
2099 if (gguid != guid)
2100 {
2101 RestoreState(it->second.group, "Proposal Fail (someone in group didn't accepted)");
2102 SendLfgUpdateParty(guid, updateData);
2103 }
2104 else
2105 SendLfgUpdatePlayer(guid, updateData);
2106 }
2107 else
2108 {
2109 LOG_DEBUG("lfg", "LFGMgr::RemoveProposal: Readding [{}] to queue.", guid.ToString());
2111 if (gguid != guid)
2112 {
2113 SetState(gguid, LFG_STATE_QUEUED);
2115 }
2116 else
2118 }
2119 }
2120
2121 LFGQueue& queue = GetQueue(proposal.players.begin()->first);
2122 // Remove players/groups from queue
2123 for (LfgGuidSet::const_iterator it = toRemove.begin(); it != toRemove.end(); ++it)
2124 {
2125 ObjectGuid guid = *it;
2126 queue.RemoveFromQueue(guid);
2127 proposal.queues.remove(guid);
2128 }
2129
2130 // Readd to queue
2131 for (uint8 i = 0; i < 5 && proposal.queues.guids[i]; ++i)
2132 {
2133 // xinef: this will work as data is not deleted, only references to this data are cleared
2134 // xinef: when new proposal is created
2135 // xinef: successful proposal is also taken into account is similar manner
2136 queue.AddToQueue(proposal.queues.guids[i], true);
2137 }
2138
2139 ProposalsStore.erase(itProposal);
2140 }
constexpr auto IN_MILLISECONDS
Definition Common.h:53
Definition SpellAuras.h:88
void RestoreState(ObjectGuid guid, char const *debugMsg)
Definition LFGMgr.cpp:2573
std::string const & GetComment(ObjectGuid gguid)
Get current player comment (used for LFR)
Definition LFGMgr.cpp:2548
void SendLfgUpdateProposal(ObjectGuid guid, LfgProposal const &proposal)
Definition LFGMgr.cpp:2819
@ LFG_UPDATETYPE_ADDED_TO_QUEUE
Definition LFG.h:59
@ LFG_UPDATETYPE_PROPOSAL_FAILED
Definition LFG.h:56
@ LFG_PROPOSAL_FAILED
Definition LFGMgr.h:82

References lfg::LFGQueue::AddToQueue(), ObjectAccessor::FindPlayer(), GetComment(), GetQueue(), GetSelectedDungeons(), lfg::Lfg5Guids::guids, IN_MILLISECONDS, lfg::LFG_ANSWER_AGREE, lfg::LFG_ANSWER_DENY, lfg::LFG_ANSWER_PENDING, lfg::LFG_PROPOSAL_FAILED, lfg::LFG_SPELL_DUNGEON_COOLDOWN, lfg::LFG_STATE_QUEUED, lfg::LFG_UPDATETYPE_ADDED_TO_QUEUE, lfg::LFG_UPDATETYPE_PROPOSAL_FAILED, lfg::LFG_UPDATETYPE_REMOVED_FROM_QUEUE, LOG_DEBUG, lfg::LfgProposal::players, ProposalsStore, lfg::LfgProposal::queues, lfg::Lfg5Guids::remove(), lfg::LFGQueue::RemoveFromQueue(), RestoreState(), SendLfgUpdateParty(), SendLfgUpdatePlayer(), SendLfgUpdateProposal(), SetState(), lfg::LfgProposal::state, ObjectGuid::ToString(), and lfg::LfgUpdateData::updateType.

Referenced by LeaveLfg(), Update(), and UpdateProposal().

◆ RestoreState()

void lfg::LFGMgr::RestoreState ( ObjectGuid  guid,
char const *  debugMsg 
)
private
2574 {
2575 if (guid.IsGroup())
2576 {
2577 LfgGroupData& data = GroupsStore[guid];
2578 /*if (sLog->ShouldLog(LOG_FILTER_LFG, LOG_LEVEL_DEBUG))
2579 {
2580 std::string const& ps = GetStateString(data.GetState());
2581 std::string const& os = GetStateString(data.GetOldState());
2582 LOG_TRACE("lfg", "LFGMgr::RestoreState: Group: [{}] ({}) State: {}, oldState: {}",
2583 guid.ToString(), debugMsg, ps, os);
2584 }*/
2585
2586 data.RestoreState();
2587 }
2588 else
2589 {
2590 LfgPlayerData& data = PlayersStore[guid];
2591 /*if (sLog->ShouldLog(LOG_FILTER_LFG, LOG_LEVEL_DEBUG))
2592 {
2593 std::string const& ps = GetStateString(data.GetState());
2594 std::string const& os = GetStateString(data.GetOldState());
2595 LOG_TRACE("lfg", "LFGMgr::RestoreState: Player: [{}] ({}) State: {}, oldState: {}",
2596 guid.ToString(), debugMsg, ps, os);
2597 }*/
2598 data.RestoreState();
2599 }
2600 }

References GroupsStore, ObjectGuid::IsGroup(), PlayersStore, lfg::LfgGroupData::RestoreState(), and lfg::LfgPlayerData::RestoreState().

Referenced by RemoveProposal(), Update(), and UpdateRoleCheck().

◆ selectedRandomLfgDungeon()

bool lfg::LFGMgr::selectedRandomLfgDungeon ( ObjectGuid  guid)

Check if given guid applied for random dungeon.

2928 {
2929 if (GetState(guid) != LFG_STATE_NONE)
2930 {
2931 LfgDungeonSet const& dungeons = GetSelectedDungeons(guid);
2932 if (!dungeons.empty())
2933 {
2934 LFGDungeonData const* dungeon = GetLFGDungeon(*dungeons.begin());
2935 if (dungeon && (dungeon->type == LFG_TYPE_RANDOM || dungeon->seasonal))
2936 return true;
2937 }
2938 }
2939
2940 return false;
2941 }

References GetLFGDungeon(), GetSelectedDungeons(), GetState(), lfg::LFG_STATE_NONE, lfg::LFG_TYPE_RANDOM, lfg::LFGDungeonData::seasonal, and lfg::LFGDungeonData::type.

Referenced by MakeNewGroup().

◆ SendLfgBootProposalUpdate()

void lfg::LFGMgr::SendLfgBootProposalUpdate ( ObjectGuid  guid,
LfgPlayerBoot const &  boot 
)
private
2814 {
2815 if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
2816 player->GetSession()->SendLfgBootProposalUpdate(boot);
2817 }

References ObjectAccessor::FindConnectedPlayer().

Referenced by InitBoot(), Update(), and UpdateBoot().

◆ SendLfgJoinResult()

void lfg::LFGMgr::SendLfgJoinResult ( ObjectGuid  guid,
LfgJoinResultData const &  data 
)
private
2808 {
2809 if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
2810 player->GetSession()->SendLfgJoinResult(data);
2811 }

References ObjectAccessor::FindConnectedPlayer().

Referenced by Update(), and UpdateRoleCheck().

◆ SendLfgQueueStatus()

void lfg::LFGMgr::SendLfgQueueStatus ( ObjectGuid  guid,
LfgQueueStatusData const &  data 
)
static

Sends queue status to player.

2826 {
2827 if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
2828 player->GetSession()->SendLfgQueueStatus(data);
2829 }

References ObjectAccessor::FindConnectedPlayer().

Referenced by lfg::LFGQueue::UpdateQueueTimers().

◆ SendLfgRoleCheckUpdate()

void lfg::LFGMgr::SendLfgRoleCheckUpdate ( ObjectGuid  guid,
LfgRoleCheck const &  roleCheck 
)
private
2790 {
2791 if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
2792 player->GetSession()->SendLfgRoleCheckUpdate(roleCheck);
2793 }

References ObjectAccessor::FindConnectedPlayer().

Referenced by Update(), and UpdateRoleCheck().

◆ SendLfgRoleChosen()

void lfg::LFGMgr::SendLfgRoleChosen ( ObjectGuid  guid,
ObjectGuid  pguid,
uint8  roles 
)
private
2784 {
2785 if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
2786 player->GetSession()->SendLfgRoleChosen(pguid, roles);
2787 }

References ObjectAccessor::FindConnectedPlayer(), Player::GetSession(), and WorldSession::SendLfgRoleChosen().

Referenced by UpdateRoleCheck().

◆ SendLfgUpdateParty()

void lfg::LFGMgr::SendLfgUpdateParty ( ObjectGuid  guid,
LfgUpdateData const &  data 
)
private
2802 {
2803 if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
2804 player->GetSession()->SendLfgUpdateParty(data);
2805 }

References ObjectAccessor::FindConnectedPlayer().

Referenced by LeaveAllLfgQueues(), LeaveLfg(), RemoveGroupData(), RemoveProposal(), Update(), UpdateProposal(), and UpdateRoleCheck().

◆ SendLfgUpdatePlayer()

void lfg::LFGMgr::SendLfgUpdatePlayer ( ObjectGuid  guid,
LfgUpdateData const &  data 
)
private
2796 {
2797 if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
2798 player->GetSession()->SendLfgUpdatePlayer(data);
2799 }

References ObjectAccessor::FindConnectedPlayer().

Referenced by LeaveAllLfgQueues(), LeaveLfg(), RemoveProposal(), Update(), and UpdateProposal().

◆ SendLfgUpdateProposal()

void lfg::LFGMgr::SendLfgUpdateProposal ( ObjectGuid  guid,
LfgProposal const &  proposal 
)
private
2820 {
2821 if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
2822 player->GetSession()->SendLfgUpdateProposal(proposal);
2823 }

References ObjectAccessor::FindConnectedPlayer().

Referenced by RemoveProposal(), Update(), and UpdateProposal().

◆ SendRaidBrowserCachedList()

void lfg::LFGMgr::SendRaidBrowserCachedList ( Player *  player,
uint32  dungeonId 
)
1052 {
1053 RBCacheMap::iterator itr = RBCacheStore[player->GetTeamId()].find(dungeonId);
1054 if (itr != RBCacheStore[player->GetTeamId()].end())
1055 {
1056 player->SendDirectMessage(&(itr->second));
1057 return;
1058 }
1059 // send empty packet if cache not found
1061 data << (uint32)LFG_TYPE_RAID;
1062 data << (uint32)dungeonId;
1063 data << (uint8)0;
1064 data << (uint32)0;
1065 data << (uint32)0;
1066 data << (uint32)0;
1067 data << (uint32)0;
1068 player->SendDirectMessage(&data);
1069 }
void SendDirectMessage(WorldPacket const *data) const
Definition Player.cpp:5886
Definition WorldPacket.h:26
RBCacheMap RBCacheStore[2]
Definition LFGMgr.h:433
@ SMSG_UPDATE_LFG_LIST
Definition Opcodes.h:894

References Player::GetTeamId(), lfg::LFG_TYPE_RAID, RBCacheStore, Player::SendDirectMessage(), and SMSG_UPDATE_LFG_LIST.

◆ SendRaidBrowserJoinedPacket()

void lfg::LFGMgr::SendRaidBrowserJoinedPacket ( Player *  p,
LfgDungeonSet &  dungeons,
std::string  comment 
)
1015 {
1016 if (dungeons.empty())
1017 {
1018 RBEntryInfoMap::iterator iter;
1019 uint8 team = p->GetTeamId();
1020 bool setComment = true;
1021 for (RBStoreMap::iterator itr = RaidBrowserStore[team].begin(); itr != RaidBrowserStore[team].end(); ++itr)
1022 if ((iter = itr->second.find(p->GetGUID())) != itr->second.end())
1023 {
1024 dungeons.insert(itr->first);
1025 if (setComment)
1026 {
1027 comment = iter->second.comment;
1028 setComment = false;
1029 }
1030 }
1031 }
1032 LfgJoinResultData joinData;
1033 p->GetSession()->SendLfgJoinResult(joinData);
1034 LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_JOIN_RAIDBROWSER, dungeons, comment);
1035 if (p->GetGroup())
1036 p->GetSession()->SendLfgUpdateParty(updateData);
1037 else
1038 p->GetSession()->SendLfgUpdatePlayer(updateData);
1039 }
void SendLfgUpdateParty(lfg::LfgUpdateData const &updateData)
Definition LFGHandler.cpp:343
@ LFG_UPDATETYPE_JOIN_RAIDBROWSER
Definition LFG.h:51

References Player::GetGroup(), Object::GetGUID(), Player::GetSession(), Player::GetTeamId(), lfg::LFG_UPDATETYPE_JOIN_RAIDBROWSER, RaidBrowserStore, WorldSession::SendLfgJoinResult(), WorldSession::SendLfgUpdateParty(), and WorldSession::SendLfgUpdatePlayer().

Referenced by JoinLfg().

◆ SetCanOverrideRBState()

void lfg::LFGMgr::SetCanOverrideRBState ( ObjectGuid  guid,
bool  val 
)
private
2625 {
2626 PlayersStore[guid].SetCanOverrideRBState(val);
2627 }

References PlayersStore.

Referenced by LeaveLfg().

◆ SetComment()

void lfg::LFGMgr::SetComment ( ObjectGuid  guid,
std::string const &  comment 
)

Sets player lfr comment.

2642 {
2643 LOG_DEBUG("lfg", "LFGMgr::SetComment: [{}] comment: {}", guid.ToString(), comment);
2644 PlayersStore[guid].SetComment(comment);
2645 }

References LOG_DEBUG, PlayersStore, and ObjectGuid::ToString().

Referenced by JoinLfg().

◆ SetDungeon()

void lfg::LFGMgr::SetDungeon ( ObjectGuid  guid,
uint32  dungeon 
)
2630 {
2631 LOG_DEBUG("lfg", "LFGMgr::SetDungeon: [{}] dungeon {}", guid.ToString(), dungeon);
2632 GroupsStore[guid].SetDungeon(dungeon);
2633 }

References GroupsStore, LOG_DEBUG, and ObjectGuid::ToString().

Referenced by _LoadFromDB(), LeaveLfg(), and MakeNewGroup().

◆ SetGroup()

void lfg::LFGMgr::SetGroup ( ObjectGuid  guid,
ObjectGuid  group 
)

Sets player group.

2747 {
2748 PlayersStore[guid].SetGroup(group);
2749 }

References PlayersStore.

Referenced by RemoveGroupData(), and SetupGroupMember().

◆ SetLeader()

void lfg::LFGMgr::SetLeader ( ObjectGuid  gguid,
ObjectGuid  leader 
)

Sets the leader of the group.

2729 {
2730 GroupsStore[gguid].SetLeader(leader);
2731 }

References GroupsStore.

Referenced by _LoadFromDB().

◆ SetLockedDungeons()

void lfg::LFGMgr::SetLockedDungeons ( ObjectGuid  guid,
LfgLockMap const &  lock 
)
private
2667 {
2668 LOG_DEBUG("lfg", "LFGMgr::SetLockedDungeons: [{}]", guid.ToString());
2669 PlayersStore[guid].SetLockedDungeons(lock);
2670 }

References LOG_DEBUG, PlayersStore, and ObjectGuid::ToString().

Referenced by InitializeLockedDungeons().

◆ SetOptions()

void lfg::LFGMgr::SetOptions ( uint32  options)

Sets new lfg options.

2891 {
2892 m_options = options;
2893 }

References m_options.

◆ SetRandomPlayersCount()

void lfg::LFGMgr::SetRandomPlayersCount ( ObjectGuid  guid,
uint8  count 
)

Xinef: Set Random Players Count.

2767 {
2768 PlayersStore[guid].SetRandomPlayersCount(count);
2769 }

References PlayersStore.

Referenced by MakeNewGroup().

◆ SetRoles()

void lfg::LFGMgr::SetRoles ( ObjectGuid  guid,
uint8  roles 
)

Sets player lfg roles.

2636 {
2637 LOG_DEBUG("lfg", "LFGMgr::SetRoles: [{}] roles: {}", guid.ToString(), roles);
2638 PlayersStore[guid].SetRoles(roles);
2639 }

References LOG_DEBUG, PlayersStore, and ObjectGuid::ToString().

Referenced by JoinLfg(), and UpdateRoleCheck().

◆ SetSelectedDungeons()

void lfg::LFGMgr::SetSelectedDungeons ( ObjectGuid  guid,
LfgDungeonSet const &  dungeons 
)
private
2661 {
2662 LOG_DEBUG("lfg", "LFGMgr::SetLockedDungeons: [{}]", guid.ToString());
2663 PlayersStore[guid].SetSelectedDungeons(dungeons);
2664 }

References LOG_DEBUG, PlayersStore, and ObjectGuid::ToString().

Referenced by JoinLfg(), and SetupGroupMember().

◆ SetState()

void lfg::LFGMgr::SetState ( ObjectGuid  guid,
LfgState  state 
)
private
2603 {
2604 if (guid.IsGroup())
2605 {
2606 LfgGroupData& data = GroupsStore[guid];
2607 std::string ns = GetStateString(state);
2608 std::string ps = GetStateString(data.GetState());
2609 std::string os = GetStateString(data.GetOldState());
2610 LOG_DEBUG("lfg", "LFGMgr::SetState: Group: [{}] newState: {}, previous: {}, oldState: {}", guid.ToString(), ns, ps, os);
2611 data.SetState(state);
2612 }
2613 else
2614 {
2615 LfgPlayerData& data = PlayersStore[guid];
2616 std::string ns = GetStateString(state);
2617 std::string ps = GetStateString(data.GetState());
2618 std::string os = GetStateString(data.GetOldState());
2619 LOG_DEBUG("lfg", "LFGMgr::SetState: Player: [{}] newState: {}, previous: {}, oldState: {}", guid.ToString(), ns, ps, os);
2620 data.SetState(state);
2621 }
2622 }
std::string GetStateString(LfgState state)
Definition LFG.cpp:73

References lfg::LfgGroupData::GetOldState(), lfg::LfgPlayerData::GetOldState(), lfg::LfgGroupData::GetState(), lfg::LfgPlayerData::GetState(), lfg::GetStateString(), GroupsStore, ObjectGuid::IsGroup(), LOG_DEBUG, PlayersStore, lfg::LfgGroupData::SetState(), lfg::LfgPlayerData::SetState(), and ObjectGuid::ToString().

Referenced by _LoadFromDB(), FinishDungeon(), InitBoot(), JoinLfg(), LeaveAllLfgQueues(), LeaveLfg(), MakeNewGroup(), RemoveGroupData(), RemoveProposal(), SetupGroupMember(), Update(), UpdateBoot(), UpdateProposal(), and UpdateRoleCheck().

◆ SetTeam()

void lfg::LFGMgr::SetTeam ( ObjectGuid  guid,
TeamId  teamId 
)

Sets player team.

2734 {
2736 teamId = TEAM_ALLIANCE; // @Not Sure About That TeamId is supposed to be uint8 Team = 0(@TrinityCore)
2737
2738 PlayersStore[guid].SetTeam(teamId);
2739 }
@ TEAM_ALLIANCE
Definition SharedDefines.h:748
@ CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP
Definition WorldConfig.h:35

References CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP, PlayersStore, sWorld, and TEAM_ALLIANCE.

◆ SetupGroupMember()

void lfg::LFGMgr::SetupGroupMember ( ObjectGuid  guid,
ObjectGuid  gguid 
)

Initializes player data after loading group data from DB.

2918 {
2919 LfgDungeonSet dungeons;
2920 dungeons.insert(GetDungeon(gguid));
2921 SetSelectedDungeons(guid, dungeons);
2922 SetState(guid, GetState(gguid));
2923 SetGroup(guid, gguid);
2924 AddPlayerToGroup(gguid, guid);
2925 }
void AddPlayerToGroup(ObjectGuid gguid, ObjectGuid guid)
Adds player to group.
Definition LFGMgr.cpp:2711

References AddPlayerToGroup(), GetDungeon(), GetState(), SetGroup(), SetSelectedDungeons(), and SetState().

◆ TeleportPlayer()

void lfg::LFGMgr::TeleportPlayer ( Player *  player,
bool  out,
WorldLocation const *  teleportLocation = nullptr 
)

Teleport a player to/from selected dungeon.

Teleports the player in or out the dungeon

Parameters
[in]playerPlayer to teleport
[in]outTeleport out (true) or in (false)
[in]fromOpcodeFunction called from opcode handlers? (Default false)
2248 {
2249 LFGDungeonData const* dungeon = nullptr;
2250 Group* group = player->GetGroup();
2251
2252 if (group && group->isLFGGroup())
2253 dungeon = GetLFGDungeon(GetDungeon(group->GetGUID()));
2254
2255 if (!dungeon)
2256 {
2258 return;
2259 }
2260
2262
2263 if (!player->IsAlive())
2264 {
2266 }
2267 else if (player->IsFalling() || player->HasUnitState(UNIT_STATE_JUMPING))
2268 {
2270 }
2271 else if (player->IsMirrorTimerActive(FATIGUE_TIMER))
2272 {
2274 }
2275 else if (player->GetVehicle())
2276 {
2278 }
2279 // GetCharm() validates the charmed unit still exists and clears a stale reference,
2280 // unlike GetCharmGUID(); a despawned vehicle must not permanently block the teleport.
2281 else if (player->GetCharm() || player->IsInCombat())
2282 {
2284 }
2285 else if (out && error == LFG_TELEPORTERROR_OK)
2286 {
2287 if (player->GetMapId() == uint32(dungeon->map))
2288 player->TeleportToEntryPoint();
2289
2290 return;
2291 }
2292 else
2293 {
2294 uint32 mapid = dungeon->map;
2295 float x = dungeon->x;
2296 float y = dungeon->y;
2297 float z = dungeon->z;
2298 float orientation = dungeon->o;
2299
2300 if (teleportLocation)
2301 {
2302 teleportLocation->GetWorldLocation(mapid, x, y, z, orientation);
2303 }
2304
2305 if (!player->GetMap()->IsDungeon() || player->GetEntryPoint().GetMapId() == MAPID_INVALID)
2306 {
2307 player->SetEntryPoint();
2308 }
2309
2310 if (!player->TeleportTo(mapid, x, y, z, orientation, 0, nullptr, mapid == player->GetMapId()))
2311 {
2313 }
2314 }
2315
2316 if (error != LFG_TELEPORTERROR_OK)
2317 {
2318 player->GetSession()->SendLfgTeleportError(uint8(error));
2319
2320 LOG_DEBUG("lfg", "Player [{}] could NOT be teleported in to map [{}] (x: {}, y: {}, z: {}) Error: {}",
2321 player->GetName(), dungeon->map, dungeon->x, dungeon->y, dungeon->z, error);
2322 }
2323 else
2324 {
2325 LOG_DEBUG("lfg", "Player [{}] is being teleported in to map [{}] (x: {}, y: {}, z: {})",
2326 player->GetName(), dungeon->map, dungeon->x, dungeon->y, dungeon->z);
2327 }
2328
2329 }
@ FATIGUE_TIMER
Definition Player.h:559
#define MAPID_INVALID
Definition Position.h:253
@ UNIT_STATE_JUMPING
Definition UnitDefines.h:191
bool IsDungeon() const
Definition Map.h:299
void SetEntryPoint()
Definition Player.cpp:11485
bool IsMirrorTimerActive(MirrorTimerType type)
Definition Player.h:2094
bool TeleportToEntryPoint()
Definition Player.cpp:1650
WorldLocation const & GetEntryPoint() const
Definition Player.h:2428
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options=0, Unit *target=nullptr, bool newInstance=false)
Definition Player.cpp:1402
bool IsFalling() const
Definition Player.cpp:2190
Vehicle * GetVehicle() const
Definition Unit.h:1948
Unit * GetCharm() const
Definition Unit.cpp:7588
bool IsAlive() const
Definition Unit.h:1812
bool HasUnitState(const uint32 f) const
Definition Unit.h:742
bool IsInCombat() const
Definition Unit.h:949
Map * GetMap() const
Definition Object.h:637
std::string const & GetName() const
Definition Object.h:535
void SendLfgTeleportError(uint8 err)
Definition LFGHandler.cpp:640
LfgTeleportError
Teleport errors.
Definition LFGMgr.h:88
@ LFG_TELEPORTERROR_INVALID_LOCATION
Definition LFGMgr.h:95
@ LFG_TELEPORTERROR_OK
Definition LFGMgr.h:90
@ LFG_TELEPORTERROR_FATIGUE
Definition LFGMgr.h:94
@ LFG_TELEPORTERROR_COMBAT
Definition LFGMgr.h:96
@ LFG_TELEPORTERROR_PLAYER_DEAD
Definition LFGMgr.h:91
@ LFG_TELEPORTERROR_FALLING
Definition LFGMgr.h:92
@ LFG_TELEPORTERROR_IN_VEHICLE
Definition LFGMgr.h:93

References FATIGUE_TIMER, Unit::GetCharm(), GetDungeon(), Player::GetEntryPoint(), Player::GetGroup(), Group::GetGUID(), GetLFGDungeon(), WorldObject::GetMap(), WorldLocation::GetMapId(), WorldObject::GetName(), Player::GetSession(), Unit::GetVehicle(), WorldLocation::GetWorldLocation(), Unit::HasUnitState(), Unit::IsAlive(), Map::IsDungeon(), Player::IsFalling(), Unit::IsInCombat(), Group::isLFGGroup(), Player::IsMirrorTimerActive(), lfg::LFG_TELEPORTERROR_COMBAT, lfg::LFG_TELEPORTERROR_FALLING, lfg::LFG_TELEPORTERROR_FATIGUE, lfg::LFG_TELEPORTERROR_IN_VEHICLE, lfg::LFG_TELEPORTERROR_INVALID_LOCATION, lfg::LFG_TELEPORTERROR_OK, lfg::LFG_TELEPORTERROR_PLAYER_DEAD, LOG_DEBUG, lfg::LFGDungeonData::map, MAPID_INVALID, lfg::LFGDungeonData::o, WorldSession::SendLfgTeleportError(), Player::SetEntryPoint(), Player::TeleportTo(), Player::TeleportToEntryPoint(), UNIT_STATE_JUMPING, lfg::LFGDungeonData::x, lfg::LFGDungeonData::y, and lfg::LFGDungeonData::z.

Referenced by MakeNewGroup().

◆ ToggleTesting()

void lfg::LFGMgr::ToggleTesting ( )
892 {
893 if (sWorld->getBoolConfig(CONFIG_DEBUG_LFG))
894 {
895 m_Testing = true;
897 }
898 else
899 {
902 }
903 }
@ LANG_DEBUG_LFG_ON
Definition Language.h:1442
@ LANG_DEBUG_LFG_OFF
Definition Language.h:1443
@ LANG_DEBUG_LFG_CONF
Definition Language.h:1444
Definition Chat.h:37
void SendWorldText(std::string_view str)
Definition Chat.cpp:139

References CONFIG_DEBUG_LFG, LANG_DEBUG_LFG_CONF, LANG_DEBUG_LFG_OFF, LANG_DEBUG_LFG_ON, m_Testing, ChatHandler::SendWorldText(), and sWorld.

◆ Update()

void lfg::LFGMgr::Update ( uint32  diff,
uint8  task 
)
357 {
359 return;
360
361 if (task == 0)
362 {
363 time_t currTime = GameTime::GetGameTime().count();
364
365 // Remove obsolete role checks
366 for (LfgRoleCheckContainer::iterator it = RoleChecksStore.begin(); it != RoleChecksStore.end();)
367 {
368 LfgRoleCheckContainer::iterator itRoleCheck = it++;
369 LfgRoleCheck& roleCheck = itRoleCheck->second;
370 if (currTime < roleCheck.cancelTime)
371 continue;
372 roleCheck.state = LFG_ROLECHECK_MISSING_ROLE;
373
374 for (LfgRolesMap::const_iterator itRoles = roleCheck.roles.begin(); itRoles != roleCheck.roles.end(); ++itRoles)
375 {
376 ObjectGuid guid = itRoles->first;
377 RestoreState(guid, "Remove Obsolete RoleCheck");
378 SendLfgRoleCheckUpdate(guid, roleCheck);
379 if (guid == roleCheck.leader)
381 }
382
383 RestoreState(itRoleCheck->first, "Remove Obsolete RoleCheck");
384 RoleChecksStore.erase(itRoleCheck);
385 }
386
387 // Remove obsolete proposals
388 for (LfgProposalContainer::iterator it = ProposalsStore.begin(); it != ProposalsStore.end();)
389 {
390 LfgProposalContainer::iterator itRemove = it++;
391 if (itRemove->second.cancelTime < currTime)
393 }
394
395 // Remove obsolete kicks
396 for (LfgPlayerBootContainer::iterator it = BootsStore.begin(); it != BootsStore.end();)
397 {
398 LfgPlayerBootContainer::iterator itBoot = it++;
399 LfgPlayerBoot& boot = itBoot->second;
400 if (boot.cancelTime < currTime)
401 {
402 boot.inProgress = false;
403 for (LfgAnswerContainer::const_iterator itVotes = boot.votes.begin(); itVotes != boot.votes.end(); ++itVotes)
404 {
405 ObjectGuid pguid = itVotes->first;
406 if (pguid != boot.victim)
407 SendLfgBootProposalUpdate(pguid, boot);
409 }
410 SetState(itBoot->first, LFG_STATE_DUNGEON);
411 BootsStore.erase(itBoot);
412 }
413 }
414
415 // Cleanup expired dungeon cooldowns
417 }
418 else if (task == 1)
419 {
420 this->lastProposalId = m_lfgProposalId; // pussywizard: task 2 is done independantly, store previous value in LFGMgr for future use
421 uint8 newGroupsProcessed = 0;
422 // Check if a proposal can be formed with the new groups being added
423 for (LfgQueueContainer::iterator it = QueuesStore.begin(); it != QueuesStore.end(); ++it)
424 {
425 newGroupsProcessed += it->second.FindGroups();
426 if (newGroupsProcessed)
427 break;
428 }
429
430 // Update all players status queue info
431 if (!newGroupsProcessed) // don't do this on updates that precessed groups (performance)
432 for (LfgQueueContainer::iterator it = QueuesStore.begin(); it != QueuesStore.end(); ++it)
433 it->second.UpdateQueueTimers(tdiff);
434 }
435 else if (task == 2)
436 {
438 {
439 // pussywizard: only one proposal can be created in World::Update (during maps update), and it has id == m_lfgProposalId, so try to find only that one, dunno why for loop here xD
440 for (LfgProposalContainer::const_iterator itProposal = ProposalsStore.find(m_lfgProposalId); itProposal != ProposalsStore.end(); ++itProposal)
441 {
442 uint32 proposalId = itProposal->first;
443 LfgProposal& proposal = ProposalsStore[proposalId];
444
445 ObjectGuid guid;
446 for (LfgProposalPlayerContainer::const_iterator itPlayers = proposal.players.begin(); itPlayers != proposal.players.end(); ++itPlayers)
447 {
448 guid = itPlayers->first;
450 if (ObjectGuid gguid = GetGroup(guid))
451 {
454 }
455 else
457 SendLfgUpdateProposal(guid, proposal);
458 }
459
460 if (proposal.state == LFG_PROPOSAL_SUCCESS) // pussywizard: no idea what's the purpose of this xD
461 UpdateProposal(proposalId, guid, true);
462 }
463 }
464
465 UpdateRaidBrowser(tdiff);
466 }
467 }
void SendLfgRoleCheckUpdate(ObjectGuid guid, LfgRoleCheck const &roleCheck)
Definition LFGMgr.cpp:2789
void SendLfgJoinResult(ObjectGuid guid, LfgJoinResultData const &data)
Definition LFGMgr.cpp:2807
uint32 lastProposalId
pussywizard, store it here because of splitting LFGMgr update into tasks
Definition LFGMgr.h:628
void UpdateProposal(uint32 proposalId, ObjectGuid guid, bool accept)
Updates proposal to join dungeon with player answer.
Definition LFGMgr.cpp:1938
void CleanupDungeonCooldowns()
Definition LFGMgr.cpp:177
void UpdateRaidBrowser(uint32 diff)
Definition LFGMgr.cpp:1109
@ LFG_OPTION_ENABLE_DUNGEON_FINDER
Definition LFGMgr.h:42
@ LFG_UPDATETYPE_PROPOSAL_BEGIN
Definition LFG.h:60
@ LFG_ROLECHECK_MISSING_ROLE
Definition LFGMgr.h:128
@ LFG_PROPOSAL_SUCCESS
Definition LFGMgr.h:83
@ LFG_JOIN_FAILED
Definition LFGMgr.h:104

References BootsStore, lfg::LfgRoleCheck::cancelTime, lfg::LfgPlayerBoot::cancelTime, CleanupDungeonCooldowns(), GetComment(), GameTime::GetGameTime(), GetGroup(), GetSelectedDungeons(), lfg::LfgPlayerBoot::inProgress, isOptionEnabled(), lastProposalId, lfg::LfgRoleCheck::leader, lfg::LFG_JOIN_FAILED, lfg::LFG_OPTION_ENABLE_DUNGEON_FINDER, lfg::LFG_OPTION_ENABLE_RAID_BROWSER, lfg::LFG_OPTION_ENABLE_SEASONAL_BOSSES, lfg::LFG_PROPOSAL_SUCCESS, lfg::LFG_ROLECHECK_MISSING_ROLE, lfg::LFG_STATE_DUNGEON, lfg::LFG_STATE_PROPOSAL, lfg::LFG_UPDATETYPE_PROPOSAL_BEGIN, lfg::LFG_UPDATETYPE_PROPOSAL_FAILED, m_lfgProposalId, lfg::LfgProposal::players, ProposalsStore, QueuesStore, RemoveProposal(), RestoreState(), RoleChecksStore, lfg::LfgRoleCheck::roles, SendLfgBootProposalUpdate(), SendLfgJoinResult(), SendLfgRoleCheckUpdate(), SendLfgUpdateParty(), SendLfgUpdatePlayer(), SendLfgUpdateProposal(), SetState(), lfg::LfgProposal::state, lfg::LfgRoleCheck::state, UpdateProposal(), UpdateRaidBrowser(), lfg::LfgPlayerBoot::victim, and lfg::LfgPlayerBoot::votes.

◆ UpdateBoot()

void lfg::LFGMgr::UpdateBoot ( ObjectGuid  guid,
bool  accept 
)

Updates player boot proposal with new player answer.

Update Boot info with player answer

Parameters
[in]guidPlayer who has answered
[in]playeranswer
2185 {
2186 ObjectGuid gguid = GetGroup(guid);
2187 if (!gguid)
2188 return;
2189
2190 LfgPlayerBootContainer::iterator itBoot = BootsStore.find(gguid);
2191 if (itBoot == BootsStore.end())
2192 return;
2193
2194 LfgPlayerBoot& boot = itBoot->second;
2195
2196 if (boot.votes[guid] != LFG_ANSWER_PENDING) // Cheat check: Player can't vote twice
2197 return;
2198
2199 boot.votes[guid] = LfgAnswer(accept);
2200
2201 uint8 votesNum = 0;
2202 uint8 agreeNum = 0;
2203 for (LfgAnswerContainer::const_iterator itVotes = boot.votes.begin(); itVotes != boot.votes.end(); ++itVotes)
2204 {
2205 if (itVotes->second != LFG_ANSWER_PENDING)
2206 {
2207 ++votesNum;
2208 if (itVotes->second == LFG_ANSWER_AGREE)
2209 ++agreeNum;
2210 }
2211 }
2212
2213 // if we don't have enough votes (agree or deny) do nothing
2214 if (agreeNum < LFG_GROUP_KICK_VOTES_NEEDED && (votesNum - agreeNum) < LFG_GROUP_KICK_VOTES_NEEDED)
2215 return;
2216
2217 // Send update info to all players
2218 boot.inProgress = false;
2219 for (LfgAnswerContainer::const_iterator itVotes = boot.votes.begin(); itVotes != boot.votes.end(); ++itVotes)
2220 {
2221 ObjectGuid pguid = itVotes->first;
2222 if (pguid != boot.victim)
2223 {
2225 SendLfgBootProposalUpdate(pguid, boot);
2226 }
2227 }
2228
2230 if (agreeNum == LFG_GROUP_KICK_VOTES_NEEDED) // Vote passed - Kick player
2231 {
2232 if (Group* group = sGroupMgr->GetGroupByGUID(gguid.GetCounter()))
2234
2235 DecreaseKicksLeft(gguid);
2236 }
2237 BootsStore.erase(itBoot);
2238 }
@ GROUP_REMOVEMETHOD_KICK_LFG
Definition SharedDefines.h:3846
static void RemoveFromGroup(Group *group, ObjectGuid guid, RemoveMethod method=GROUP_REMOVEMETHOD_DEFAULT, ObjectGuid kicker=ObjectGuid::Empty, char const *reason=nullptr)
Definition Player.cpp:2375
void DecreaseKicksLeft(ObjectGuid guid)
Definition LFGMgr.cpp:2672
@ LFG_GROUP_KICK_VOTES_NEEDED
Definition LFGMgr.h:56
LfgAnswer
Answer state (Also used to check compatibilites)
Definition LFG.h:97

References BootsStore, DecreaseKicksLeft(), ObjectGuid::GetCounter(), GetGroup(), GROUP_REMOVEMETHOD_KICK_LFG, lfg::LfgPlayerBoot::inProgress, lfg::LFG_ANSWER_AGREE, lfg::LFG_ANSWER_PENDING, lfg::LFG_GROUP_KICK_VOTES_NEEDED, lfg::LFG_STATE_DUNGEON, Player::RemoveFromGroup(), SendLfgBootProposalUpdate(), SetState(), sGroupMgr, lfg::LfgPlayerBoot::victim, and lfg::LfgPlayerBoot::votes.

◆ UpdateProposal()

void lfg::LFGMgr::UpdateProposal ( uint32  proposalId,
ObjectGuid  guid,
bool  accept 
)

Updates proposal to join dungeon with player answer.

Update Proposal info with player answer

Parameters
[in]proposalIdProposal id to be updated
[in]guidPlayer guid to update answer
[in]acceptPlayer answer
1939 {
1940 // Check if the proposal exists
1941 LfgProposalContainer::iterator itProposal = ProposalsStore.find(proposalId);
1942 if (itProposal == ProposalsStore.end())
1943 return;
1944
1945 LfgProposal& proposal = itProposal->second;
1946
1947 // Check if proposal have the current player
1948 LfgProposalPlayerContainer::iterator itProposalPlayer = proposal.players.find(guid);
1949 if (itProposalPlayer == proposal.players.end())
1950 return;
1951
1952 LfgProposalPlayer& player = itProposalPlayer->second;
1953 player.accept = LfgAnswer(accept);
1954
1955 LOG_DEBUG("lfg", "LFGMgr::UpdateProposal: Player [{}] of proposal {} selected: {}", guid.ToString(), proposalId, accept);
1956 if (!accept)
1957 {
1959 return;
1960 }
1961
1962 // check if all have answered and reorder players (leader first)
1963 bool allAnswered = true;
1964 for (LfgProposalPlayerContainer::const_iterator itPlayers = proposal.players.begin(); itPlayers != proposal.players.end(); ++itPlayers)
1965 if (itPlayers->second.accept != LFG_ANSWER_AGREE) // No answer (-1) or not accepted (0)
1966 allAnswered = false;
1967
1968 if (!m_Testing && !allAnswered)
1969 {
1970 for (LfgProposalPlayerContainer::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it)
1971 SendLfgUpdateProposal(it->first, proposal);
1972
1973 return;
1974 }
1975
1976 bool sendUpdate = proposal.state != LFG_PROPOSAL_SUCCESS;
1977 proposal.state = LFG_PROPOSAL_SUCCESS;
1978 time_t joinTime = GameTime::GetGameTime().count();
1979
1980 LFGQueue& queue = GetQueue(guid);
1981 LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_GROUP_FOUND);
1982 for (LfgProposalPlayerContainer::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it)
1983 {
1984 ObjectGuid pguid = it->first;
1985 ObjectGuid gguid = it->second.group;
1986 uint32 dungeonId = (*GetSelectedDungeons(pguid).begin());
1987 int32 waitTime = -1;
1988 if (sendUpdate)
1989 SendLfgUpdateProposal(pguid, proposal);
1990
1991 if (gguid)
1992 {
1993 waitTime = int32((joinTime - queue.GetJoinTime(gguid)) / IN_MILLISECONDS);
1994 SendLfgUpdateParty(pguid, updateData);
1995 }
1996 else
1997 {
1998 waitTime = int32((joinTime - queue.GetJoinTime(pguid)) / IN_MILLISECONDS);
1999 SendLfgUpdatePlayer(pguid, updateData);
2000 }
2001 updateData.updateType = LFG_UPDATETYPE_REMOVED_FROM_QUEUE;
2002 SendLfgUpdatePlayer(pguid, updateData);
2003 SendLfgUpdateParty(pguid, updateData);
2004
2005 // Update timers
2006 uint8 role = GetRoles(pguid);
2007 role &= ~PLAYER_ROLE_LEADER;
2008 switch (role)
2009 {
2010 case PLAYER_ROLE_DAMAGE:
2011 queue.UpdateWaitTimeDps(waitTime, dungeonId);
2012 break;
2013 case PLAYER_ROLE_HEALER:
2014 queue.UpdateWaitTimeHealer(waitTime, dungeonId);
2015 break;
2016 case PLAYER_ROLE_TANK:
2017 queue.UpdateWaitTimeTank(waitTime, dungeonId);
2018 break;
2019 default:
2020 queue.UpdateWaitTimeAvg(waitTime, dungeonId);
2021 break;
2022 }
2023
2025 }
2026
2027 // Remove players/groups from Queue
2028 for (uint8 i = 0; i < 5 && proposal.queues.guids[i]; ++i)
2029 queue.RemoveQueueData(proposal.queues.guids[i]);
2030
2031 MakeNewGroup(proposal);
2032 ProposalsStore.erase(itProposal);
2033 }
std::int32_t int32
Definition Define.h:103
uint8 GetRoles(ObjectGuid guid)
Get current player roles.
Definition LFGMgr.cpp:2541
void MakeNewGroup(LfgProposal const &proposal)
Definition LFGMgr.cpp:1691
@ LFG_UPDATETYPE_GROUP_FOUND
Definition LFG.h:58

References lfg::LfgProposalPlayer::accept, GameTime::GetGameTime(), lfg::LFGQueue::GetJoinTime(), GetQueue(), GetRoles(), GetSelectedDungeons(), lfg::Lfg5Guids::guids, IN_MILLISECONDS, lfg::LFG_ANSWER_AGREE, lfg::LFG_PROPOSAL_SUCCESS, lfg::LFG_STATE_DUNGEON, lfg::LFG_UPDATETYPE_GROUP_FOUND, lfg::LFG_UPDATETYPE_PROPOSAL_DECLINED, lfg::LFG_UPDATETYPE_REMOVED_FROM_QUEUE, LOG_DEBUG, m_Testing, MakeNewGroup(), lfg::PLAYER_ROLE_DAMAGE, lfg::PLAYER_ROLE_HEALER, lfg::PLAYER_ROLE_TANK, lfg::LfgProposal::players, ProposalsStore, lfg::LfgProposal::queues, RemoveProposal(), lfg::LFGQueue::RemoveQueueData(), SendLfgUpdateParty(), SendLfgUpdatePlayer(), SendLfgUpdateProposal(), SetState(), lfg::LfgProposal::state, ObjectGuid::ToString(), lfg::LfgUpdateData::updateType, lfg::LFGQueue::UpdateWaitTimeAvg(), lfg::LFGQueue::UpdateWaitTimeDps(), lfg::LFGQueue::UpdateWaitTimeHealer(), and lfg::LFGQueue::UpdateWaitTimeTank().

Referenced by Update().

◆ UpdateRaidBrowser()

void lfg::LFGMgr::UpdateRaidBrowser ( uint32  diff)
1110 {
1112 return;
1113
1114 for (uint8 team = 0; team < 2; ++team)
1115 {
1116 if (m_raidBrowserUpdateTimer[team] > diff)
1117 m_raidBrowserUpdateTimer[team] -= diff;
1118 else
1119 m_raidBrowserUpdateTimer[team] = 0;
1120 }
1121
1122 if (GetMSTimeDiff(GameTime::GetGameTimeMS(), GetTimeMS()) > 98ms) // prevent lagging
1123 {
1124 return;
1125 }
1126
1127 ObjectGuid guid, groupGuid, instanceGuid;
1128 uint8 level, Class, race, talents[3];
1129 uint32 dungeonId, encounterMask;
1130 uint32 deletedCounter, groupCounter, playerCounter;
1131 std::string emptyComment;
1132
1133 for (uint8 team = 0; team < 2; ++team)
1134 {
1135 if (m_raidBrowserLastUpdatedDungeonId[team] == 0) // new loop
1136 {
1137 if (m_raidBrowserUpdateTimer[team] > 0) // allowed only with some time interval
1138 continue;
1139 else // reset timer
1140 m_raidBrowserUpdateTimer[team] = 5000;
1141 }
1142
1143 RBUsedDungeonsSet::const_iterator neitr, titr;
1144 for (neitr = RBUsedDungeonsStore[team].begin(); neitr != RBUsedDungeonsStore[team].end(); )
1145 {
1146 titr = neitr++;
1147 dungeonId = (*titr);
1148
1149 // go to next dungeon than previously (one dungeon updated in one LFGMgr::UpdateRaidBrowser)
1150 if (dungeonId <= m_raidBrowserLastUpdatedDungeonId[team])
1151 continue;
1152 m_raidBrowserLastUpdatedDungeonId[team] = dungeonId;
1153
1154 RBEntryInfoMap& entryInfoMap = RaidBrowserStore[team][dungeonId];
1155 LFGDungeonData const* dungeonData = GetLFGDungeon(dungeonId); // checked if exists before inserting to the container
1156 RBInternalInfoMap& currInternalInfoMap = RBInternalInfoStoreCurr[team][dungeonId];
1157 for (RBEntryInfoMap::const_iterator sitr = entryInfoMap.begin(); sitr != entryInfoMap.end(); ++sitr)
1158 {
1159 guid = sitr->first;
1160 groupGuid.Clear();
1162 ASSERT(p);
1163 if (sitr->second.roles == PLAYER_ROLE_LEADER)
1164 {
1165 ASSERT(p->GetGroup());
1166 groupGuid = p->GetGroup()->GetGUID();
1167 }
1168 encounterMask = 0;
1169 instanceGuid.Clear();
1170 if (InstancePlayerBind* bind = sInstanceSaveMgr->PlayerGetBoundInstance(guid, dungeonData->map, dungeonData->difficulty))
1171 if (bind->perm)
1172 {
1173 instanceGuid = ObjectGuid::Create<HighGuid::Instance>(bind->save->GetInstanceId());
1174 encounterMask = bind->save->GetCompletedEncounterMask();
1175 }
1176
1177 currInternalInfoMap[sitr->first] = BuildRBInternalInfo(p, sitr->second.comment, groupGuid,
1178 !groupGuid.IsEmpty(), sitr->second.roles, encounterMask, instanceGuid);
1179
1180 if (!groupGuid)
1181 continue;
1182 for (Group::member_citerator mitr = p->GetGroup()->GetMemberSlots().begin(); mitr != p->GetGroup()->GetMemberSlots().end(); ++mitr)
1183 {
1184 if (mitr->guid == sitr->first) // leader already added
1185 continue;
1186
1187 if (Player* member = ObjectAccessor::FindConnectedPlayer(mitr->guid))
1188 {
1189 currInternalInfoMap[mitr->guid] =
1190 BuildRBInternalInfo(member, emptyComment, groupGuid, false, 0);
1191 continue;
1192 }
1193
1194 // offline: cached level/class/race, other stats are kept from when last seen online
1195 level = 1;
1196 Class = 0;
1197 race = 0;
1198 talents[0] = 0;
1199 talents[1] = 0;
1200 talents[2] = 0;
1201 if (CharacterCacheEntry const* gpd = sCharacterCache->GetCharacterCacheByGuid(mitr->guid))
1202 {
1203 level = gpd->Level;
1204 Class = gpd->Class;
1205 race = gpd->Race;
1206 }
1207 currInternalInfoMap[mitr->guid] = RBInternalInfo(mitr->guid, emptyComment, false, groupGuid,
1208 0, 0, ObjectGuid::Empty, 0, level, Class, race, 0.0f,
1209 talents, 0, 0, 0, 0,
1210 0, 0, 0, 0, 0,
1211 0, 0, 0, 0, 0,
1212 0, 0, 0, 0, 0);
1213 }
1214 }
1215
1216 _rbCopy.clear();
1217 _rbCopy = currInternalInfoMap; // will be saved as prev at the end
1218
1219 RBInternalInfoMap& prevInternalInfoMap = RBInternalInfoStorePrev[team][dungeonId];
1220
1221 // offline players keep their previous stats (itemLevel, talents, area, etc.)
1222 for (auto const& [prevGuid, prevInfo] : prevInternalInfoMap)
1223 {
1224 RBInternalInfoMap::iterator currItr = _rbCopy.find(prevGuid);
1225 if (currItr != _rbCopy.end() && !currItr->second._online)
1226 currItr->second.CopyStats(prevInfo);
1227 }
1228
1229 // The client frees a group's linked players when the group is removed, but removing a grouped
1230 // player on its own leaves a dangling entry in the group's member list. So grouped players are
1231 // never removed individually: a group that lost a member or changed leader is dropped and
1232 // re-sent with all of its members.
1233 _rbPrevGroups.clear();
1234 _rbDroppedGroups.clear();
1235 for (auto const& [prevGuid, prevInfo] : prevInternalInfoMap)
1236 {
1237 if (!prevInfo.groupGuid)
1238 continue;
1239
1240 if (prevInfo.isGroupLeader)
1241 _rbPrevGroups.insert(prevInfo.groupGuid);
1242
1243 RBInternalInfoMap::const_iterator currItr = _rbCopy.find(prevGuid);
1244 bool unchanged = currItr != _rbCopy.end() && currItr->second.groupGuid == prevInfo.groupGuid
1245 && currItr->second.isGroupLeader == prevInfo.isGroupLeader;
1246 if (!unchanged)
1247 _rbDroppedGroups.insert(prevInfo.groupGuid);
1248 }
1249
1250 // compare prev with curr to build difference packet
1251 deletedCounter = 0;
1252 groupCounter = 0;
1253 playerCounter = 0;
1257
1258 for (ObjectGuid const& droppedGroup : _rbDroppedGroups)
1259 {
1260 ++deletedCounter;
1261 _rbBufferDeleted << droppedGroup;
1262 }
1263
1264 for (auto const& [prevGuid, prevInfo] : prevInternalInfoMap)
1265 {
1266 if (!prevInfo.groupGuid && !_rbCopy.contains(prevGuid))
1267 {
1268 ++deletedCounter;
1269 _rbBufferDeleted << prevGuid;
1270 }
1271 }
1272
1273 for (auto const& [currGuid, currInfo] : _rbCopy)
1274 {
1275 if (!currInfo.isGroupLeader)
1276 continue;
1277
1278 bool sendGroup = !_rbPrevGroups.contains(currInfo.groupGuid)
1279 || _rbDroppedGroups.contains(currInfo.groupGuid);
1280 if (!sendGroup)
1281 {
1282 RBInternalInfoMap::const_iterator prevItr = prevInternalInfoMap.find(currGuid);
1283 sendGroup = prevItr == prevInternalInfoMap.end() || prevItr->second.comment != currInfo.comment
1284 || prevItr->second.encounterMask != currInfo.encounterMask
1285 || prevItr->second.instanceGuid != currInfo.instanceGuid;
1286 }
1287
1288 if (sendGroup)
1289 {
1290 ++groupCounter;
1292 }
1293 }
1294
1295 for (auto const& [currGuid, currInfo] : _rbCopy)
1296 {
1297 RBInternalInfoMap::const_iterator prevItr = prevInternalInfoMap.find(currGuid);
1298 // new, freed together with its previous group, in a group re-sent without members, or changed
1299 bool sendPlayer = prevItr == prevInternalInfoMap.end()
1300 || (prevItr->second.groupGuid && _rbDroppedGroups.contains(prevItr->second.groupGuid))
1301 || (currInfo.groupGuid && _rbDroppedGroups.contains(currInfo.groupGuid))
1302 || !prevItr->second.PlayerSameAs(currInfo);
1303
1304 if (sendPlayer)
1305 {
1306 ++playerCounter;
1308 }
1309 }
1310
1311 WorldPacket differencePacket(SMSG_UPDATE_LFG_LIST, 1000);
1312 RBPacketBuildDifference(differencePacket, dungeonId, deletedCounter, _rbBufferDeleted, groupCounter, _rbBufferGroups, playerCounter, _rbBufferPlayers);
1313 WorldPacket fullPacket(SMSG_UPDATE_LFG_LIST, 1000);
1314 RBPacketBuildFull(fullPacket, dungeonId, _rbCopy);
1315
1316 RBCacheStore[team][dungeonId] = fullPacket;
1317 prevInternalInfoMap = _rbCopy;
1318 currInternalInfoMap.clear();
1319
1320 if (entryInfoMap.empty())
1321 RBUsedDungeonsStore[team].erase(titr);
1322
1323 // send difference packet to browsing players
1324 for (RBSearchersMap::const_iterator sitr = RBSearchersStore[team].begin(); sitr != RBSearchersStore[team].end(); ++sitr)
1325 if (sitr->second == dungeonId)
1326 if (Player* p = ObjectAccessor::FindConnectedPlayer(sitr->first))
1327 p->SendDirectMessage(&differencePacket);
1328
1329 break; // one dungeon updated in one LFGMgr::UpdateRaidBrowser
1330 }
1331
1332 // already updated all in this time interval
1333 if (neitr == RBUsedDungeonsStore[team].end())
1335 }
1336 }
#define sCharacterCache
Definition CharacterCache.h:88
@ Class
Requires the player to be a specific class.
Milliseconds GetTimeMS()
Definition Timer.h:84
Milliseconds GetMSTimeDiff(Milliseconds oldMSTime, Milliseconds newMSTime)
Definition Timer.h:91
void clear()
Definition ByteBuffer.h:122
MemberSlotList const & GetMemberSlots() const
Definition Group.h:252
MemberSlotList::const_iterator member_citerator
Definition Group.h:190
ByteBuffer _rbBufferGroups
Definition LFGMgr.h:632
GuidSet _rbPrevGroups
Definition LFGMgr.h:634
ByteBuffer _rbBufferDeleted
Definition LFGMgr.h:631
std::unordered_map< ObjectGuid, RBInternalInfo > RBInternalInfoMap
Definition LFGMgr.h:434
RBInternalInfoMapMap RBInternalInfoStorePrev[2]
Definition LFGMgr.h:436
void RBPacketBuildDifference(WorldPacket &differencePacket, uint32 dungeonId, uint32 deletedCounter, ByteBuffer const &bufferDeleted, uint32 groupCounter, ByteBuffer const &bufferGroups, uint32 playerCounter, ByteBuffer const &bufferPlayers)
Definition LFGMgr.cpp:1410
std::unordered_map< ObjectGuid, RBEntryInfo > RBEntryInfoMap
Definition LFGMgr.h:427
ByteBuffer _rbBufferPlayers
Definition LFGMgr.h:633
GuidSet _rbDroppedGroups
Definition LFGMgr.h:635
void RBPacketBuildFull(WorldPacket &fullPacket, uint32 dungeonId, RBInternalInfoMap const &infoMap)
Definition LFGMgr.cpp:1425
RBInternalInfoMapMap RBInternalInfoStoreCurr[2]
Definition LFGMgr.h:437
RBInternalInfoMap _rbCopy
Definition LFGMgr.h:636
Milliseconds GetGameTimeMS()
Definition GameTime.cpp:44
static RBInternalInfo BuildRBInternalInfo(Player *player, std::string const &comment, ObjectGuid groupGuid, bool isGroupLeader, uint8 roles, uint32 encounterMask=0, ObjectGuid instanceGuid=ObjectGuid::Empty)
Definition LFGMgr.cpp:1071
Definition CharacterCache.h:28

References _rbBufferDeleted, _rbBufferGroups, _rbBufferPlayers, _rbCopy, _rbDroppedGroups, _rbPrevGroups, ASSERT, lfg::BuildRBInternalInfo(), Class, ObjectGuid::Clear(), ByteBuffer::clear(), lfg::LFGDungeonData::difficulty, ObjectGuid::Empty, ObjectAccessor::FindConnectedPlayer(), GameTime::GetGameTimeMS(), Player::GetGroup(), Group::GetGUID(), GetLFGDungeon(), Group::GetMemberSlots(), GetMSTimeDiff(), GetTimeMS(), ObjectGuid::IsEmpty(), isOptionEnabled(), lfg::LFG_OPTION_ENABLE_RAID_BROWSER, m_raidBrowserLastUpdatedDungeonId, m_raidBrowserUpdateTimer, lfg::LFGDungeonData::map, lfg::PLAYER_ROLE_LEADER, RaidBrowserStore, RBCacheStore, RBInternalInfoStoreCurr, RBInternalInfoStorePrev, RBPacketAppendGroup(), RBPacketAppendPlayer(), RBPacketBuildDifference(), RBPacketBuildFull(), RBSearchersStore, RBUsedDungeonsStore, sCharacterCache, sInstanceSaveMgr, and SMSG_UPDATE_LFG_LIST.

Referenced by Update().

◆ UpdateRoleCheck()

void lfg::LFGMgr::UpdateRoleCheck ( ObjectGuid  gguid,
ObjectGuid  guid = ObjectGuid::Empty,
uint8  roles = PLAYER_ROLE_NONE 
)

Updates the role check with player answer.

Update the Role check info with the player selected role.

Parameters
[in]grpGroup guid to update rolecheck
[in]guidPlayer guid (0 = rolecheck failed)
[in]rolesPlayer selected roles
1507 {
1508 if (!gguid)
1509 return;
1510
1511 LfgRoleCheckContainer::iterator itRoleCheck = RoleChecksStore.find(gguid);
1512 if (itRoleCheck == RoleChecksStore.end())
1513 return;
1514
1515 LfgRoleCheck& roleCheck = itRoleCheck->second;
1516 bool sendRoleChosen = roleCheck.state != LFG_ROLECHECK_DEFAULT && guid;
1517
1518 if (!guid)
1519 roleCheck.state = LFG_ROLECHECK_ABORTED;
1520 else if (roles < PLAYER_ROLE_TANK) // Player selected no role.
1521 roleCheck.state = LFG_ROLECHECK_NO_ROLE;
1522 else
1523 {
1524 roleCheck.roles[guid] = roles;
1525
1526 // Check if all players have selected a role
1527 LfgRolesMap::const_iterator itRoles = roleCheck.roles.begin();
1528 while (itRoles != roleCheck.roles.end() && itRoles->second != PLAYER_ROLE_NONE)
1529 ++itRoles;
1530
1531 if (itRoles == roleCheck.roles.end())
1532 {
1533 roleCheck.state = CheckGroupRoles(roleCheck.roles) ? LFG_ROLECHECK_FINISHED : LFG_ROLECHECK_WRONG_ROLES;
1534 }
1535 }
1536
1537 LfgDungeonSet dungeons;
1538 if (roleCheck.rDungeonId)
1539 dungeons.insert(roleCheck.rDungeonId);
1540 else
1541 dungeons = roleCheck.dungeons;
1542
1543 LfgJoinResultData joinData = LfgJoinResultData(LFG_JOIN_FAILED, roleCheck.state);
1544 for (LfgRolesMap::const_iterator it = roleCheck.roles.begin(); it != roleCheck.roles.end(); ++it)
1545 {
1546 ObjectGuid pguid = it->first;
1547
1548 if (sendRoleChosen)
1549 SendLfgRoleChosen(pguid, guid, roles);
1550
1551 SendLfgRoleCheckUpdate(pguid, roleCheck);
1552 switch (roleCheck.state)
1553 {
1555 continue;
1557 SetState(pguid, LFG_STATE_QUEUED);
1558 SetRoles(pguid, it->second);
1559 SendLfgUpdateParty(pguid, LfgUpdateData(LFG_UPDATETYPE_ADDED_TO_QUEUE, dungeons, GetComment(pguid)));
1560 break;
1561 default:
1562 if (roleCheck.leader == pguid)
1563 SendLfgJoinResult(pguid, joinData);
1565 RestoreState(pguid, "Rolecheck Failed");
1566 break;
1567 }
1568 }
1569
1570 if (roleCheck.state == LFG_ROLECHECK_FINISHED)
1571 {
1572 SetState(gguid, LFG_STATE_QUEUED);
1573 LFGQueue& queue = GetQueue(gguid);
1574 queue.AddQueueData(gguid, time_t(GameTime::GetGameTime().count()), roleCheck.dungeons, roleCheck.roles);
1575 RoleChecksStore.erase(itRoleCheck);
1576 }
1577 else if (roleCheck.state != LFG_ROLECHECK_INITIALITING)
1578 {
1579 RestoreState(gguid, "Rolecheck Failed");
1580 RoleChecksStore.erase(itRoleCheck);
1581 }
1582 }
void SendLfgRoleChosen(ObjectGuid guid, ObjectGuid pguid, uint8 roles)
Definition LFGMgr.cpp:2783
@ LFG_UPDATETYPE_ROLECHECK_FAILED
Definition LFG.h:54
@ LFG_ROLECHECK_WRONG_ROLES
Definition LFGMgr.h:129
@ LFG_ROLECHECK_ABORTED
Definition LFGMgr.h:130
@ LFG_ROLECHECK_DEFAULT
Definition LFGMgr.h:125
@ LFG_ROLECHECK_FINISHED
Definition LFGMgr.h:126
@ LFG_ROLECHECK_NO_ROLE
Definition LFGMgr.h:131

References lfg::LFGQueue::AddQueueData(), CheckGroupRoles(), lfg::LfgRoleCheck::dungeons, GetComment(), GameTime::GetGameTime(), GetQueue(), lfg::LfgRoleCheck::leader, lfg::LFG_JOIN_FAILED, lfg::LFG_ROLECHECK_ABORTED, lfg::LFG_ROLECHECK_DEFAULT, lfg::LFG_ROLECHECK_FINISHED, lfg::LFG_ROLECHECK_INITIALITING, lfg::LFG_ROLECHECK_NO_ROLE, lfg::LFG_ROLECHECK_WRONG_ROLES, lfg::LFG_STATE_QUEUED, lfg::LFG_UPDATETYPE_ADDED_TO_QUEUE, lfg::LFG_UPDATETYPE_ROLECHECK_FAILED, lfg::PLAYER_ROLE_NONE, lfg::PLAYER_ROLE_TANK, lfg::LfgRoleCheck::rDungeonId, RestoreState(), RoleChecksStore, lfg::LfgRoleCheck::roles, SendLfgJoinResult(), SendLfgRoleCheckUpdate(), SendLfgRoleChosen(), SendLfgUpdateParty(), SetRoles(), SetState(), and lfg::LfgRoleCheck::state.

Referenced by JoinLfg(), and LeaveLfg().

Member Data Documentation

◆ _rbBufferDeleted

ByteBuffer lfg::LFGMgr::_rbBufferDeleted
private

Referenced by UpdateRaidBrowser().

◆ _rbBufferGroups

ByteBuffer lfg::LFGMgr::_rbBufferGroups
private

Referenced by UpdateRaidBrowser().

◆ _rbBufferPlayers

ByteBuffer lfg::LFGMgr::_rbBufferPlayers
private

Referenced by UpdateRaidBrowser().

◆ _rbCopy

RBInternalInfoMap lfg::LFGMgr::_rbCopy
private

Referenced by UpdateRaidBrowser().

◆ _rbDroppedGroups

GuidSet lfg::LFGMgr::_rbDroppedGroups
private

Referenced by UpdateRaidBrowser().

◆ _rbPrevGroups

GuidSet lfg::LFGMgr::_rbPrevGroups
private

Referenced by UpdateRaidBrowser().

◆ BootsStore

LfgPlayerBootContainer lfg::LFGMgr::BootsStore
private

Current player kicks.

Referenced by InitBoot(), Update(), and UpdateBoot().

◆ CachedDungeonMapStore

LfgCachedDungeonContainer lfg::LFGMgr::CachedDungeonMapStore
private

Stores all dungeons by groupType.

Referenced by GetDungeonsByRandom(), and LoadLFGDungeons().

◆ DungeonCooldownStore

LfgDungeonCooldownContainer lfg::LFGMgr::DungeonCooldownStore
private

Stores dungeon cooldowns per player.

Referenced by AddDungeonCooldown(), CleanupDungeonCooldowns(), ClearDungeonCooldowns(), and FilterCooldownDungeons().

◆ GroupsStore

◆ lastProposalId

uint32 lfg::LFGMgr::lastProposalId
private

pussywizard, store it here because of splitting LFGMgr update into tasks

Referenced by Update().

◆ LfgDungeonStore

LFGDungeonContainer lfg::LFGMgr::LfgDungeonStore
private

◆ m_lfgProposalId

uint32 lfg::LFGMgr::m_lfgProposalId
private

used as internal counter for proposals

Referenced by AddProposal(), and Update().

◆ m_options

uint32 lfg::LFGMgr::m_options
private

Stores config options.

Referenced by GetOptions(), InitializeLockedDungeons(), isOptionEnabled(), and SetOptions().

◆ m_raidBrowserLastUpdatedDungeonId

uint32 lfg::LFGMgr::m_raidBrowserLastUpdatedDungeonId[2]
private

pussywizard: for 2 factions

Referenced by LFGMgr(), and UpdateRaidBrowser().

◆ m_raidBrowserUpdateTimer

uint32 lfg::LFGMgr::m_raidBrowserUpdateTimer[2]
private

pussywizard

Referenced by LFGMgr(), and UpdateRaidBrowser().

◆ m_Testing

bool lfg::LFGMgr::m_Testing
private

◆ PlayersStore

◆ ProposalsStore

LfgProposalContainer lfg::LFGMgr::ProposalsStore
private

Current Proposals.

Referenced by AddProposal(), LeaveLfg(), RemoveProposal(), Update(), and UpdateProposal().

◆ QueuesStore

LfgQueueContainer lfg::LFGMgr::QueuesStore
private

Queues.

Referenced by Clean(), GetQueue(), LeaveAllLfgQueues(), and Update().

◆ RaidBrowserStore

◆ RBCacheStore

RBCacheMap lfg::LFGMgr::RBCacheStore[2]
private

◆ RBInternalInfoStoreCurr

RBInternalInfoMapMap lfg::LFGMgr::RBInternalInfoStoreCurr[2]
private

Referenced by UpdateRaidBrowser().

◆ RBInternalInfoStorePrev

RBInternalInfoMapMap lfg::LFGMgr::RBInternalInfoStorePrev[2]
private

Referenced by UpdateRaidBrowser().

◆ RBSearchersStore

RBSearchersMap lfg::LFGMgr::RBSearchersStore[2]
private

◆ RBUsedDungeonsStore

RBUsedDungeonsSet lfg::LFGMgr::RBUsedDungeonsStore[2]
private

◆ RewardMapStore

LfgRewardContainer lfg::LFGMgr::RewardMapStore
private

Stores rewards for random dungeons.

Referenced by GetRandomDungeonReward(), LoadRewards(), and ~LFGMgr().

◆ RoleChecksStore

LfgRoleCheckContainer lfg::LFGMgr::RoleChecksStore
private

Current Role checks.

Referenced by JoinLfg(), Update(), and UpdateRoleCheck().


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