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, const Map *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.
 
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 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.
 
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 (const RBInternalInfo &info, ByteBuffer &buffer)
 
void RBPacketAppendPlayer (const RBInternalInfo &info, ByteBuffer &buffer)
 
void RBPacketBuildDifference (WorldPacket &differencePacket, uint32 dungeonId, uint32 deletedCounter, ByteBuffer &buffer_deleted, uint32 groupCounter, ByteBuffer &buffer_groups, uint32 playerCounter, ByteBuffer &buffer_players)
 
void RBPacketBuildFull (WorldPacket &fullPacket, uint32 dungeonId, RBInternalInfoMap &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)
 

Static Public Member Functions

static LFGMgrinstance ()
 
static uint8 CheckGroupRoles (LfgRolesMap &groles, bool removeLeaderFlag=true)
 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, RBEntryInfoRBEntryInfoMap
 
typedef std::unordered_map< uint32, RBEntryInfoMapRBStoreMap
 
typedef std::unordered_map< ObjectGuid, uint32RBSearchersMap
 
typedef std::unordered_map< uint32, WorldPacketRBCacheMap
 
typedef std::unordered_map< ObjectGuid, RBInternalInfoRBInternalInfoMap
 
typedef std::unordered_map< uint32, RBInternalInfoMapRBInternalInfoMapMap
 
typedef std::set< uint32RBUsedDungeonsSet
 

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)
 
void _SaveToDB (ObjectGuid guid)
 
LFGDungeonData const * GetLFGDungeon (uint32 id)
 
void RemoveProposal (LfgProposalContainer::iterator itProposal, LfgUpdateType type)
 
void MakeNewGroup (LfgProposal const &proposal)
 
LFGQueueGetQueue (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)
 

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

Detailed Description

Member Typedef Documentation

◆ 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
46 {
47 for (uint8 team = 0; team < 2; ++team)
48 {
49 m_raidBrowserUpdateTimer[team] = 10000;
51 }
52 }
std::uint8_t uint8
Definition Define.h:109
@ CONFIG_LFG_OPTIONSMASK
Definition WorldConfig.h:318
bool m_Testing
Definition LFGMgr.h:633
uint32 m_lfgProposalId
used as internal counter for proposals
Definition LFGMgr.h:616
uint32 m_raidBrowserLastUpdatedDungeonId[2]
pussywizard: for 2 factions
Definition LFGMgr.h:620
uint32 m_options
Stores config options.
Definition LFGMgr.h:617
uint32 m_raidBrowserUpdateTimer[2]
pussywizard
Definition LFGMgr.h:619
#define sWorld
Definition World.h:320

References m_raidBrowserLastUpdatedDungeonId, and m_raidBrowserUpdateTimer.

◆ ~LFGMgr()

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

References RewardMapStore.

Member Function Documentation

◆ _LoadFromDB()

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

Load Lfg group info from DB.

67 {
68 if (!fields)
69 return;
70
71 if (!guid.IsGroup())
72 return;
73
74 SetLeader(guid, ObjectGuid::Create<HighGuid::Player>(fields[0].Get<uint32>()));
75
76 uint32 dungeon = fields[17].Get<uint32>();
77 uint8 state = fields[18].Get<uint8>();
78
79 if (!dungeon || !state)
80 return;
81
82 SetDungeon(guid, dungeon);
83
84 switch (state)
85 {
88 SetState(guid, (LfgState)state);
89 break;
90 default:
91 break;
92 }
93 }
std::uint32_t uint32
Definition Define.h:107
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition Field.h:112
bool IsGroup() const
Definition ObjectGuid.h:178
void SetDungeon(ObjectGuid guid, uint32 dungeon)
Definition LFGMgr.cpp:2488
void SetState(ObjectGuid guid, LfgState state)
Definition LFGMgr.cpp:2461
void SetLeader(ObjectGuid gguid, ObjectGuid leader)
Sets the leader of the group.
Definition LFGMgr.cpp:2575
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
96 {
97 if (!guid.IsGroup())
98 return;
99
101 stmt->SetData(0, guid.GetCounter());
102 stmt->SetData(1, GetDungeon(guid));
103 stmt->SetData(2, GetState(guid));
104 CharacterDatabase.Execute(stmt);
105 }
@ CHAR_REP_LFG_DATA
Definition CharacterDatabase.h:326
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition DatabaseEnv.cpp:21
LowType GetCounter() const
Definition ObjectGuid.h:145
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:2357
uint32 GetDungeon(ObjectGuid guid, bool asId=true)
Get current dungeon.
Definition LFGMgr.cpp:2381

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

Referenced by FinishDungeon(), and MakeNewGroup().

◆ AddPlayerToGroup()

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

Adds player to group.

2571 {
2572 GroupsStore[gguid].AddPlayer(guid);
2573 }
LfgGroupDataContainer GroupsStore
Group data.
Definition LFGMgr.h:632

References GroupsStore.

Referenced by SetupGroupMember().

◆ AddProposal()

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

Add a new Proposal.

1793 {
1794 proposal.id = ++m_lfgProposalId;
1795 ProposalsStore[m_lfgProposalId] = proposal;
1796 return m_lfgProposalId;
1797 }
LfgProposalContainer ProposalsStore
Current Proposals.
Definition LFGMgr.h:629

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

◆ AllQueued()

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

Checks if all players are queued.

2701 {
2702 bool ok = true;
2703
2704 if (check.empty())
2705 return false;
2706
2707 for (uint8 i = 0; i < 5 && check.guids[i]; ++i)
2708 {
2709 ObjectGuid guid = check.guids[i];
2710 if (GetState(guid) != LFG_STATE_QUEUED)
2711 {
2712 LFGQueue& queue = GetQueue(guid);
2713 queue.RemoveFromQueue(guid);
2714 ok = false;
2715 }
2716 }
2717
2718 return ok;
2719 }
Definition ObjectGuid.h:118
LFGQueue & GetQueue(ObjectGuid guid)
Definition LFGMgr.cpp:2683
@ 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,
bool  removeLeaderFlag = true 
)
static

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

1512 {
1513 if (groles.empty())
1514 return 0;
1515
1516 uint8 damage = 0;
1517 uint8 tank = 0;
1518 uint8 healer = 0;
1519
1520 if (removeLeaderFlag)
1521 for (LfgRolesMap::iterator it = groles.begin(); it != groles.end(); ++it)
1522 it->second &= ~PLAYER_ROLE_LEADER;
1523
1524 for (LfgRolesMap::iterator it = groles.begin(); it != groles.end(); ++it)
1525 {
1526 if (it->second == PLAYER_ROLE_NONE)
1527 return 0;
1528
1529 if (it->second & PLAYER_ROLE_DAMAGE)
1530 {
1531 if (it->second != PLAYER_ROLE_DAMAGE)
1532 {
1533 it->second -= PLAYER_ROLE_DAMAGE;
1534 if (uint8 x = CheckGroupRoles(groles, false))
1535 return x;
1536 it->second += PLAYER_ROLE_DAMAGE;
1537 }
1538 else if (damage == LFG_DPS_NEEDED)
1539 return 0;
1540 else
1541 damage++;
1542 }
1543
1544 if (it->second & PLAYER_ROLE_HEALER)
1545 {
1546 if (it->second != PLAYER_ROLE_HEALER)
1547 {
1548 it->second -= PLAYER_ROLE_HEALER;
1549 if (uint8 x = CheckGroupRoles(groles, false))
1550 return x;
1551 it->second += PLAYER_ROLE_HEALER;
1552 }
1553 else if (healer == LFG_HEALERS_NEEDED)
1554 return 0;
1555 else
1556 healer++;
1557 }
1558
1559 if (it->second & PLAYER_ROLE_TANK)
1560 {
1561 if (it->second != PLAYER_ROLE_TANK)
1562 {
1563 it->second -= PLAYER_ROLE_TANK;
1564 if (uint8 x = CheckGroupRoles(groles, false))
1565 return x;
1566 it->second += PLAYER_ROLE_TANK;
1567 }
1568 else if (tank == LFG_TANKS_NEEDED)
1569 return 0;
1570 else
1571 tank++;
1572 }
1573 }
1574 if ((tank + healer + damage) == uint8(groles.size()))
1575 return (8 * tank + 4 * healer + damage);
1576 return 0;
1577 }
static uint8 CheckGroupRoles(LfgRolesMap &groles, bool removeLeaderFlag=true)
Checks if given roles match, modifies given roles map with new roles.
Definition LFGMgr.cpp:1511
@ 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_LEADER
Definition LFG.h:40
@ 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_LEADER, 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.

2723 {
2724 QueuesStore.clear();
2725 }
LfgQueueContainer QueuesStore
Queues.
Definition LFGMgr.h:622

References QueuesStore.

◆ ClearState()

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

◆ DecreaseKicksLeft()

void lfg::LFGMgr::DecreaseKicksLeft ( ObjectGuid  guid)
private
2532 {
2533 LOG_DEBUG("lfg", "LFGMgr::DecreaseKicksLeft: [{}]", guid.ToString());
2534 GroupsStore[guid].DecreaseKicksLeft();
2535 }
#define LOG_DEBUG(filterType__,...)
Definition Log.h:170
std::string ToString() const
Definition ObjectGuid.cpp:47

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

Referenced by UpdateBoot().

◆ FinishDungeon()

void lfg::LFGMgr::FinishDungeon ( ObjectGuid  gguid,
uint32  dungeonId,
const Map 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
2204 {
2205 uint32 gDungeonId = GetDungeon(gguid);
2206 if (gDungeonId != dungeonId)
2207 {
2208 LOG_DEBUG("lfg", "LFGMgr::FinishDungeon: [{}] Finished dungeon {} but group queued for {}. Ignoring", gguid.ToString(), dungeonId, gDungeonId);
2209 return;
2210 }
2211
2212 if (GetState(gguid) == LFG_STATE_FINISHED_DUNGEON) // Shouldn't happen. Do not reward multiple times
2213 {
2214 LOG_DEBUG("lfg", "LFGMgr::FinishDungeon: [{}] Already rewarded group. Ignoring", gguid.ToString());
2215 return;
2216 }
2217
2219 _SaveToDB(gguid); // pussywizard
2220
2221 const LfgGuidSet& players = GetPlayers(gguid);
2222 for (LfgGuidSet::const_iterator it = players.begin(); it != players.end(); ++it)
2223 {
2224 ObjectGuid guid = (*it);
2226 {
2227 LOG_DEBUG("lfg", "LFGMgr::FinishDungeon: [{}] Already rewarded player. Ignoring", guid.ToString());
2228 continue;
2229 }
2230
2231 uint32 rDungeonId = 0;
2232 const LfgDungeonSet& dungeons = GetSelectedDungeons(guid);
2233 if (!dungeons.empty())
2234 rDungeonId = (*dungeons.begin());
2235
2237
2238 // Give rewards only if its a random dungeon
2239 LFGDungeonData const* dungeon = GetLFGDungeon(rDungeonId);
2240
2241 if (!dungeon || (dungeon->type != LFG_TYPE_RANDOM && !dungeon->seasonal))
2242 {
2243 LOG_DEBUG("lfg", "LFGMgr::FinishDungeon: [{}] dungeon {} is not random or seasonal", guid.ToString(), rDungeonId);
2244 continue;
2245 }
2246
2247 Player* player = ObjectAccessor::FindPlayer(guid);
2248 if (!player || player->FindMap() != currMap) // pussywizard: currMap - multithreading crash if on other map (map id check is not enough, binding system is not reliable)
2249 {
2250 LOG_DEBUG("lfg", "LFGMgr::FinishDungeon: [{}] not found in world", guid.ToString());
2251 continue;
2252 }
2253
2254 LFGDungeonData const* dungeonDone = GetLFGDungeon(dungeonId);
2255 uint32 mapId = dungeonDone ? uint32(dungeonDone->map) : 0;
2256
2257 if (player->GetMapId() != mapId)
2258 {
2259 LOG_DEBUG("lfg", "LFGMgr::FinishDungeon: [{}] is in map {} and should be in {} to get reward", guid.ToString(), player->GetMapId(), mapId);
2260 continue;
2261 }
2262
2263 // Remove Dungeon Finder Cooldown if still exists
2265 {
2267 }
2268
2269 // Xinef: Update achievements, set correct amount of randomly grouped players
2270 if (dungeon->difficulty == DUNGEON_DIFFICULTY_HEROIC)
2271 if (uint8 count = GetRandomPlayersCount(player->GetGUID()))
2273
2274 LfgReward const* reward = GetRandomDungeonReward(rDungeonId, player->GetLevel());
2275 if (!reward)
2276 continue;
2277
2278 bool done = false;
2279 Quest const* quest = sObjectMgr->GetQuestTemplate(reward->firstQuest);
2280 if (!quest)
2281 continue;
2282
2283 // if we can take the quest, means that we haven't done this kind of "run", IE: First Heroic Random of Day.
2284 if (player->CanRewardQuest(quest, false))
2285 player->RewardQuest(quest, 0, nullptr, false, true);
2286 else
2287 {
2288 done = true;
2289 quest = sObjectMgr->GetQuestTemplate(reward->otherQuest);
2290 if (!quest)
2291 continue;
2292 // we give reward without informing client (retail does this)
2293 player->RewardQuest(quest, 0, nullptr, false, true);
2294 }
2295
2296 // Give rewards
2297 LOG_DEBUG("lfg", "LFGMgr::FinishDungeon: [{}] done dungeon {}, {} previously done.", player->GetGUID().ToString(), GetDungeon(gguid), done ? " " : " not");
2298 LfgPlayerRewardData data = LfgPlayerRewardData(dungeon->Entry(), GetDungeon(gguid, false), done, quest);
2299 player->GetSession()->SendLfgPlayerReward(data);
2300 }
2301 }
@ 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:1650
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:113
Definition Player.h:1083
void UpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscValue1=0, uint32 miscValue2=0, Unit *unit=nullptr)
Definition PlayerUpdates.cpp:2179
bool CanRewardQuest(Quest const *quest, bool msg)
Definition PlayerQuest.cpp:385
WorldSession * GetSession() const
Definition Player.h:2016
void RewardQuest(Quest const *quest, uint32 reward, Object *questGiver, bool announce=true, bool isLFGReward=false)
Definition PlayerQuest.cpp:659
Definition QuestDef.h:210
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
Definition Unit.cpp:5777
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:4965
uint8 GetLevel() const
Definition Unit.h:1026
uint32 GetMapId() const
Definition Position.h:280
Map * FindMap() const
Definition Object.h:588
void SendLfgPlayerReward(lfg::LfgPlayerRewardData const &lfgPlayerRewardData)
Definition LFGHandler.cpp:471
uint8 GetRandomPlayersCount(ObjectGuid guid)
Xinef: Get Random Players Count.
Definition LFGMgr.cpp:2618
void _SaveToDB(ObjectGuid guid)
Definition LFGMgr.cpp:95
LFGDungeonData const * GetLFGDungeon(uint32 id)
Definition LFGMgr.cpp:168
LfgDungeonSet const & GetSelectedDungeons(ObjectGuid guid)
Get selected dungeons.
Definition LFGMgr.cpp:2413
LfgReward const * GetRandomDungeonReward(uint32 dungeon, uint8 level)
Gets the random dungeon reward corresponding to given dungeon and player level.
Definition LFGMgr.cpp:2327
LfgGuidSet const & GetPlayers(ObjectGuid guid)
Definition LFGMgr.cpp:2598
Player * FindPlayer(ObjectGuid const guid)
Definition ObjectAccessor.cpp:245
GuidSet LfgGuidSet
Definition LFG.h:109
@ LFG_SPELL_DUNGEON_COOLDOWN
Definition LFGMgr.h:52
@ LFG_TYPE_RANDOM
Definition LFGMgr.h:74
std::set< uint32 > LfgDungeonSet
Definition LFG.h:106

References _SaveToDB(), ACHIEVEMENT_CRITERIA_TYPE_USE_LFD_TO_GROUP_WITH_PLAYERS, 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(), lfg::LFG_SPELL_DUNGEON_COOLDOWN, lfg::LFG_STATE_FINISHED_DUNGEON, lfg::LFG_TYPE_RANDOM, LOG_DEBUG, lfg::LFGDungeonData::map, lfg::LfgReward::otherQuest, Unit::RemoveAurasDueToSpell(), Player::RewardQuest(), lfg::LFGDungeonData::seasonal, WorldSession::SendLfgPlayerReward(), SetState(), sObjectMgr, ObjectGuid::ToString(), lfg::LFGDungeonData::type, and Player::UpdateAchievementCriteria().

◆ GetComment()

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

Get current player comment (used for LFR)

2408 {
2409 LOG_DEBUG("lfg", "LFGMgr::GetComment: [{}] = {}", guid.ToString(), PlayersStore[guid].GetComment());
2410 return PlayersStore[guid].GetComment();
2411 }
LfgPlayerDataContainer PlayersStore
Player data.
Definition LFGMgr.h:631

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 
)
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)
1489 {
1490 lockMap.clear();
1491 for (LfgGuidSet::const_iterator it = players.begin(); it != players.end() && !dungeons.empty(); ++it)
1492 {
1493 ObjectGuid guid = (*it);
1494 LfgLockMap const& cachedLockMap = GetLockedDungeons(guid);
1495 for (LfgLockMap::const_iterator it2 = cachedLockMap.begin(); it2 != cachedLockMap.end() && !dungeons.empty(); ++it2)
1496 {
1497 uint32 dungeonId = (it2->first & 0x00FFFFFF); // Compare dungeon ids
1498
1499 LfgDungeonSet::iterator itDungeon = dungeons.find(dungeonId);
1500 if (itDungeon != dungeons.end())
1501 {
1502 dungeons.erase(itDungeon);
1503 lockMap[guid][dungeonId] = it2->second;
1504 }
1505 }
1506 }
1507 if (!dungeons.empty())
1508 lockMap.clear();
1509 }
LfgLockMap const & GetLockedDungeons(ObjectGuid guid)
Get locked dungeons.
Definition LFGMgr.cpp:2419
std::map< uint32, uint32 > LfgLockMap
Definition LFG.h:107

References GetLockedDungeons().

Referenced by JoinLfg().

◆ GetDungeon()

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

Get current dungeon.

2382 {
2383 uint32 dungeon = GroupsStore[guid].GetDungeon(asId);
2384 LOG_DEBUG("lfg", "LFGMgr::GetDungeon: [{}] asId: {} = {}", guid.ToString(), asId, dungeon);
2385 return dungeon;
2386 }

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

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

◆ GetDungeonMapId()

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

Get the map id of the current dungeon.

2389 {
2390 uint32 dungeonId = GroupsStore[guid].GetDungeon(true);
2391 uint32 mapId = 0;
2392 if (dungeonId)
2393 if (LFGDungeonData const* dungeon = GetLFGDungeon(dungeonId))
2394 mapId = dungeon->map;
2395
2396 LOG_DEBUG("lfg", "LFGMgr::GetDungeonMapId: [{}] = {} (DungeonId = {})", guid.ToString(), mapId, dungeonId);
2397 return mapId;
2398 }

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.
2314 {
2315 LFGDungeonData const* dungeon = GetLFGDungeon(randomdungeon);
2316 uint32 group = dungeon ? dungeon->group : 0;
2317 return CachedDungeonMapStore[group];
2318 }
LfgCachedDungeonContainer CachedDungeonMapStore
Stores all dungeons by groupType.
Definition LFGMgr.h:623

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
2349 {
2350 LFGDungeonData const* dungeon = GetLFGDungeon(dungeonId);
2351 if (!dungeon)
2352 return LFG_TYPE_NONE;
2353
2354 return LfgType(dungeon->type);
2355 }
LfgType
Determines the type of instance.
Definition LFGMgr.h:68
@ LFG_TYPE_NONE
Definition LFGMgr.h:69

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

Referenced by JoinLfg().

◆ GetGroup()

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

Gets player group.

2589 {
2590 return PlayersStore[guid].GetGroup();
2591 }

References PlayersStore.

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

◆ GetKicksLeft()

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

Get kicks left in current group.

2426 {
2427 uint8 kicks = GroupsStore[guid].GetKicksLeft();
2428 LOG_DEBUG("lfg", "LFGMgr::GetKicksLeft: [{}] = {}", guid.ToString(), kicks);
2429 return kicks;
2430 }

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

◆ GetLeader()

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

Get leader of the group (using internal data)

2609 {
2610 return GroupsStore[guid].GetLeader();
2611 }

References GroupsStore.

Referenced by GetQueue(), and LeaveLfg().

◆ GetLFGDungeon()

LFGDungeonData const * lfg::LFGMgr::GetLFGDungeon ( uint32  id)
private
169 {
170 LFGDungeonContainer::const_iterator itr = LfgDungeonStore.find(id);
171 if (itr != LfgDungeonStore.end())
172 return &(itr->second);
173
174 return nullptr;
175 }
LFGDungeonContainer LfgDungeonStore
Definition LFGMgr.h:626

References LfgDungeonStore.

Referenced by FinishDungeon(), 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.

2804 {
2805 if (id)
2806 if (LFGDungeonData const* dungeon = GetLFGDungeon(id))
2807 return dungeon->Entry();
2808
2809 return 0;
2810 }

References GetLFGDungeon().

Referenced by LoadRewards().

◆ GetLfgStatus()

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

Returns current lfg status.

2743 {
2744 LfgPlayerData& playerData = PlayersStore[guid];
2745 return LfgUpdateData(LFG_UPDATETYPE_UPDATE_STATUS, playerData.GetState(), playerData.GetSelectedDungeons());
2746 }
@ 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.

2420 {
2421 LOG_DEBUG("lfg", "LFGMgr::GetLockedDungeons: [{}]", guid.ToString());
2422 return PlayersStore[guid].GetLockedDungeons();
2423 }

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)

2370 {
2371 LfgState state;
2372 if (guid.IsGroup())
2373 state = GroupsStore[guid].GetOldState();
2374 else
2375 state = PlayersStore[guid].GetOldState();
2376
2377 LOG_DEBUG("lfg", "LFGMgr::GetOldState: [{}] = {}", guid.ToString(), state);
2378 return state;
2379 }

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

◆ GetOptions()

uint32 lfg::LFGMgr::GetOptions ( )

Gets current lfg options.

2733 {
2734 return m_options;
2735 }

References m_options.

◆ GetPlayerCount()

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

Gets the player count of given group.

2604 {
2605 return GroupsStore[guid].GetPlayerCount();
2606 }

References GroupsStore.

◆ GetPlayers()

LfgGuidSet const & lfg::LFGMgr::GetPlayers ( ObjectGuid  guid)
private
2599 {
2600 return GroupsStore[guid].GetPlayers();
2601 }

References GroupsStore.

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

◆ GetQueue()

LFGQueue & lfg::LFGMgr::GetQueue ( ObjectGuid  guid)
private
2684 {
2685 uint8 queueId = 0;
2686 if (guid.IsGroup())
2687 {
2688 LfgGuidSet const& players = GetPlayers(guid);
2689 ObjectGuid pguid = players.empty() ? ObjectGuid::Empty : (*players.begin());
2690 if (pguid)
2691 queueId = GetTeam(pguid);
2692 else
2693 queueId = GetTeam(GetLeader(guid));
2694 }
2695 else
2696 queueId = GetTeam(guid);
2697 return QueuesStore[queueId];
2698 }
static ObjectGuid const Empty
Definition ObjectGuid.h:120
ObjectGuid GetLeader(ObjectGuid guid)
Get leader of the group (using internal data)
Definition LFGMgr.cpp:2608
TeamId GetTeam(ObjectGuid guid)
Definition LFGMgr.cpp:2560

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.

2813 {
2814 LfgDungeonSet randomDungeons;
2815 for (lfg::LFGDungeonContainer::const_iterator itr = LfgDungeonStore.begin(); itr != LfgDungeonStore.end(); ++itr)
2816 {
2817 lfg::LFGDungeonData const& dungeon = itr->second;
2818 if ((dungeon.type == lfg::LFG_TYPE_RANDOM || (dungeon.seasonal && sLFGMgr->IsSeasonActive(dungeon.id)))
2819 && dungeon.expansion <= expansion && dungeon.minlevel <= level && level <= dungeon.maxlevel)
2820 randomDungeons.insert(dungeon.Entry());
2821 }
2822 return randomDungeons;
2823 }
#define sLFGMgr
Definition LFGMgr.h:641
Definition LFGMgr.h:394
uint8 expansion
Definition LFGMgr.h:407
uint8 minlevel
Definition LFGMgr.h:409
uint8 maxlevel
Definition LFGMgr.h:410
uint8 type
Definition LFGMgr.h:406
uint32 Entry() const
Definition LFGMgr.h:416
bool seasonal
Definition LFGMgr.h:412
uint32 id
Definition LFGMgr.h:403

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
2328 {
2329 LfgReward const* rew = nullptr;
2330 LfgRewardContainerBounds bounds = RewardMapStore.equal_range(dungeon & 0x00FFFFFF);
2331 for (LfgRewardContainer::const_iterator itr = bounds.first; itr != bounds.second; ++itr)
2332 {
2333 rew = itr->second;
2334 // ordered properly at loading
2335 if (itr->second->maxLevel >= level)
2336 break;
2337 }
2338
2339 return rew;
2340 }
std::pair< LfgRewardContainer::const_iterator, LfgRewardContainer::const_iterator > LfgRewardContainerBounds
Definition LFGMgr.h:267

References RewardMapStore.

Referenced by FinishDungeon().

◆ GetRandomPlayersCount()

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

Xinef: Get Random Players Count.

2619 {
2620 return PlayersStore[guid].GetRandomPlayersCount();
2621 }

References PlayersStore.

Referenced by FinishDungeon().

◆ GetRoles()

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

Get current player roles.

2401 {
2402 uint8 roles = PlayersStore[guid].GetRoles();
2403 LOG_DEBUG("lfg", "LFGMgr::GetRoles: [{}] = {}", guid.ToString(), roles);
2404 return roles;
2405 }

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

Referenced by UpdateProposal().

◆ GetSelectedDungeons()

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

Get selected dungeons.

2414 {
2415 LOG_DEBUG("lfg", "LFGMgr::GetSelectedDungeons: [{}]", guid.ToString());
2416 return PlayersStore[guid].GetSelectedDungeons();
2417 }

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

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

◆ GetState()

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

Get current lfg state.

2358 {
2359 LfgState state;
2360 if (guid.IsGroup())
2361 state = GroupsStore[guid].GetState();
2362 else
2363 state = PlayersStore[guid].GetState();
2364
2365 LOG_DEBUG("lfg", "LFGMgr::GetState: [{}] = {}", guid.ToString(), state);
2366 return state;
2367 }

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
2561 {
2562 return PlayersStore[guid].GetTeam();
2563 }

References PlayersStore.

Referenced by GetQueue().

◆ HasIgnore()

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

Checks if given players are ignoring each other.

2624 {
2627 return plr1 && plr2 && (plr1->GetSocial()->HasIgnore(guid2) || plr2->GetSocial()->HasIgnore(guid1));
2628 }
bool HasIgnore(ObjectGuid ignore_guid) const
Definition SocialMgr.cpp:193
PlayerSocial * GetSocial()
Definition Player.h:1160
Player * FindConnectedPlayer(ObjectGuid const guid)
Definition ObjectAccessor.cpp:257

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
2019 {
2020 SetState(gguid, LFG_STATE_BOOT);
2021
2022 LfgPlayerBoot& boot = BootsStore[gguid];
2023 boot.inProgress = true;
2024 boot.cancelTime = time_t(GameTime::GetGameTime().count()) + LFG_TIME_BOOT;
2025 boot.reason = reason;
2026 boot.victim = victim;
2027
2028 LfgGuidSet const& players = GetPlayers(gguid);
2029
2030 // Set votes
2031 for (LfgGuidSet::const_iterator itr = players.begin(); itr != players.end(); ++itr)
2032 {
2033 ObjectGuid guid = (*itr);
2034 SetState(guid, LFG_STATE_BOOT);
2035 boot.votes[guid] = LFG_ANSWER_PENDING;
2036 }
2037
2038 boot.votes[victim] = LFG_ANSWER_DENY; // Victim auto vote NO
2039 boot.votes[kicker] = LFG_ANSWER_AGREE; // Kicker auto vote YES
2040
2041 // Notify players
2042 for (LfgGuidSet::const_iterator it = players.begin(); it != players.end(); ++it)
2043 SendLfgBootProposalUpdate(*it, boot);
2044 }
void SendLfgBootProposalUpdate(ObjectGuid guid, LfgPlayerBoot const &boot)
Definition LFGMgr.cpp:2660
LfgPlayerBootContainer BootsStore
Current player kicks.
Definition LFGMgr.h:630
Seconds GetGameTime()
Definition GameTime.cpp:38
@ LFG_STATE_BOOT
Definition LFG.h:72
@ LFG_TIME_BOOT
Definition LFGMgr.h:49
@ 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
390 {
391 ObjectGuid guid = player->GetGUID();
392
393 uint8 level = player->GetLevel();
394 uint8 expansion = player->GetSession()->Expansion();
395 LfgDungeonSet const& dungeons = GetDungeonsByRandom(0);
396 LfgLockMap lock;
397
398 bool onlySeasonalBosses = m_options == LFG_OPTION_ENABLE_SEASONAL_BOSSES;
399
400 float avgItemLevel = player->GetAverageItemLevelForDF();
401
402 for (LfgDungeonSet::const_iterator it = dungeons.begin(); it != dungeons.end(); ++it)
403 {
404 LFGDungeonData const* dungeon = GetLFGDungeon(*it);
405 if (!dungeon) // should never happen - We provide a list from sLFGDungeonStore
406 continue;
407 MapEntry const* mapEntry = sMapStore.LookupEntry(dungeon->map);
408 DungeonProgressionRequirements const* ar = sObjectMgr->GetAccessRequirement(dungeon->map, Difficulty(dungeon->difficulty));
409
410 uint32 lockData = 0;
411 if (dungeon->expansion > expansion || (onlySeasonalBosses && !dungeon->seasonal))
413 else if (sDisableMgr->IsDisabledFor(DISABLE_TYPE_MAP, dungeon->map, player))
415 else if (sDisableMgr->IsDisabledFor(DISABLE_TYPE_LFG_MAP, dungeon->map, player))
417 else if (dungeon->difficulty > DUNGEON_DIFFICULTY_NORMAL && (!mapEntry || !mapEntry->IsRaid()) && sInstanceSaveMgr->PlayerIsPermBoundToInstance(player->GetGUID(), dungeon->map, Difficulty(dungeon->difficulty)))
419 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))
421 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))
423 else if (dungeon->seasonal && !IsSeasonActive(dungeon->id))
425 else if (player->IsClass(CLASS_DEATH_KNIGHT) && !player->IsGameMaster() &&!(player->IsQuestRewarded(13188) || player->IsQuestRewarded(13189)))
427 else if (ar)
428 {
429 // Check required items
430 for (const ProgressionRequirement* itemRequirement : ar->items)
431 {
432 if (!itemRequirement->checkLeaderOnly || !group || group->GetLeaderGUID() == player->GetGUID())
433 {
434 if (itemRequirement->faction == TEAM_NEUTRAL || itemRequirement->faction == player->GetTeamId(true))
435 {
436 if (!player->HasItemCount(itemRequirement->id, 1))
437 {
439 break;
440 }
441 }
442 }
443 }
444
445 //Check for quests
446 for (const ProgressionRequirement* questRequirement : ar->quests)
447 {
448 if (!questRequirement->checkLeaderOnly || !group || group->GetLeaderGUID() == player->GetGUID())
449 {
450 if (questRequirement->faction == TEAM_NEUTRAL || questRequirement->faction == player->GetTeamId(true))
451 {
452 if (!player->GetQuestRewardStatus(questRequirement->id))
453 {
455 break;
456 }
457 }
458 }
459 }
460
461 //Check for ilvl
462 if (ar->reqItemLevel && (float)ar->reqItemLevel > avgItemLevel)
463 {
465 }
466
467 //Check if player has the required achievements
468 for (const ProgressionRequirement* achievementRequirement : ar->achievements)
469 {
470 if (!achievementRequirement->checkLeaderOnly || !group || group->GetLeaderGUID() == player->GetGUID())
471 {
472 if (achievementRequirement->faction == TEAM_NEUTRAL || achievementRequirement->faction == player->GetTeamId(true))
473 {
474 if (!player->HasAchieved(achievementRequirement->id))
475 {
477 break;
478 }
479 }
480 }
481 }
482 }
483
484 sScriptMgr->OnInitializeLockedDungeons(player, level, lockData, dungeon);
485
486 /* TODO VoA closed if WG is not under team control (LFG_LOCKSTATUS_RAID_LOCKED)
487 lockData = LFG_LOCKSTATUS_TOO_LOW_GEAR_SCORE;
488 lockData = LFG_LOCKSTATUS_TOO_HIGH_GEAR_SCORE;
489 lockData = LFG_LOCKSTATUS_ATTUNEMENT_TOO_LOW_LEVEL;
490 lockData = LFG_LOCKSTATUS_ATTUNEMENT_TOO_HIGH_LEVEL;
491 */
492
493 if (lockData)
494 lock[dungeon->Entry()] = lockData;
495 }
496
497 sScriptMgr->OnAfterInitializeLockedDungeons(player);
498
499 SetLockedDungeons(guid, lock);
500 }
Difficulty
Definition DBCEnums.h:266
@ DUNGEON_DIFFICULTY_NORMAL
Definition DBCEnums.h:269
DBCStorage< MapEntry > sMapStore(MapEntryfmt)
#define sDisableMgr
Definition DisableMgr.h:88
@ DISABLE_TYPE_MAP
Definition DisableMgr.h:30
@ DISABLE_TYPE_LFG_MAP
Definition DisableMgr.h:36
#define sInstanceSaveMgr
Definition InstanceSaveMgr.h:202
#define sScriptMgr
Definition ScriptMgr.h:727
@ CLASS_DEATH_KNIGHT
Definition SharedDefines.h:146
@ TEAM_NEUTRAL
Definition SharedDefines.h:762
@ CONFIG_DUNGEON_ACCESS_REQUIREMENTS_LFG_DBC_LEVEL_OVERRIDE
Definition WorldConfig.h:123
float GetAverageItemLevelForDF()
Definition Player.cpp:15724
bool GetQuestRewardStatus(uint32 quest_id) const
Definition PlayerQuest.cpp:1415
bool HasItemCount(uint32 item, uint32 count=1, bool inBankAlso=false) const
Definition PlayerStorage.cpp:655
TeamId GetTeamId(bool original=false) const
Definition Player.h:2127
bool HasAchieved(uint32 achievementId) const
Definition Player.cpp:13900
bool IsClass(Classes playerClass, ClassContext context=CLASS_CONTEXT_NONE) const override
Definition Player.cpp:1292
bool IsGameMaster() const
Definition Player.h:1177
bool IsQuestRewarded(uint32 quest_id) const
Definition Player.h:1643
uint8 Expansion() const
Definition WorldSession.h:392
void SetLockedDungeons(ObjectGuid guid, LfgLockMap const &lock)
Definition LFGMgr.cpp:2525
LfgDungeonSet const & GetDungeonsByRandom(uint32 randomdungeon)
Definition LFGMgr.cpp:2313
bool IsSeasonActive(uint32 dungeonId)
Checks if Seasonal dungeon is active.
Definition LFGMgr.cpp:2748
@ LFG_LOCKSTATUS_INSUFFICIENT_EXPANSION
Definition LFG.h:81
@ LFG_LOCKSTATUS_TOO_LOW_LEVEL
Definition LFG.h:82
@ LFG_LOCKSTATUS_RAID_LOCKED
Definition LFG.h:86
@ 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:43
Definition Player.h:949
uint8 levelMax
Definition Player.h:951
uint8 levelMin
Definition Player.h:950
uint16 reqItemLevel
Definition Player.h:952
Definition DBCStructure.h:1326
bool IsRaid() const
Definition DBCStructure.h:1355
Definition Player.h:940

References DungeonProgressionRequirements::achievements, CLASS_DEATH_KNIGHT, CONFIG_DUNGEON_ACCESS_REQUIREMENTS_LFG_DBC_LEVEL_OVERRIDE, lfg::LFGDungeonData::difficulty, DISABLE_TYPE_LFG_MAP, DISABLE_TYPE_MAP, 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(), lfg::LFGDungeonData::id, Player::IsClass(), 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, DungeonProgressionRequirements::reqItemLevel, sDisableMgr, 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.

2791 {
2792 if (!guid.IsGroup())
2793 guid = GetGroup(guid);
2794
2795 if (uint32 dungeonId = GetDungeon(guid, true))
2796 if (LFGDungeonData const* dungeon = GetLFGDungeon(dungeonId))
2797 if (uint32(dungeon->map) == map && dungeon->difficulty == difficulty)
2798 return true;
2799
2800 return false;
2801 }
ObjectGuid GetGroup(ObjectGuid guid)
Gets player group.
Definition LFGMgr.cpp:2588

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

◆ instance()

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

References instance().

Referenced by instance().

◆ IsLfgGroup()

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

Check if given group guid is lfg.

2679 {
2680 return guid && guid.IsGroup() && GroupsStore[guid].IsLfgGroup();
2681 }

References GroupsStore, and ObjectGuid::IsGroup().

◆ isOptionEnabled()

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

Checks if given lfg option is enabled.

2728 {
2729 return m_options & option;
2730 }

References m_options.

Referenced by Update().

◆ IsSeasonActive()

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

Checks if Seasonal dungeon is active.

2749 {
2750 switch (dungeonId)
2751 {
2760 }
2761 return false;
2762 }
bool IsHolidayActive(HolidayIds id)
Definition GameEventMgr.cpp:1950
@ HOLIDAY_HALLOWS_END
Definition SharedDefines.h:2992
@ HOLIDAY_FIRE_FESTIVAL
Definition SharedDefines.h:2995
@ HOLIDAY_LOVE_IS_IN_THE_AIR
Definition SharedDefines.h:3007
@ HOLIDAY_BREWFEST
Definition SharedDefines.h:2997
@ LFG_DUNGEON_FROST_LORD_AHUNE
Definition LFGMgr.h:149
@ LFG_DUNGEON_HEADLESS_HORSEMAN
Definition LFGMgr.h:148
@ LFG_DUNGEON_CROWN_CHEMICAL_CO
Definition LFGMgr.h:151
@ LFG_DUNGEON_COREN_DIREBREW
Definition LFGMgr.h:150

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.

579{ 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
513 {
514 if (!player || dungeons.empty())
515 return;
516
517 Group* grp = player->GetGroup();
518 ObjectGuid guid = player->GetGUID();
519 ObjectGuid gguid = grp ? grp->GetGUID() : guid;
520 LfgJoinResultData joinData;
521 LfgGuidSet players;
522 uint32 rDungeonId = 0;
523 bool isContinue = grp && grp->isLFGGroup() && GetState(gguid) != LFG_STATE_FINISHED_DUNGEON;
524
525 if (grp && (grp->isBGGroup() || grp->isBFGroup()))
526 return;
527
528 if (!sScriptMgr->OnPlayerCanJoinLfg(player, roles, dungeons, comment))
529 return;
530
531 // pussywizard: can't join LFG/LFR while using LFR
532 if (GetState(player->GetGUID()) == LFG_STATE_RAIDBROWSER)
533 {
534 LfgDungeonSet tmp;
535 SendRaidBrowserJoinedPacket(player, tmp, ""); // the df "eye" can disappear in various case, resend if needed
536 return;
537 }
538
539 // Do not allow to change dungeon in the middle of a current dungeon
540 if (isContinue)
541 {
542 dungeons.clear();
543 dungeons.insert(GetDungeon(gguid));
544 }
545
546 LfgState state = GetState(gguid);
547 switch (state)
548 {
549 case LFG_STATE_ROLECHECK: // if joining again during rolecheck (eg. many players clicked continue inside instance)
550 if (gguid.IsGroup())
551 UpdateRoleCheck(gguid); // abort role check and remove from RoleChecksStore
552 break;
553 case LFG_STATE_QUEUED: // joining again while in a queue
554 {
555 LFGQueue& queue = GetQueue(gguid);
556 queue.RemoveFromQueue(gguid);
557 }
558 break;
559 case LFG_STATE_PROPOSAL: // if joining again during proposal
560 joinData.result = LFG_JOIN_INTERNAL_ERROR;
561 break;
562 /*case LFG_STATE_FINISHED_DUNGEON:
563 if (grp && grp->isLFGGroup())
564 joinData.result = LFG_JOIN_PARTY_NOT_MEET_REQS;
565 break;
566 */
567 default:
568 break;
569 }
570
571 // Check if all dungeons are valid
572 bool isRaid = false;
573 if (joinData.result == LFG_JOIN_OK)
574 {
575 bool isDungeon = false;
576 for (LfgDungeonSet::const_iterator it = dungeons.begin(); it != dungeons.end() && joinData.result == LFG_JOIN_OK; ++it)
577 {
578 LfgType type = GetDungeonType(*it);
579 switch (type)
580 {
581 case LFG_TYPE_RANDOM:
582 if (dungeons.size() > 1) // Only allow 1 random dungeon
583 {
584 joinData.result = LFG_JOIN_DUNGEON_INVALID;
585 }
586 else
587 {
588 rDungeonId = (*dungeons.begin());
589 sScriptMgr->OnPlayerQueueRandomDungeon(player, rDungeonId);
590 }
591 [[fallthrough]]; // On purpose (Random can only be dungeon or heroic dungeon)
592 case LFG_TYPE_HEROIC:
593 case LFG_TYPE_DUNGEON:
594 if (isRaid)
595 {
596 joinData.result = LFG_JOIN_MIXED_RAID_DUNGEON;
597 }
598 isDungeon = true;
599 break;
600 case LFG_TYPE_RAID:
601 if (isDungeon)
602 {
603 joinData.result = LFG_JOIN_MIXED_RAID_DUNGEON;
604 }
605 isRaid = true;
606 break;
607 default:
608 LOG_ERROR("lfg", "Wrong dungeon type {} for dungeon {}", type, *it);
609 joinData.result = LFG_JOIN_DUNGEON_INVALID;
610 break;
611 }
612 }
613 }
614
615 if (!isRaid && joinData.result == LFG_JOIN_OK)
616 {
617 // Check player or group member restrictions
618 if (player->InBattleground() || (player->InBattlegroundQueue() && !sWorld->getBoolConfig(CONFIG_ALLOW_JOIN_BG_AND_LFG)))
619 {
620 joinData.result = LFG_JOIN_USING_BG_SYSTEM;
621 }
622 else if (player->HasAura(LFG_SPELL_DUNGEON_DESERTER))
623 {
624 joinData.result = LFG_JOIN_DESERTER;
625 }
626 else if (dungeons.empty())
627 {
628 joinData.result = LFG_JOIN_NOT_MEET_REQS;
629 }
630 else if (grp)
631 {
632 if (grp->GetMembersCount() > MAXGROUPSIZE)
633 joinData.result = LFG_JOIN_TOO_MUCH_MEMBERS;
634 else
635 {
636 uint8 memberCount = 0;
637 for (GroupReference* itr = grp->GetFirstMember(); itr != nullptr && joinData.result == LFG_JOIN_OK; itr = itr->next())
638 {
639 if (Player* plrg = itr->GetSource())
640 {
641 if (plrg->HasAura(LFG_SPELL_DUNGEON_DESERTER))
642 {
643 joinData.result = LFG_JOIN_PARTY_DESERTER;
644 }
645 else if (plrg->InBattleground() || (plrg->InBattlegroundQueue() && !sWorld->getBoolConfig(CONFIG_ALLOW_JOIN_BG_AND_LFG)))
646 {
647 joinData.result = LFG_JOIN_USING_BG_SYSTEM;
648 }
649
650 ++memberCount;
651 players.insert(plrg->GetGUID());
652 }
653 }
654
655 if (joinData.result == LFG_JOIN_OK && memberCount != grp->GetMembersCount())
656 joinData.result = LFG_JOIN_DISCONNECTED;
657 }
658 }
659 else
660 players.insert(player->GetGUID());
661
662 // Xinef: Check dungeon cooldown only for random dungeons
663 // Xinef: Moreover check this only if dungeon is not started, afterwards its obvious that players will have the cooldown
664 if (joinData.result == LFG_JOIN_OK && !isContinue && rDungeonId)
665 {
666 if (player->HasAura(LFG_SPELL_DUNGEON_COOLDOWN)) // xinef: added !isContinue
667 joinData.result = LFG_JOIN_RANDOM_COOLDOWN;
668 else if (grp)
669 {
670 for (GroupReference* itr = grp->GetFirstMember(); itr != nullptr && joinData.result == LFG_JOIN_OK; itr = itr->next())
671 if (Player* plrg = itr->GetSource())
672 if (plrg->HasAura(LFG_SPELL_DUNGEON_COOLDOWN)) // xinef: added !isContinue
673 joinData.result = LFG_JOIN_PARTY_RANDOM_COOLDOWN;
674 }
675 }
676 }
677
678 if (isRaid)
679 players.insert(player->GetGUID());
680
681 if (joinData.result == LFG_JOIN_OK)
682 {
683 // Expand random dungeons and check restrictions
684 if (rDungeonId)
685 dungeons = GetDungeonsByRandom(rDungeonId);
686
687 // if we have lockmap then there are no compatible dungeons
688 // xinef: dont check compatibile dungeons for already running group (bind problems)
689 if (!isContinue)
690 {
691 GetCompatibleDungeons(dungeons, players, joinData.lockmap);
692 if (dungeons.empty())
694 }
695 }
696
697 // pussywizard:
698 if (isRaid && grp && (grp->isLFGGroup() || guid != grp->GetLeaderGUID()))
699 return;
700
701 // Do not allow to change dungeon in the middle of a current dungeon
702 if (!isRaid && isContinue && grp->GetMembersCount() == 5)
703 {
704 dungeons.clear();
705 dungeons.insert(GetDungeon(gguid));
706 joinData.result = LFG_JOIN_PARTY_NOT_MEET_REQS;
707 }
708
709 // Can't join. Send result
710 if (joinData.result != LFG_JOIN_OK)
711 {
712 LOG_DEBUG("lfg", "LFGMgr::Join: [{}] joining with {} members. result: {}", guid.ToString(), grp ? grp->GetMembersCount() : 1, joinData.result);
713 if (!dungeons.empty()) // Only should show lockmap when have no dungeons available
714 joinData.lockmap.clear();
715 player->GetSession()->SendLfgJoinResult(joinData);
716 return;
717 }
718
719 SetComment(guid, comment);
720
721 if (isRaid)
722 {
723 if (grp)
724 roles = PLAYER_ROLE_LEADER;
725 else
727 if (!roles)
728 return;
729 JoinRaidBrowser(player, roles, dungeons, comment);
731 SendRaidBrowserJoinedPacket(player, dungeons, comment);
732 return;
733 }
734
735 std::string debugNames = "";
736 if (grp) // Begin rolecheck
737 {
738 // Create new rolecheck
739 LfgRoleCheck& roleCheck = RoleChecksStore[gguid];
740 roleCheck.roles.clear(); // pussywizard: NEW rolecheck, not old one with trash data >_>
741 roleCheck.cancelTime = time_t(GameTime::GetGameTime().count()) + LFG_TIME_ROLECHECK;
742 roleCheck.state = LFG_ROLECHECK_INITIALITING;
743 roleCheck.leader = guid;
744 roleCheck.dungeons = dungeons;
745 roleCheck.rDungeonId = rDungeonId;
746
747 if (rDungeonId)
748 {
749 dungeons.clear();
750 dungeons.insert(rDungeonId);
751 }
752
754 // Send update to player
755 LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_JOIN_QUEUE, dungeons, comment);
756 for (GroupReference* itr = grp->GetFirstMember(); itr != nullptr; itr = itr->next())
757 {
758 if (Player* plrg = itr->GetSource())
759 {
760 ObjectGuid pguid = plrg->GetGUID();
761 plrg->GetSession()->SendLfgUpdateParty(updateData);
763 if (!isContinue)
764 SetSelectedDungeons(pguid, dungeons);
765 roleCheck.roles[pguid] = 0;
766 if (!debugNames.empty())
767 debugNames.append(", ");
768 debugNames.append(plrg->GetName());
769 }
770 }
771 // Update leader role
772 UpdateRoleCheck(gguid, guid, roles);
773 }
774 else // Add player to queue
775 {
776 LfgRolesMap rolesMap;
777 rolesMap[guid] = roles;
778 LFGQueue& queue = GetQueue(guid);
779 queue.AddQueueData(guid, GameTime::GetGameTime().count(), dungeons, rolesMap);
780
781 if (!isContinue)
782 {
783 if (rDungeonId)
784 {
785 dungeons.clear();
786 dungeons.insert(rDungeonId);
787 }
788 SetSelectedDungeons(guid, dungeons);
789 }
790 // Send update to player
791 player->GetSession()->SendLfgJoinResult(joinData);
792 player->GetSession()->SendLfgUpdatePlayer(LfgUpdateData(LFG_UPDATETYPE_JOIN_QUEUE, dungeons, comment));
794 SetRoles(guid, roles);
795 debugNames.append(player->GetName());
796 }
797
798 /*if (sLog->ShouldLog(LOG_FILTER_LFG, LOG_LEVEL_DEBUG))
799 {
800 std::ostringstream o;
801 o << "LFGMgr::Join: [" << guid << "] joined (" << (grp ? "group" : "player") << ") Members: " << debugNames.c_str()
802 << ". Dungeons (" << uint32(dungeons.size()) << "): " << ConcatenateDungeons(dungeons);
803 LOG_DEBUG("lfg", "{}", o.str());
804 }*/
805 }
#define MAXGROUPSIZE
Definition Group.h:43
#define LOG_ERROR(filterType__,...)
Definition Log.h:158
@ CONFIG_ALLOW_JOIN_BG_AND_LFG
Definition WorldConfig.h:129
Definition GroupReference.h:27
Definition Group.h:169
bool isLFGGroup(bool restricted=false) const
Definition Group.cpp:2264
ObjectGuid GetGUID() const
Definition Group.cpp:2305
bool isBGGroup() const
Definition Group.cpp:2275
uint32 GetMembersCount() const
Definition Group.h:245
bool isBFGroup() const
Definition Group.cpp:2280
GroupReference * GetFirstMember()
Definition Group.h:243
ObjectGuid GetLeaderGUID() const
Definition Group.cpp:2295
bool InBattleground() const
Definition Player.h:2271
bool InBattlegroundQueue(bool ignoreArena=false) const
Definition Player.cpp:12187
Group * GetGroup()
Definition Player.h:2487
std::string const & GetName() const
Definition Object.h:514
void SendLfgJoinResult(lfg::LfgJoinResultData const &joinData)
Definition LFGHandler.cpp:437
void SendLfgUpdatePlayer(lfg::LfgUpdateData const &updateData)
Definition LFGHandler.cpp:298
void SetSelectedDungeons(ObjectGuid guid, LfgDungeonSet const &dungeons)
Definition LFGMgr.cpp:2519
void SetComment(ObjectGuid guid, std::string const &comment)
Sets player lfr comment.
Definition LFGMgr.cpp:2500
void JoinRaidBrowser(Player *player, uint8 roles, LfgDungeonSet &dungeons, std::string comment)
pussywizard: Raid Browser
Definition LFGMgr.cpp:900
void SendRaidBrowserJoinedPacket(Player *p, LfgDungeonSet &dungeons, std::string comment)
Definition LFGMgr.cpp:922
void UpdateRoleCheck(ObjectGuid gguid, ObjectGuid guid=ObjectGuid::Empty, uint8 roles=PLAYER_ROLE_NONE)
Updates the role check with player answer.
Definition LFGMgr.cpp:1400
LfgRoleCheckContainer RoleChecksStore
Current Role checks.
Definition LFGMgr.h:628
void SetRoles(ObjectGuid guid, uint8 roles)
Sets player lfg roles.
Definition LFGMgr.cpp:2494
void GetCompatibleDungeons(LfgDungeonSet &dungeons, LfgGuidSet const &players, LfgLockPartyMap &lockMap)
Definition LFGMgr.cpp:1488
LfgType GetDungeonType(uint32 dungeon)
Definition LFGMgr.cpp:2348
std::map< ObjectGuid, uint8 > LfgRolesMap
Definition LFG.h:111
@ 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:48
@ LFG_SPELL_DUNGEON_DESERTER
Definition LFGMgr.h:53
@ LFG_TYPE_RAID
Definition LFGMgr.h:71
@ LFG_TYPE_DUNGEON
Definition LFGMgr.h:70
@ LFG_TYPE_HEROIC
Definition LFGMgr.h:73
@ LFG_ROLECHECK_INITIALITING
Definition LFGMgr.h:126
@ LFG_JOIN_TOO_MUCH_MEMBERS
Definition LFGMgr.h:117
@ LFG_JOIN_DISCONNECTED
Definition LFGMgr.h:110
@ LFG_JOIN_DUNGEON_INVALID
Definition LFGMgr.h:112
@ LFG_JOIN_USING_BG_SYSTEM
Definition LFGMgr.h:118
@ LFG_JOIN_INTERNAL_ERROR
Definition LFGMgr.h:105
@ LFG_JOIN_MIXED_RAID_DUNGEON
Definition LFGMgr.h:108
@ LFG_JOIN_PARTY_NOT_MEET_REQS
Definition LFGMgr.h:107
@ LFG_JOIN_DESERTER
Definition LFGMgr.h:113
@ LFG_JOIN_RANDOM_COOLDOWN
Definition LFGMgr.h:115
@ LFG_JOIN_PARTY_RANDOM_COOLDOWN
Definition LFGMgr.h:116
@ LFG_JOIN_OK
Definition LFGMgr.h:102
@ LFG_JOIN_PARTY_DESERTER
Definition LFGMgr.h:114
@ LFG_JOIN_NOT_MEET_REQS
Definition LFGMgr.h:106

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(), WorldObject::GetName(), GetQueue(), Player::GetSession(), GetState(), Unit::HasAura(), Player::InBattleground(), Player::InBattlegroundQueue(), Group::isBFGroup(), Group::isBGGroup(), ObjectGuid::IsGroup(), Group::isLFGGroup(), 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_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, 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

901 {
902 // pussywizard: client limit for comment length is 64 @ 3.3.5a
903 if (comment.size() > 64)
904 comment = comment.substr(0, 64);
905
906 RBEntryInfo entry(roles, comment);
907 for (LfgDungeonSet::const_iterator itr = dungeons.begin(); itr != dungeons.end(); ++itr)
908 if (GetLFGDungeon(*itr)) // ensure dungeon data exists for such dungeon id
909 {
910 RaidBrowserStore[player->GetTeamId()][*itr][player->GetGUID()] = entry;
911 RBUsedDungeonsStore[player->GetTeamId()].insert(*itr);
912 }
913 }
RBUsedDungeonsSet RBUsedDungeonsStore[2]
Definition LFGMgr.h:438
RBStoreMap RaidBrowserStore[2]
Definition LFGMgr.h:428

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

1346 {
1347 ObjectGuid pguid, gguid;
1348 if (guid.IsGroup())
1349 gguid = guid;
1350 else if (groupguid && groupguid.IsGroup())
1351 {
1352 pguid = guid;
1353 gguid = groupguid;
1354 }
1355 else
1356 {
1357 pguid = guid;
1358 gguid = GetGroup(guid);
1359 }
1360 if (!allowgroup)
1361 gguid.Clear();
1362
1363 if (pguid)
1364 for (lfg::LfgQueueContainer::iterator itr = QueuesStore.begin(); itr != QueuesStore.end(); ++itr)
1365 itr->second.RemoveFromQueue(pguid);
1366 if (gguid)
1367 for (lfg::LfgQueueContainer::iterator itr = QueuesStore.begin(); itr != QueuesStore.end(); ++itr)
1368 itr->second.RemoveFromQueue(gguid);
1369
1370 if (pguid && !gguid)
1371 {
1372 if (GetState(pguid) == LFG_STATE_QUEUED)
1373 {
1375 SetState(pguid, LFG_STATE_NONE);
1376 }
1377 }
1378 if (gguid)
1379 {
1380 if (GetState(gguid) == LFG_STATE_QUEUED)
1381 {
1382 SetState(gguid, LFG_STATE_NONE);
1383 const LfgGuidSet& players = GetPlayers(gguid);
1384 for (LfgGuidSet::const_iterator it = players.begin(); it != players.end(); ++it)
1385 {
1388 }
1389 }
1390 }
1391 }
void Clear()
Definition ObjectGuid.h:138
void SendLfgUpdateParty(ObjectGuid guid, LfgUpdateData const &data)
Definition LFGMgr.cpp:2648
void SendLfgUpdatePlayer(ObjectGuid guid, LfgUpdateData const &data)
Definition LFGMgr.cpp:2642
@ 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
820 {
821 LOG_DEBUG("lfg", "LFGMgr::Leave: [{}]", guid.ToString());
822 ObjectGuid gguid = guid.IsGroup() ? guid : GetGroup(guid);
823 LfgState state = GetState(guid);
824 switch (state)
825 {
826 case LFG_STATE_QUEUED:
827 if (gguid)
828 {
829 LFGQueue& queue = GetQueue(gguid);
830 queue.RemoveFromQueue(gguid);
831 uint32 dungeonId = GetDungeon(gguid);
832 SetState(gguid, LFG_STATE_NONE);
833 const LfgGuidSet& players = GetPlayers(gguid);
834 for (LfgGuidSet::const_iterator it = players.begin(); it != players.end(); ++it)
835 {
838 }
839 if (Group* group = sGroupMgr->GetGroupByGUID(gguid.GetCounter()))
840 {
841 if (group->isLFGGroup())
842 {
843 SetDungeon(gguid, dungeonId);
844 }
845 }
846 }
847 else
848 {
849 LFGQueue& queue = GetQueue(guid);
850 queue.RemoveFromQueue(guid);
853 }
854 break;
856 if (gguid)
857 UpdateRoleCheck(gguid); // No player to update role = LFG_ROLECHECK_ABORTED
858 break;
860 {
861 // Remove from Proposals
862 LfgProposalContainer::iterator it = ProposalsStore.begin();
863 ObjectGuid pguid = gguid == guid ? GetLeader(gguid) : guid;
864 while (it != ProposalsStore.end())
865 {
866 LfgProposalPlayerContainer::iterator itPlayer = it->second.players.find(pguid);
867 if (itPlayer != it->second.players.end())
868 {
869 // Mark the player/leader of group who left as didn't accept the proposal
870 itPlayer->second.accept = LFG_ANSWER_DENY;
871 break;
872 }
873 ++it;
874 }
875
876 // Remove from queue - if proposal is found, RemoveProposal will call RemoveFromQueue
877 if (it != ProposalsStore.end())
879 break;
880 }
881 case LFG_STATE_NONE:
882 break;
885 case LFG_STATE_BOOT:
886 if (guid != gguid) // Player
888 break;
890 LeaveRaidBrowser(guid);
891 SetCanOverrideRBState(guid, true);
893 SetCanOverrideRBState(guid, false);
896 break;
897 }
898 }
#define sGroupMgr
Definition GroupMgr.h:51
void LeaveRaidBrowser(ObjectGuid guid)
Definition LFGMgr.cpp:915
void RemoveProposal(LfgProposalContainer::iterator itProposal, LfgUpdateType type)
Definition LFGMgr.cpp:1909
void SetCanOverrideRBState(ObjectGuid guid, bool val)
Definition LFGMgr.cpp:2483
@ 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)
916 {
917 for (uint8 team = 0; team < 2; ++team)
918 for (RBStoreMap::iterator itr = RaidBrowserStore[team].begin(); itr != RaidBrowserStore[team].end(); ++itr)
919 itr->second.erase(guid);
920 }

References RaidBrowserStore.

Referenced by LeaveLfg().

◆ LfrSearchAdd()

void lfg::LFGMgr::LfrSearchAdd ( Player p,
uint32  dungeonId 
)
950 {
951 RBSearchersStore[p->GetTeamId()][p->GetGUID()] = dungeonId;
952 }
RBSearchersMap RBSearchersStore[2]
Definition LFGMgr.h:430

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

◆ LfrSearchRemove()

void lfg::LFGMgr::LfrSearchRemove ( Player p)
955 {
956 RBSearchersStore[p->GetTeamId()].erase(p->GetGUID());
957 }

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

◆ LfrSetComment()

void lfg::LFGMgr::LfrSetComment ( Player p,
std::string  comment 
)
2507 {
2508 // pussywizard: client limit for comment length is 64 @ 3.3.5a
2509 if (comment.size() > 64)
2510 comment = comment.substr(0, 64);
2511
2512 uint8 teamId = p->GetTeamId();
2513 RBEntryInfoMap::iterator iter;
2514 for (RBStoreMap::iterator itr = RaidBrowserStore[teamId].begin(); itr != RaidBrowserStore[teamId].end(); ++itr)
2515 if ((iter = itr->second.find(p->GetGUID())) != itr->second.end())
2516 iter->second.comment = comment;
2517 }

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

◆ LoadLFGDungeons()

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

Loads dungeons from dbc and adds teleport coords.

178 {
179 uint32 oldMSTime = getMSTime();
180
181 LfgDungeonStore.clear();
182
183 // Initialize Dungeon map with data from dbcs
184 for (uint32 i = 0; i < sLFGDungeonStore.GetNumRows(); ++i)
185 {
186 LFGDungeonEntry const* dungeon = sLFGDungeonStore.LookupEntry(i);
187 if (!dungeon)
188 continue;
189
190 switch (dungeon->TypeID)
191 {
192 case LFG_TYPE_DUNGEON:
193 case LFG_TYPE_HEROIC:
194 case LFG_TYPE_RAID:
195 case LFG_TYPE_RANDOM:
196 LfgDungeonStore[dungeon->ID] = LFGDungeonData(dungeon);
197 break;
198 }
199 }
200
201 // Fill teleport locations from DB
202 // 0 1 2 3 4
203 QueryResult result = WorldDatabase.Query("SELECT dungeonId, position_x, position_y, position_z, orientation FROM lfg_dungeon_template");
204
205 if (!result)
206 {
207 LOG_ERROR("lfg", ">> Loaded 0 LFG Entrance Positions. DB Table `lfg_dungeon_template` Is Empty!");
208 LOG_INFO("server.loading", " ");
209 return;
210 }
211
212 uint32 count = 0;
213
214 do
215 {
216 Field* fields = result->Fetch();
217 uint32 dungeonId = fields[0].Get<uint32>();
218 LFGDungeonContainer::iterator dungeonItr = LfgDungeonStore.find(dungeonId);
219 if (dungeonItr == LfgDungeonStore.end())
220 {
221 LOG_ERROR("lfg", "table `lfg_dungeon_template` contains coordinates for wrong dungeon {}", dungeonId);
222 continue;
223 }
224
225 LFGDungeonData& data = dungeonItr->second;
226 data.x = fields[1].Get<float>();
227 data.y = fields[2].Get<float>();
228 data.z = fields[3].Get<float>();
229 data.o = fields[4].Get<float>();
230
231 ++count;
232 } while (result->NextRow());
233
234 LOG_INFO("server.loading", ">> Loaded {} LFG Entrance Positions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
235 LOG_INFO("server.loading", " ");
236
237 // Fill all other teleport coords from areatriggers
238 for (LFGDungeonContainer::iterator itr = LfgDungeonStore.begin(); itr != LfgDungeonStore.end(); ++itr)
239 {
240 LFGDungeonData& dungeon = itr->second;
241
242 // No teleport coords in database, load from areatriggers
243 if (dungeon.type != LFG_TYPE_RANDOM && dungeon.x == 0.0f && dungeon.y == 0.0f && dungeon.z == 0.0f)
244 {
245 AreaTriggerTeleport const* at = sObjectMgr->GetMapEntranceTrigger(dungeon.map);
246 if (!at)
247 {
248 LOG_ERROR("lfg", "LFGMgr::LoadLFGDungeons: Failed to load dungeon {}, cant find areatrigger for map {}", dungeon.name, dungeon.map);
249 continue;
250 }
251
252 dungeon.map = at->target_mapId;
253 dungeon.x = at->target_X;
254 dungeon.y = at->target_Y;
255 dungeon.z = at->target_Z;
256 dungeon.o = at->target_Orientation;
257 }
258
259 if (dungeon.type != LFG_TYPE_RANDOM)
260 CachedDungeonMapStore[dungeon.group].insert(dungeon.id);
261 CachedDungeonMapStore[0].insert(dungeon.id);
262 }
263
264 if (reload)
265 {
266 CachedDungeonMapStore.clear();
267 // Recalculate locked dungeons
268 for (LfgPlayerDataContainer::const_iterator it = PlayersStore.begin(); it != PlayersStore.end(); ++it)
269 if (Player* player = ObjectAccessor::FindConnectedPlayer(it->first))
270 InitializeLockedDungeons(player, nullptr);
271 }
272 }
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:166
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:98
void InitializeLockedDungeons(Player *player, Group const *group=nullptr)
Initializes locked dungeons for given player (called at login or level change)
Definition LFGMgr.cpp:389
Definition ObjectMgr.h:411
float target_Z
Definition ObjectMgr.h:415
float target_X
Definition ObjectMgr.h:413
float target_Orientation
Definition ObjectMgr.h:416
float target_Y
Definition ObjectMgr.h:414
uint32 target_mapId
Definition ObjectMgr.h:412
Definition DBCStructure.h:1246
uint32 TypeID
Definition DBCStructure.h:1258
uint32 ID
Definition DBCStructure.h:1247

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.

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

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
1584 {
1585 LfgGuidList players;
1586 GuidUnorderedSet playersToTeleport;
1587
1588 for (LfgProposalPlayerContainer::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it)
1589 {
1590 ObjectGuid guid = it->first;
1591 if (guid == proposal.leader)
1592 players.push_front(guid);
1593 else
1594 players.push_back(guid);
1595
1596 if (proposal.isNew || GetGroup(guid) != proposal.group)
1597 playersToTeleport.insert(guid);
1598 }
1599
1600 // Set the dungeon difficulty
1601 LFGDungeonData const* dungeon = GetLFGDungeon(proposal.dungeonId);
1602 ASSERT(dungeon);
1603
1604 bool isPremadeGroup = false;
1605 Group* grp = proposal.group ? sGroupMgr->GetGroupByGUID(proposal.group.GetCounter()) : nullptr;
1606 if (!grp)
1607 {
1608 ObjectGuid groupGUID;
1609 for (ObjectGuid const& guid : players)
1610 {
1611 if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
1612 {
1613 Group* group = player->GetGroup();
1614 if (!group || (groupGUID && groupGUID != group->GetGUID()))
1615 {
1616 isPremadeGroup = false;
1617 break;
1618 }
1619
1620 groupGUID = group->GetGUID();
1621 isPremadeGroup = true;
1622 }
1623 }
1624 }
1625
1626 ObjectGuid oldGroupGUID;
1627 for (LfgGuidList::const_iterator it = players.begin(); it != players.end(); ++it)
1628 {
1629 ObjectGuid pguid = (*it);
1631 if (!player)
1632 continue;
1633
1634 Group* group = player->GetGroup();
1635 if (isPremadeGroup && !grp)
1636 {
1637 oldGroupGUID = group->GetGUID();
1638 grp = group;
1639 grp->ConvertToLFG(false);
1641 }
1642
1643 // Xinef: Apply Random Buff
1644 if (grp && !grp->IsLfgWithBuff())
1645 {
1646 if (!group || group->GetGUID() != oldGroupGUID)
1647 grp->AddLfgBuffFlag();
1648 else
1649 oldGroupGUID = group->GetGUID();
1650 }
1651
1652 // Xinef: Store amount of random players player grouped with
1653 if (group)
1654 {
1655 SetRandomPlayersCount(pguid, group->GetMembersCount() >= MAXGROUPSIZE ? 0 : MAXGROUPSIZE - group->GetMembersCount());
1656 oldGroupGUID = group->GetGUID();
1657 if (group != grp)
1658 group->RemoveMember(player->GetGUID());
1659 }
1660 else
1662
1663 if (!grp)
1664 {
1665 grp = new Group();
1666 grp->ConvertToLFG();
1667 grp->Create(player);
1668 ObjectGuid gguid = grp->GetGUID();
1670 sGroupMgr->AddGroup(grp);
1671 }
1672 else if (group != grp)
1673 {
1674 if (!grp->IsFull())
1675 grp->AddMember(player);
1676 }
1677
1678 grp->SetLfgRoles(pguid, proposal.players.find(pguid)->second.role);
1679 }
1680
1681 // pussywizard: crashfix, group wasn't created when iterating players (no player found by guid), proposal is deleted by the calling function
1682 if (!grp)
1683 return;
1684
1685 grp->SetDungeonDifficulty(Difficulty(dungeon->difficulty));
1686 ObjectGuid gguid = grp->GetGUID();
1687 SetDungeon(gguid, dungeon->Entry());
1689
1690 _SaveToDB(gguid);
1691
1692 // Select a player inside to be teleported to
1693 WorldLocation const* teleportLocation = nullptr;
1694 bool leaderTeleportIncluded = false;
1695 for (GroupReference* itr = grp->GetFirstMember(); itr != nullptr; itr = itr->next())
1696 {
1697 if (Player* plr = itr->GetSource())
1698 {
1699 if (grp->IsLeader(plr->GetGUID()) && playersToTeleport.find(plr->GetGUID()) != playersToTeleport.end())
1700 {
1701 leaderTeleportIncluded = true;
1702 }
1703
1704 if (plr->GetMapId() == uint32(dungeon->map) && !proposal.isNew)
1705 {
1706 teleportLocation = plr;
1707 break;
1708 }
1709
1710 // Remove from battleground queues
1711 for (uint8 i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
1712 {
1713 if (BattlegroundQueueTypeId bgQueueTypeId = plr->GetBattlegroundQueueTypeId(i))
1714 {
1715 if (bgQueueTypeId != BATTLEGROUND_QUEUE_NONE)
1716 {
1717 plr->RemoveBattlegroundQueueId(bgQueueTypeId);
1718 sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId).RemovePlayer(plr->GetGUID(), true);
1719 }
1720 }
1721 }
1722 }
1723 }
1724
1725 bool randomDungeon = false;
1726 std::vector<Player*> playersTeleported;
1727 // Teleport Player
1728 for (GuidUnorderedSet::const_iterator it = playersToTeleport.begin(); it != playersToTeleport.end(); ++it)
1729 {
1730 if (Player* player = ObjectAccessor::FindPlayer(*it))
1731 {
1732 if (player->GetGroup() != grp) // pussywizard: could not add because group was full
1733 continue;
1734
1735 // Add the cooldown spell if queued for a random dungeon
1736 // xinef: add aura
1737 if ((randomDungeon || selectedRandomLfgDungeon(player->GetGUID())) && !player->HasAura(LFG_SPELL_DUNGEON_COOLDOWN))
1738 {
1739 randomDungeon = true;
1740 // if player is debugging, don't add dungeon cooldown
1741 if (!m_Testing)
1742 {
1743 player->AddAura(LFG_SPELL_DUNGEON_COOLDOWN, player);
1744 }
1745 }
1746
1747 if (player->GetMapId() == uint32(dungeon->map))
1748 {
1749 // check instance id with leader
1750 if (!leaderTeleportIncluded)
1751 {
1752 if (InstancePlayerBind* ilb = sInstanceSaveMgr->PlayerGetBoundInstance(grp->GetLeaderGUID(), dungeon->map, player->GetDungeonDifficulty()))
1753 {
1754 if (player->GetInstanceId() == ilb->save->GetInstanceId())
1755 {
1756 // Do not teleport if in the same map and instance as leader
1757 continue;
1758 }
1759 }
1760 }
1761
1762 // Remove bind to that map
1763 sInstanceSaveMgr->PlayerUnbindInstance(player->GetGUID(), dungeon->map, player->GetDungeonDifficulty(), true);
1764 }
1765 else
1766 {
1767 // RDF removes all binds to that map
1768 if (randomDungeon && !sInstanceSaveMgr->PlayerIsPermBoundToInstance(player->GetGUID(), dungeon->map, player->GetDungeonDifficulty()))
1769 {
1770 sInstanceSaveMgr->PlayerUnbindInstance(player->GetGUID(), dungeon->map, player->GetDungeonDifficulty(), true);
1771 }
1772 }
1773
1774 playersTeleported.push_back(player);
1775 }
1776 }
1777
1778 for (Player* player : playersTeleported)
1779 {
1780 TeleportPlayer(player, false, teleportLocation);
1781 }
1782
1783 if (randomDungeon)
1785 if (Difficulty(dungeon->difficulty) == DUNGEON_DIFFICULTY_HEROIC)
1786 grp->AddLfgHeroicFlag();
1787
1788 // Update group info
1789 grp->SendUpdate();
1790 }
#define sBattlegroundMgr
Definition BattlegroundMgr.h:187
#define ASSERT
Definition Errors.h:68
std::unordered_set< ObjectGuid > GuidUnorderedSet
Definition ObjectGuid.h:257
BattlegroundQueueTypeId
Definition SharedDefines.h:3874
@ BATTLEGROUND_QUEUE_NONE
Definition SharedDefines.h:3875
#define PLAYER_MAX_BATTLEGROUND_QUEUES
Definition SharedDefines.h:176
void AddLfgRandomInstanceFlag()
Definition Group.h:311
void SetDungeonDifficulty(Difficulty difficulty)
Definition Group.cpp:2072
void SetLfgRoles(ObjectGuid guid, const uint8 roles)
Definition Group.cpp:2249
bool AddMember(Player *player)
Definition Group.cpp:389
bool IsLeader(ObjectGuid guid) const
Definition Group.cpp:2340
void SendUpdate()
Definition Group.cpp:1664
bool IsLfgWithBuff() const
Definition Group.h:313
bool RemoveMember(ObjectGuid guid, const RemoveMethod &method=GROUP_REMOVEMETHOD_DEFAULT, ObjectGuid kicker=ObjectGuid::Empty, const char *reason=nullptr)
Definition Group.cpp:545
void AddLfgBuffFlag()
Definition Group.h:310
void ConvertToLFG(bool restricted=true)
Definition Group.cpp:259
void AddLfgHeroicFlag()
Definition Group.h:312
bool Create(Player *leader)
Definition Group.cpp:107
bool IsFull() const
Definition Group.cpp:2259
Difficulty GetDungeonDifficulty() const
Definition Player.h:1934
Aura * AddAura(uint32 spellId, Unit *target)
Definition Unit.cpp:18951
Definition Position.h:255
uint32 GetInstanceId() const
Definition Object.h:499
void TeleportPlayer(Player *player, bool out, WorldLocation const *teleportLocation=nullptr)
Teleport a player to/from selected dungeon.
Definition LFGMgr.cpp:2115
bool selectedRandomLfgDungeon(ObjectGuid guid)
Check if given guid applied for random dungeon.
Definition LFGMgr.cpp:2774
void SetRandomPlayersCount(ObjectGuid guid, uint8 count)
Xinef: Set Random Players Count.
Definition LFGMgr.cpp:2613
GuidList LfgGuidList
Definition LFG.h:110
Definition InstanceSaveMgr.h:39

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, 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::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 ( const RBInternalInfo info,
ByteBuffer buffer 
)
1235 {
1236 buffer << info.groupGuid;
1238 buffer << (uint32)flags;
1239 if (flags & LFG_UPDATE_FLAG_COMMENT)
1240 buffer << info.comment;
1241 if (flags & LFG_UPDATE_FLAG_ROLES)
1242 for (uint8 j = 0; j < 3; ++j)
1243 buffer << (uint8)0;
1244 if (!(flags & LFG_UPDATE_FLAG_BINDED))
1245 return;
1246 buffer << info.instanceGuid;
1247 buffer << (uint32)info.encounterMask;
1248 }
@ LFG_UPDATE_FLAG_BINDED
Definition LFGMgr.h:143
@ LFG_UPDATE_FLAG_COMMENT
Definition LFGMgr.h:137
@ LFG_UPDATE_FLAG_ROLES
Definition LFGMgr.h:140

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 ( const RBInternalInfo info,
ByteBuffer buffer 
)
1251 {
1252 buffer << info.guid;
1253 uint32 flags = LFG_UPDATE_FLAG_CHARACTERINFO | LFG_UPDATE_FLAG_ROLES | LFG_UPDATE_FLAG_COMMENT | (info.groupGuid ? LFG_UPDATE_FLAG_GROUPGUID : LFG_UPDATE_FLAG_BINDED) | (info.isGroupLeader ? LFG_UPDATE_FLAG_GROUPLEADER : 0) | (!info.groupGuid || info.isGroupLeader ? LFG_UPDATE_FLAG_AREA : 0);
1254 buffer << (uint32)flags;
1255
1257 {
1258 buffer << (uint8)info._level;
1259 buffer << (uint8)info._class;
1260 buffer << (uint8)info._race;
1261 buffer << (uint8)info._talents0;
1262 buffer << (uint8)info._talents1;
1263 buffer << (uint8)info._talents2;
1264 buffer << (uint32)info._armor;
1265 buffer << (uint32)info._spellDamage;
1266 buffer << (uint32)info._spellHeal;
1267 buffer << (uint32)info._critRatingMelee;
1268 buffer << (uint32)info._critRatingRanged;
1269 buffer << (uint32)info._critRatingSpell;
1270 buffer << (float)info._mp5;
1271 buffer << (float)info._mp5combat;
1272 buffer << (uint32)info._attackPower;
1273 buffer << (uint32)info._agility;
1274 buffer << (uint32)info._health;
1275 buffer << (uint32)info._mana;
1276 buffer << (uint32)info._online; // talentpoints, used as online/offline marker :D
1277 buffer << (float)info._avgItemLevel; // avgitemlevel
1278 buffer << (uint32)info._defenseSkill;
1279 buffer << (uint32)info._dodgeRating;
1280 buffer << (uint32)info._blockRating;
1281 buffer << (uint32)info._parryRating;
1282 buffer << (uint32)info._hasteRating;
1283 buffer << (uint32)info._expertiseRating;
1284 }
1285
1286 if (flags & LFG_UPDATE_FLAG_COMMENT)
1287 buffer << (info.groupGuid ? std::string("") : info.comment);
1288 if (flags & LFG_UPDATE_FLAG_GROUPLEADER)
1289 buffer << (uint8)1; // isLFM
1290 if (flags & LFG_UPDATE_FLAG_GROUPGUID)
1291 buffer << info.groupGuid;
1292 if (flags & LFG_UPDATE_FLAG_ROLES)
1293 buffer << (uint8)(info.groupGuid ? (info.isGroupLeader ? PLAYER_ROLE_LEADER : 0) : info.roles);
1294 if (flags & LFG_UPDATE_FLAG_AREA)
1295 buffer << (uint32)info._area;
1296 if (flags & LFG_UPDATE_FLAG_STATUS)
1297 buffer << (uint8)0;
1298 if (!(flags & LFG_UPDATE_FLAG_BINDED))
1299 return;
1300 buffer << info.instanceGuid;
1301 buffer << (uint32)info.encounterMask;
1302 }
@ LFG_UPDATE_FLAG_AREA
Definition LFGMgr.h:141
@ LFG_UPDATE_FLAG_GROUPLEADER
Definition LFGMgr.h:138
@ LFG_UPDATE_FLAG_STATUS
Definition LFGMgr.h:142
@ LFG_UPDATE_FLAG_CHARACTERINFO
Definition LFGMgr.h:136
@ LFG_UPDATE_FLAG_GROUPGUID
Definition LFGMgr.h:139

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::_defenseSkill, 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::_online, 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 buffer_deleted,
uint32  groupCounter,
ByteBuffer buffer_groups,
uint32  playerCounter,
ByteBuffer buffer_players 
)
1305 {
1306 differencePacket << (uint32)LFG_TYPE_RAID;
1307 differencePacket << (uint32)dungeonId;
1308 differencePacket << (uint8)1;
1309 differencePacket << (uint32)deletedCounter;
1310 differencePacket.append(buffer_deleted);
1311 differencePacket << (uint32)groupCounter;
1312 differencePacket << (uint32)0;
1313 differencePacket.append(buffer_groups);
1314 differencePacket << (uint32)playerCounter;
1315 differencePacket << (uint32)0;
1316 differencePacket.append(buffer_players);
1317 }
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 infoMap 
)
1320 {
1321 fullPacket << (uint32)LFG_TYPE_RAID;
1322 fullPacket << (uint32)dungeonId;
1323 fullPacket << (uint8)0;
1324 uint32 groupCounter = 0, playerCounter = 0;
1325 ByteBuffer buffer_groups, buffer_players;
1326 for (RBInternalInfoMap::const_iterator itr = infoMap.begin(); itr != infoMap.end(); ++itr)
1327 {
1328 if (itr->second.isGroupLeader)
1329 {
1330 ++groupCounter;
1331 RBPacketAppendGroup(itr->second, buffer_groups);
1332 }
1333 ++playerCounter;
1334 RBPacketAppendPlayer(itr->second, buffer_players);
1335 }
1336 fullPacket << (uint32)groupCounter;
1337 fullPacket << (uint32)0;
1338 fullPacket.append(buffer_groups);
1339 fullPacket << (uint32)playerCounter;
1340 fullPacket << (uint32)0;
1341 fullPacket.append(buffer_players);
1342 }
Definition ByteBuffer.h:70
void RBPacketAppendGroup(const RBInternalInfo &info, ByteBuffer &buffer)
Definition LFGMgr.cpp:1234
void RBPacketAppendPlayer(const RBInternalInfo &info, ByteBuffer &buffer)
Definition LFGMgr.cpp:1250

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

Referenced by UpdateRaidBrowser().

◆ RemoveGroupData()

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

Removes saved group data.

2538 {
2539 LOG_DEBUG("lfg", "LFGMgr::RemoveGroupData: [{}]", guid.ToString());
2540 LfgGroupDataContainer::iterator it = GroupsStore.find(guid);
2541 if (it == GroupsStore.end())
2542 return;
2543
2544 LfgState state = GetState(guid);
2545 // If group is being formed after proposal success do nothing more
2546 LfgGuidSet const& players = it->second.GetPlayers();
2547 for (auto iterator = players.begin(); iterator != players.end(); ++iterator)
2548 {
2549 ObjectGuid objectGuid = (*iterator);
2550 SetGroup(*iterator, ObjectGuid::Empty);
2551 if (state != LFG_STATE_PROPOSAL)
2552 {
2553 SetState(*iterator, LFG_STATE_NONE);
2554 SendLfgUpdateParty(objectGuid, LfgUpdateData(LFG_UPDATETYPE_REMOVED_FROM_QUEUE));
2555 }
2556 }
2557 GroupsStore.erase(it);
2558 }
void SetGroup(ObjectGuid guid, ObjectGuid group)
Sets player group.
Definition LFGMgr.cpp:2593

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.

2566 {
2567 return GroupsStore[gguid].RemovePlayer(guid);
2568 }

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)
1910 {
1911 LfgProposal& proposal = itProposal->second;
1912 proposal.state = LFG_PROPOSAL_FAILED;
1913
1914 LOG_DEBUG("lfg", "LFGMgr::RemoveProposal: Proposal {}, state FAILED, UpdateType {}", itProposal->first, type);
1915 // Mark all people that didn't answered as no accept
1917 for (LfgProposalPlayerContainer::iterator it = proposal.players.begin(); it != proposal.players.end(); ++it)
1918 if (it->second.accept == LFG_ANSWER_PENDING)
1919 it->second.accept = LFG_ANSWER_DENY;
1920
1921 // pussywizard: add cooldown for not accepting (after 40 secs) or declining
1922 for (LfgProposalPlayerContainer::iterator it = proposal.players.begin(); it != proposal.players.end(); ++it)
1923 if (it->second.accept == LFG_ANSWER_DENY)
1924 if (Player* plr = ObjectAccessor::FindPlayer(it->first))
1925 if (Aura* aura = plr->AddAura(LFG_SPELL_DUNGEON_COOLDOWN, plr))
1926 aura->SetDuration(150 * IN_MILLISECONDS);
1927
1928 // Mark players/groups to be removed
1929 LfgGuidSet toRemove;
1930 for (LfgProposalPlayerContainer::iterator it = proposal.players.begin(); it != proposal.players.end(); ++it)
1931 {
1932 if (it->second.accept == LFG_ANSWER_AGREE)
1933 continue;
1934
1935 ObjectGuid guid = it->second.group ? it->second.group : it->first;
1936 // Player didn't accept or still pending when no secs left
1937 if (it->second.accept == LFG_ANSWER_DENY || type == LFG_UPDATETYPE_PROPOSAL_FAILED)
1938 {
1939 it->second.accept = LFG_ANSWER_DENY;
1940 toRemove.insert(guid);
1941 }
1942 }
1943
1944 // Notify players
1945 for (LfgProposalPlayerContainer::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it)
1946 {
1947 ObjectGuid guid = it->first;
1948 ObjectGuid gguid = it->second.group ? it->second.group : guid;
1949
1950 SendLfgUpdateProposal(guid, proposal);
1951
1952 if (toRemove.find(gguid) != toRemove.end()) // Didn't accept or in same group that someone that didn't accept
1953 {
1954 LfgUpdateData updateData;
1955 if (it->second.accept == LFG_ANSWER_DENY)
1956 {
1957 updateData.updateType = type;
1958 LOG_DEBUG("lfg", "LFGMgr::RemoveProposal: [{}] didn't accept. Removing from queue and compatible cache", guid.ToString());
1959 }
1960 else
1961 {
1962 updateData.updateType = LFG_UPDATETYPE_REMOVED_FROM_QUEUE;
1963 LOG_DEBUG("lfg", "LFGMgr::RemoveProposal: [{}] in same group that someone that didn't accept. Removing from queue and compatible cache", guid.ToString());
1964 }
1965
1966 RestoreState(guid, "Proposal Fail (didn't accepted or in group with someone that didn't accept");
1967 if (gguid != guid)
1968 {
1969 RestoreState(it->second.group, "Proposal Fail (someone in group didn't accepted)");
1970 SendLfgUpdateParty(guid, updateData);
1971 }
1972 else
1973 SendLfgUpdatePlayer(guid, updateData);
1974 }
1975 else
1976 {
1977 LOG_DEBUG("lfg", "LFGMgr::RemoveProposal: Readding [{}] to queue.", guid.ToString());
1979 if (gguid != guid)
1980 {
1981 SetState(gguid, LFG_STATE_QUEUED);
1983 }
1984 else
1986 }
1987 }
1988
1989 LFGQueue& queue = GetQueue(proposal.players.begin()->first);
1990 // Remove players/groups from queue
1991 for (LfgGuidSet::const_iterator it = toRemove.begin(); it != toRemove.end(); ++it)
1992 {
1993 ObjectGuid guid = *it;
1994 queue.RemoveFromQueue(guid);
1995 proposal.queues.remove(guid);
1996 }
1997
1998 // Readd to queue
1999 for (uint8 i = 0; i < 5 && proposal.queues.guids[i]; ++i)
2000 {
2001 // xinef: this will work as data is not deleted, only references to this data are cleared
2002 // xinef: when new proposal is created
2003 // xinef: successful proposal is also taken into account is similar manner
2004 queue.AddToQueue(proposal.queues.guids[i], true);
2005 }
2006
2007 ProposalsStore.erase(itProposal);
2008 }
constexpr auto IN_MILLISECONDS
Definition Common.h:53
Definition SpellAuras.h:87
void RestoreState(ObjectGuid guid, char const *debugMsg)
Definition LFGMgr.cpp:2432
std::string const & GetComment(ObjectGuid gguid)
Get current player comment (used for LFR)
Definition LFGMgr.cpp:2407
void SendLfgUpdateProposal(ObjectGuid guid, LfgProposal const &proposal)
Definition LFGMgr.cpp:2666
@ LFG_UPDATETYPE_ADDED_TO_QUEUE
Definition LFG.h:59
@ LFG_UPDATETYPE_PROPOSAL_FAILED
Definition LFG.h:56
@ LFG_PROPOSAL_FAILED
Definition LFGMgr.h:81

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
2433 {
2434 if (guid.IsGroup())
2435 {
2436 LfgGroupData& data = GroupsStore[guid];
2437 /*if (sLog->ShouldLog(LOG_FILTER_LFG, LOG_LEVEL_DEBUG))
2438 {
2439 std::string const& ps = GetStateString(data.GetState());
2440 std::string const& os = GetStateString(data.GetOldState());
2441 LOG_TRACE("lfg", "LFGMgr::RestoreState: Group: [{}] ({}) State: {}, oldState: {}",
2442 guid.ToString(), debugMsg, ps, os);
2443 }*/
2444
2445 data.RestoreState();
2446 }
2447 else
2448 {
2449 LfgPlayerData& data = PlayersStore[guid];
2450 /*if (sLog->ShouldLog(LOG_FILTER_LFG, LOG_LEVEL_DEBUG))
2451 {
2452 std::string const& ps = GetStateString(data.GetState());
2453 std::string const& os = GetStateString(data.GetOldState());
2454 LOG_TRACE("lfg", "LFGMgr::RestoreState: Player: [{}] ({}) State: {}, oldState: {}",
2455 guid.ToString(), debugMsg, ps, os);
2456 }*/
2457 data.RestoreState();
2458 }
2459 }

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.

2775 {
2776 if (GetState(guid) != LFG_STATE_NONE)
2777 {
2778 LfgDungeonSet const& dungeons = GetSelectedDungeons(guid);
2779 if (!dungeons.empty())
2780 {
2781 LFGDungeonData const* dungeon = GetLFGDungeon(*dungeons.begin());
2782 if (dungeon && (dungeon->type == LFG_TYPE_RANDOM || dungeon->seasonal))
2783 return true;
2784 }
2785 }
2786
2787 return false;
2788 }

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
2661 {
2662 if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
2663 player->GetSession()->SendLfgBootProposalUpdate(boot);
2664 }

References ObjectAccessor::FindConnectedPlayer().

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

◆ SendLfgJoinResult()

void lfg::LFGMgr::SendLfgJoinResult ( ObjectGuid  guid,
LfgJoinResultData const &  data 
)
private
2655 {
2656 if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
2657 player->GetSession()->SendLfgJoinResult(data);
2658 }

References ObjectAccessor::FindConnectedPlayer().

Referenced by Update(), and UpdateRoleCheck().

◆ SendLfgQueueStatus()

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

Sends queue status to player.

2673 {
2674 if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
2675 player->GetSession()->SendLfgQueueStatus(data);
2676 }

References ObjectAccessor::FindConnectedPlayer().

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

◆ SendLfgRoleCheckUpdate()

void lfg::LFGMgr::SendLfgRoleCheckUpdate ( ObjectGuid  guid,
LfgRoleCheck const &  roleCheck 
)
private
2637 {
2638 if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
2639 player->GetSession()->SendLfgRoleCheckUpdate(roleCheck);
2640 }

References ObjectAccessor::FindConnectedPlayer().

Referenced by Update(), and UpdateRoleCheck().

◆ SendLfgRoleChosen()

void lfg::LFGMgr::SendLfgRoleChosen ( ObjectGuid  guid,
ObjectGuid  pguid,
uint8  roles 
)
private
2631 {
2632 if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
2633 player->GetSession()->SendLfgRoleChosen(pguid, roles);
2634 }

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

Referenced by UpdateRoleCheck().

◆ SendLfgUpdateParty()

void lfg::LFGMgr::SendLfgUpdateParty ( ObjectGuid  guid,
LfgUpdateData const &  data 
)
private
2649 {
2650 if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
2651 player->GetSession()->SendLfgUpdateParty(data);
2652 }

References ObjectAccessor::FindConnectedPlayer().

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

◆ SendLfgUpdatePlayer()

void lfg::LFGMgr::SendLfgUpdatePlayer ( ObjectGuid  guid,
LfgUpdateData const &  data 
)
private
2643 {
2644 if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
2645 player->GetSession()->SendLfgUpdatePlayer(data);
2646 }

References ObjectAccessor::FindConnectedPlayer().

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

◆ SendLfgUpdateProposal()

void lfg::LFGMgr::SendLfgUpdateProposal ( ObjectGuid  guid,
LfgProposal const &  proposal 
)
private
2667 {
2668 if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
2669 player->GetSession()->SendLfgUpdateProposal(proposal);
2670 }

References ObjectAccessor::FindConnectedPlayer().

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

◆ SendRaidBrowserCachedList()

void lfg::LFGMgr::SendRaidBrowserCachedList ( Player player,
uint32  dungeonId 
)
960 {
961 RBCacheMap::iterator itr = RBCacheStore[player->GetTeamId()].find(dungeonId);
962 if (itr != RBCacheStore[player->GetTeamId()].end())
963 {
964 player->GetSession()->SendPacket(&(itr->second));
965 return;
966 }
967 // send empty packet if cache not found
969 data << (uint32)LFG_TYPE_RAID;
970 data << (uint32)dungeonId;
971 data << (uint8)0;
972 data << (uint32)0;
973 data << (uint32)0;
974 data << (uint32)0;
975 data << (uint32)0;
976 player->GetSession()->SendPacket(&data);
977 }
Definition WorldPacket.h:26
void SendPacket(WorldPacket const *packet)
Send a packet to the client.
Definition WorldSession.cpp:251
RBCacheMap RBCacheStore[2]
Definition LFGMgr.h:432
@ SMSG_UPDATE_LFG_LIST
Definition Opcodes.h:894

References Player::GetSession(), Player::GetTeamId(), lfg::LFG_TYPE_RAID, RBCacheStore, WorldSession::SendPacket(), and SMSG_UPDATE_LFG_LIST.

◆ SendRaidBrowserJoinedPacket()

void lfg::LFGMgr::SendRaidBrowserJoinedPacket ( Player p,
LfgDungeonSet dungeons,
std::string  comment 
)
923 {
924 if (dungeons.empty())
925 {
926 RBEntryInfoMap::iterator iter;
927 uint8 team = p->GetTeamId();
928 bool setComment = true;
929 for (RBStoreMap::iterator itr = RaidBrowserStore[team].begin(); itr != RaidBrowserStore[team].end(); ++itr)
930 if ((iter = itr->second.find(p->GetGUID())) != itr->second.end())
931 {
932 dungeons.insert(itr->first);
933 if (setComment)
934 {
935 comment = iter->second.comment;
936 setComment = false;
937 }
938 }
939 }
940 LfgJoinResultData joinData;
941 p->GetSession()->SendLfgJoinResult(joinData);
942 LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_JOIN_RAIDBROWSER, dungeons, comment);
943 if (p->GetGroup())
944 p->GetSession()->SendLfgUpdateParty(updateData);
945 else
946 p->GetSession()->SendLfgUpdatePlayer(updateData);
947 }
void SendLfgUpdateParty(lfg::LfgUpdateData const &updateData)
Definition LFGHandler.cpp:335
@ 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
2484 {
2485 PlayersStore[guid].SetCanOverrideRBState(val);
2486 }

References PlayersStore.

Referenced by LeaveLfg().

◆ SetComment()

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

Sets player lfr comment.

2501 {
2502 LOG_DEBUG("lfg", "LFGMgr::SetComment: [{}] comment: {}", guid.ToString(), comment);
2503 PlayersStore[guid].SetComment(comment);
2504 }

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

Referenced by JoinLfg().

◆ SetDungeon()

void lfg::LFGMgr::SetDungeon ( ObjectGuid  guid,
uint32  dungeon 
)
2489 {
2490 LOG_DEBUG("lfg", "LFGMgr::SetDungeon: [{}] dungeon {}", guid.ToString(), dungeon);
2491 GroupsStore[guid].SetDungeon(dungeon);
2492 }

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.

2594 {
2595 PlayersStore[guid].SetGroup(group);
2596 }

References PlayersStore.

Referenced by RemoveGroupData(), and SetupGroupMember().

◆ SetLeader()

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

Sets the leader of the group.

2576 {
2577 GroupsStore[gguid].SetLeader(leader);
2578 }

References GroupsStore.

Referenced by _LoadFromDB().

◆ SetLockedDungeons()

void lfg::LFGMgr::SetLockedDungeons ( ObjectGuid  guid,
LfgLockMap const &  lock 
)
private
2526 {
2527 LOG_DEBUG("lfg", "LFGMgr::SetLockedDungeons: [{}]", guid.ToString());
2528 PlayersStore[guid].SetLockedDungeons(lock);
2529 }

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

Referenced by InitializeLockedDungeons().

◆ SetOptions()

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

Sets new lfg options.

2738 {
2739 m_options = options;
2740 }

References m_options.

◆ SetRandomPlayersCount()

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

Xinef: Set Random Players Count.

2614 {
2615 PlayersStore[guid].SetRandomPlayersCount(count);
2616 }

References PlayersStore.

Referenced by MakeNewGroup().

◆ SetRoles()

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

Sets player lfg roles.

2495 {
2496 LOG_DEBUG("lfg", "LFGMgr::SetRoles: [{}] roles: {}", guid.ToString(), roles);
2497 PlayersStore[guid].SetRoles(roles);
2498 }

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

Referenced by JoinLfg(), and UpdateRoleCheck().

◆ SetSelectedDungeons()

void lfg::LFGMgr::SetSelectedDungeons ( ObjectGuid  guid,
LfgDungeonSet const &  dungeons 
)
private
2520 {
2521 LOG_DEBUG("lfg", "LFGMgr::SetLockedDungeons: [{}]", guid.ToString());
2522 PlayersStore[guid].SetSelectedDungeons(dungeons);
2523 }

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

Referenced by JoinLfg(), and SetupGroupMember().

◆ SetState()

void lfg::LFGMgr::SetState ( ObjectGuid  guid,
LfgState  state 
)
private
2462 {
2463 if (guid.IsGroup())
2464 {
2465 LfgGroupData& data = GroupsStore[guid];
2466 std::string ns = GetStateString(state);
2467 std::string ps = GetStateString(data.GetState());
2468 std::string os = GetStateString(data.GetOldState());
2469 LOG_DEBUG("lfg", "LFGMgr::SetState: Group: [{}] newState: {}, previous: {}, oldState: {}", guid.ToString(), ns, ps, os);
2470 data.SetState(state);
2471 }
2472 else
2473 {
2474 LfgPlayerData& data = PlayersStore[guid];
2475 std::string ns = GetStateString(state);
2476 std::string ps = GetStateString(data.GetState());
2477 std::string os = GetStateString(data.GetOldState());
2478 LOG_DEBUG("lfg", "LFGMgr::SetState: Player: [{}] newState: {}, previous: {}, oldState: {}", guid.ToString(), ns, ps, os);
2479 data.SetState(state);
2480 }
2481 }
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.

2581 {
2583 teamId = TEAM_ALLIANCE; // @Not Sure About That TeamId is supposed to be uint8 Team = 0(@TrinityCore)
2584
2585 PlayersStore[guid].SetTeam(teamId);
2586 }
@ TEAM_ALLIANCE
Definition SharedDefines.h:760
@ CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP
Definition WorldConfig.h:34

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.

2765 {
2766 LfgDungeonSet dungeons;
2767 dungeons.insert(GetDungeon(gguid));
2768 SetSelectedDungeons(guid, dungeons);
2769 SetState(guid, GetState(gguid));
2770 SetGroup(guid, gguid);
2771 AddPlayerToGroup(gguid, guid);
2772 }
void AddPlayerToGroup(ObjectGuid gguid, ObjectGuid guid)
Adds player to group.
Definition LFGMgr.cpp:2570

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)
2116 {
2117 LFGDungeonData const* dungeon = nullptr;
2118 Group* group = player->GetGroup();
2119
2120 if (group && group->isLFGGroup())
2121 dungeon = GetLFGDungeon(GetDungeon(group->GetGUID()));
2122
2123 if (!dungeon)
2124 {
2126 return;
2127 }
2128
2130
2131 if (!player->IsAlive())
2132 {
2134 }
2135 else if (player->IsFalling() || player->HasUnitState(UNIT_STATE_JUMPING))
2136 {
2138 }
2139 else if (player->IsMirrorTimerActive(FATIGUE_TIMER))
2140 {
2142 }
2143 else if (player->GetVehicle())
2144 {
2146 }
2147 else if (player->GetCharmGUID() || player->IsInCombat())
2148 {
2150 }
2151 else if (out && error == LFG_TELEPORTERROR_OK)
2152 {
2153 if (player->GetMapId() == uint32(dungeon->map))
2154 player->TeleportToEntryPoint();
2155
2156 return;
2157 }
2158 else
2159 {
2160 uint32 mapid = dungeon->map;
2161 float x = dungeon->x;
2162 float y = dungeon->y;
2163 float z = dungeon->z;
2164 float orientation = dungeon->o;
2165
2166 if (teleportLocation)
2167 {
2168 teleportLocation->GetWorldLocation(mapid, x, y, z, orientation);
2169 }
2170
2171 if (!player->GetMap()->IsDungeon() || player->GetEntryPoint().GetMapId() == MAPID_INVALID)
2172 {
2173 player->SetEntryPoint();
2174 }
2175
2176 if (!player->TeleportTo(mapid, x, y, z, orientation, 0, nullptr, mapid == player->GetMapId()))
2177 {
2179 }
2180 }
2181
2182 if (error != LFG_TELEPORTERROR_OK)
2183 {
2184 player->GetSession()->SendLfgTeleportError(uint8(error));
2185
2186 LOG_DEBUG("lfg", "Player [{}] could NOT be teleported in to map [{}] (x: {}, y: {}, z: {}) Error: {}",
2187 player->GetName(), dungeon->map, dungeon->x, dungeon->y, dungeon->z, error);
2188 }
2189 else
2190 {
2191 LOG_DEBUG("lfg", "Player [{}] is being teleported in to map [{}] (x: {}, y: {}, z: {})",
2192 player->GetName(), dungeon->map, dungeon->x, dungeon->y, dungeon->z);
2193 }
2194
2195 }
@ FATIGUE_TIMER
Definition Player.h:580
#define MAPID_INVALID
Definition Position.h:252
@ UNIT_STATE_JUMPING
Definition UnitDefines.h:188
bool IsDungeon() const
Definition Map.h:290
void SetEntryPoint()
Definition Player.cpp:11266
bool IsMirrorTimerActive(MirrorTimerType type)
Definition Player.h:2079
bool TeleportToEntryPoint()
Definition Player.cpp:1609
WorldLocation const & GetEntryPoint() const
Definition Player.h:2396
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options=0, Unit *target=nullptr, bool newInstance=false)
Definition Player.cpp:1342
bool IsFalling() const
Definition Player.cpp:2167
Vehicle * GetVehicle() const
Definition Unit.h:1839
bool IsAlive() const
Definition Unit.h:1707
ObjectGuid GetCharmGUID() const
Definition Unit.h:676
bool HasUnitState(const uint32 f) const
Definition Unit.h:691
bool IsInCombat() const
Definition Unit.h:879
Map * GetMap() const
Definition Object.h:587
void SendLfgTeleportError(uint8 err)
Definition LFGHandler.cpp:610
LfgTeleportError
Teleport errors.
Definition LFGMgr.h:87
@ LFG_TELEPORTERROR_INVALID_LOCATION
Definition LFGMgr.h:94
@ LFG_TELEPORTERROR_OK
Definition LFGMgr.h:89
@ LFG_TELEPORTERROR_FATIGUE
Definition LFGMgr.h:93
@ LFG_TELEPORTERROR_COMBAT
Definition LFGMgr.h:95
@ LFG_TELEPORTERROR_PLAYER_DEAD
Definition LFGMgr.h:90
@ LFG_TELEPORTERROR_FALLING
Definition LFGMgr.h:91
@ LFG_TELEPORTERROR_IN_VEHICLE
Definition LFGMgr.h:92

References FATIGUE_TIMER, Unit::GetCharmGUID(), 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 ( )
808 {
811 }
@ LANG_DEBUG_LFG_ON
Definition Language.h:1343
@ LANG_DEBUG_LFG_OFF
Definition Language.h:1344
Definition Chat.h:37
void SendWorldText(std::string_view str)
Definition Chat.cpp:131

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

◆ Update()

void lfg::LFGMgr::Update ( uint32  diff,
uint8  task 
)
275 {
277 return;
278
279 if (task == 0)
280 {
281 time_t currTime = GameTime::GetGameTime().count();
282
283 // Remove obsolete role checks
284 for (LfgRoleCheckContainer::iterator it = RoleChecksStore.begin(); it != RoleChecksStore.end();)
285 {
286 LfgRoleCheckContainer::iterator itRoleCheck = it++;
287 LfgRoleCheck& roleCheck = itRoleCheck->second;
288 if (currTime < roleCheck.cancelTime)
289 continue;
290 roleCheck.state = LFG_ROLECHECK_MISSING_ROLE;
291
292 for (LfgRolesMap::const_iterator itRoles = roleCheck.roles.begin(); itRoles != roleCheck.roles.end(); ++itRoles)
293 {
294 ObjectGuid guid = itRoles->first;
295 RestoreState(guid, "Remove Obsolete RoleCheck");
296 SendLfgRoleCheckUpdate(guid, roleCheck);
297 if (guid == roleCheck.leader)
299 }
300
301 RestoreState(itRoleCheck->first, "Remove Obsolete RoleCheck");
302 RoleChecksStore.erase(itRoleCheck);
303 }
304
305 // Remove obsolete proposals
306 for (LfgProposalContainer::iterator it = ProposalsStore.begin(); it != ProposalsStore.end();)
307 {
308 LfgProposalContainer::iterator itRemove = it++;
309 if (itRemove->second.cancelTime < currTime)
311 }
312
313 // Remove obsolete kicks
314 for (LfgPlayerBootContainer::iterator it = BootsStore.begin(); it != BootsStore.end();)
315 {
316 LfgPlayerBootContainer::iterator itBoot = it++;
317 LfgPlayerBoot& boot = itBoot->second;
318 if (boot.cancelTime < currTime)
319 {
320 boot.inProgress = false;
321 for (LfgAnswerContainer::const_iterator itVotes = boot.votes.begin(); itVotes != boot.votes.end(); ++itVotes)
322 {
323 ObjectGuid pguid = itVotes->first;
324 if (pguid != boot.victim)
325 SendLfgBootProposalUpdate(pguid, boot);
327 }
328 SetState(itBoot->first, LFG_STATE_DUNGEON);
329 BootsStore.erase(itBoot);
330 }
331 }
332 }
333 else if (task == 1)
334 {
335 this->lastProposalId = m_lfgProposalId; // pussywizard: task 2 is done independantly, store previous value in LFGMgr for future use
336 uint8 newGroupsProcessed = 0;
337 // Check if a proposal can be formed with the new groups being added
338 for (LfgQueueContainer::iterator it = QueuesStore.begin(); it != QueuesStore.end(); ++it)
339 {
340 newGroupsProcessed += it->second.FindGroups();
341 if (newGroupsProcessed)
342 break;
343 }
344
345 // Update all players status queue info
346 if (!newGroupsProcessed) // don't do this on updates that precessed groups (performance)
347 for (LfgQueueContainer::iterator it = QueuesStore.begin(); it != QueuesStore.end(); ++it)
348 it->second.UpdateQueueTimers(tdiff);
349 }
350 else if (task == 2)
351 {
353 {
354 // 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
355 for (LfgProposalContainer::const_iterator itProposal = ProposalsStore.find(m_lfgProposalId); itProposal != ProposalsStore.end(); ++itProposal)
356 {
357 uint32 proposalId = itProposal->first;
358 LfgProposal& proposal = ProposalsStore[proposalId];
359
360 ObjectGuid guid;
361 for (LfgProposalPlayerContainer::const_iterator itPlayers = proposal.players.begin(); itPlayers != proposal.players.end(); ++itPlayers)
362 {
363 guid = itPlayers->first;
365 if (ObjectGuid gguid = GetGroup(guid))
366 {
369 }
370 else
372 SendLfgUpdateProposal(guid, proposal);
373 }
374
375 if (proposal.state == LFG_PROPOSAL_SUCCESS) // pussywizard: no idea what's the purpose of this xD
376 UpdateProposal(proposalId, guid, true);
377 }
378 }
379
380 UpdateRaidBrowser(tdiff);
381 }
382 }
void SendLfgRoleCheckUpdate(ObjectGuid guid, LfgRoleCheck const &roleCheck)
Definition LFGMgr.cpp:2636
void SendLfgJoinResult(ObjectGuid guid, LfgJoinResultData const &data)
Definition LFGMgr.cpp:2654
bool isOptionEnabled(uint32 option)
Checks if given lfg option is enabled.
Definition LFGMgr.cpp:2727
uint32 lastProposalId
pussywizard, store it here because of splitting LFGMgr update into tasks
Definition LFGMgr.h:618
void UpdateProposal(uint32 proposalId, ObjectGuid guid, bool accept)
Updates proposal to join dungeon with player answer.
Definition LFGMgr.cpp:1806
void UpdateRaidBrowser(uint32 diff)
Definition LFGMgr.cpp:979
@ LFG_OPTION_ENABLE_DUNGEON_FINDER
Definition LFGMgr.h:41
@ LFG_OPTION_ENABLE_RAID_BROWSER
Definition LFGMgr.h:42
@ LFG_UPDATETYPE_PROPOSAL_BEGIN
Definition LFG.h:60
@ LFG_ROLECHECK_MISSING_ROLE
Definition LFGMgr.h:127
@ LFG_PROPOSAL_SUCCESS
Definition LFGMgr.h:82
@ LFG_JOIN_FAILED
Definition LFGMgr.h:103

References BootsStore, lfg::LfgRoleCheck::cancelTime, lfg::LfgPlayerBoot::cancelTime, 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
2053 {
2054 ObjectGuid gguid = GetGroup(guid);
2055 if (!gguid)
2056 return;
2057
2058 LfgPlayerBootContainer::iterator itBoot = BootsStore.find(gguid);
2059 if (itBoot == BootsStore.end())
2060 return;
2061
2062 LfgPlayerBoot& boot = itBoot->second;
2063
2064 if (boot.votes[guid] != LFG_ANSWER_PENDING) // Cheat check: Player can't vote twice
2065 return;
2066
2067 boot.votes[guid] = LfgAnswer(accept);
2068
2069 uint8 votesNum = 0;
2070 uint8 agreeNum = 0;
2071 for (LfgAnswerContainer::const_iterator itVotes = boot.votes.begin(); itVotes != boot.votes.end(); ++itVotes)
2072 {
2073 if (itVotes->second != LFG_ANSWER_PENDING)
2074 {
2075 ++votesNum;
2076 if (itVotes->second == LFG_ANSWER_AGREE)
2077 ++agreeNum;
2078 }
2079 }
2080
2081 // if we don't have enough votes (agree or deny) do nothing
2082 if (agreeNum < LFG_GROUP_KICK_VOTES_NEEDED && (votesNum - agreeNum) < LFG_GROUP_KICK_VOTES_NEEDED)
2083 return;
2084
2085 // Send update info to all players
2086 boot.inProgress = false;
2087 for (LfgAnswerContainer::const_iterator itVotes = boot.votes.begin(); itVotes != boot.votes.end(); ++itVotes)
2088 {
2089 ObjectGuid pguid = itVotes->first;
2090 if (pguid != boot.victim)
2091 {
2093 SendLfgBootProposalUpdate(pguid, boot);
2094 }
2095 }
2096
2098 if (agreeNum == LFG_GROUP_KICK_VOTES_NEEDED) // Vote passed - Kick player
2099 {
2100 if (Group* group = sGroupMgr->GetGroupByGUID(gguid.GetCounter()))
2102
2103 DecreaseKicksLeft(gguid);
2104 }
2105 BootsStore.erase(itBoot);
2106 }
@ GROUP_REMOVEMETHOD_KICK_LFG
Definition SharedDefines.h:3845
static void RemoveFromGroup(Group *group, ObjectGuid guid, RemoveMethod method=GROUP_REMOVEMETHOD_DEFAULT, ObjectGuid kicker=ObjectGuid::Empty, const char *reason=nullptr)
Definition Player.cpp:2354
void DecreaseKicksLeft(ObjectGuid guid)
Definition LFGMgr.cpp:2531
@ LFG_GROUP_KICK_VOTES_NEEDED
Definition LFGMgr.h:55
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
1807 {
1808 // Check if the proposal exists
1809 LfgProposalContainer::iterator itProposal = ProposalsStore.find(proposalId);
1810 if (itProposal == ProposalsStore.end())
1811 return;
1812
1813 LfgProposal& proposal = itProposal->second;
1814
1815 // Check if proposal have the current player
1816 LfgProposalPlayerContainer::iterator itProposalPlayer = proposal.players.find(guid);
1817 if (itProposalPlayer == proposal.players.end())
1818 return;
1819
1820 LfgProposalPlayer& player = itProposalPlayer->second;
1821 player.accept = LfgAnswer(accept);
1822
1823 LOG_DEBUG("lfg", "LFGMgr::UpdateProposal: Player [{}] of proposal {} selected: {}", guid.ToString(), proposalId, accept);
1824 if (!accept)
1825 {
1827 return;
1828 }
1829
1830 // check if all have answered and reorder players (leader first)
1831 bool allAnswered = true;
1832 for (LfgProposalPlayerContainer::const_iterator itPlayers = proposal.players.begin(); itPlayers != proposal.players.end(); ++itPlayers)
1833 if (itPlayers->second.accept != LFG_ANSWER_AGREE) // No answer (-1) or not accepted (0)
1834 allAnswered = false;
1835
1836 if (!m_Testing && !allAnswered)
1837 {
1838 for (LfgProposalPlayerContainer::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it)
1839 SendLfgUpdateProposal(it->first, proposal);
1840
1841 return;
1842 }
1843
1844 bool sendUpdate = proposal.state != LFG_PROPOSAL_SUCCESS;
1845 proposal.state = LFG_PROPOSAL_SUCCESS;
1846 time_t joinTime = GameTime::GetGameTime().count();
1847
1848 LFGQueue& queue = GetQueue(guid);
1849 LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_GROUP_FOUND);
1850 for (LfgProposalPlayerContainer::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it)
1851 {
1852 ObjectGuid pguid = it->first;
1853 ObjectGuid gguid = it->second.group;
1854 uint32 dungeonId = (*GetSelectedDungeons(pguid).begin());
1855 int32 waitTime = -1;
1856 if (sendUpdate)
1857 SendLfgUpdateProposal(pguid, proposal);
1858
1859 if (gguid)
1860 {
1861 waitTime = int32((joinTime - queue.GetJoinTime(gguid)) / IN_MILLISECONDS);
1862 SendLfgUpdateParty(pguid, updateData);
1863 }
1864 else
1865 {
1866 waitTime = int32((joinTime - queue.GetJoinTime(pguid)) / IN_MILLISECONDS);
1867 SendLfgUpdatePlayer(pguid, updateData);
1868 }
1869 updateData.updateType = LFG_UPDATETYPE_REMOVED_FROM_QUEUE;
1870 SendLfgUpdatePlayer(pguid, updateData);
1871 SendLfgUpdateParty(pguid, updateData);
1872
1873 // Update timers
1874 uint8 role = GetRoles(pguid);
1875 role &= ~PLAYER_ROLE_LEADER;
1876 switch (role)
1877 {
1878 case PLAYER_ROLE_DAMAGE:
1879 queue.UpdateWaitTimeDps(waitTime, dungeonId);
1880 break;
1881 case PLAYER_ROLE_HEALER:
1882 queue.UpdateWaitTimeHealer(waitTime, dungeonId);
1883 break;
1884 case PLAYER_ROLE_TANK:
1885 queue.UpdateWaitTimeTank(waitTime, dungeonId);
1886 break;
1887 default:
1888 queue.UpdateWaitTimeAvg(waitTime, dungeonId);
1889 break;
1890 }
1891
1893 }
1894
1895 // Remove players/groups from Queue
1896 for (uint8 i = 0; i < 5 && proposal.queues.guids[i]; ++i)
1897 queue.RemoveQueueData(proposal.queues.guids[i]);
1898
1899 MakeNewGroup(proposal);
1900 ProposalsStore.erase(itProposal);
1901 }
std::int32_t int32
Definition Define.h:103
uint8 GetRoles(ObjectGuid guid)
Get current player roles.
Definition LFGMgr.cpp:2400
void MakeNewGroup(LfgProposal const &proposal)
Definition LFGMgr.cpp:1583
@ 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)
980 {
981 for (uint8 team = 0; team < 2; ++team)
982 {
983 if (m_raidBrowserUpdateTimer[team] > diff)
984 m_raidBrowserUpdateTimer[team] -= diff;
985 else
986 m_raidBrowserUpdateTimer[team] = 0;
987 }
988
989 if (GetMSTimeDiff(GameTime::GetGameTimeMS(), GetTimeMS()) > 98ms) // prevent lagging
990 {
991 return;
992 }
993
994 ObjectGuid guid, groupGuid, instanceGuid;
995 uint8 level, Class, race, talents[3];
996 float iLevel, mp5, mp5combat, baseAP, rangedAP;
997 int32 spellDamage, spellHeal;
998 uint32 dungeonId, encounterMask, maxPower;
999 uint32 deletedCounter, groupCounter, playerCounter;
1000 ByteBuffer buffer_deleted, buffer_groups, buffer_players;
1001 std::string emptyComment;
1002 GuidSet deletedGroups, deletedGroupsToErase;
1003 RBInternalInfoMap copy;
1004
1005 for (uint8 team = 0; team < 2; ++team)
1006 {
1007 if (m_raidBrowserLastUpdatedDungeonId[team] == 0) // new loop
1008 {
1009 if (m_raidBrowserUpdateTimer[team] > 0) // allowed only with some time interval
1010 continue;
1011 else // reset timer
1012 m_raidBrowserUpdateTimer[team] = 5000;
1013 }
1014
1015 RBUsedDungeonsSet::const_iterator neitr, titr;
1016 for (neitr = RBUsedDungeonsStore[team].begin(); neitr != RBUsedDungeonsStore[team].end(); )
1017 {
1018 titr = neitr++;
1019 dungeonId = (*titr);
1020
1021 // go to next dungeon than previously (one dungeon updated in one LFGMgr::UpdateRaidBrowser)
1022 if (dungeonId <= m_raidBrowserLastUpdatedDungeonId[team])
1023 continue;
1024 m_raidBrowserLastUpdatedDungeonId[team] = dungeonId;
1025
1026 RBEntryInfoMap& entryInfoMap = RaidBrowserStore[team][dungeonId];
1027 LFGDungeonData const* dungeonData = GetLFGDungeon(dungeonId); // checked if exists before inserting to the container
1028 RBInternalInfoMap& currInternalInfoMap = RBInternalInfoStoreCurr[team][dungeonId];
1029 for (RBEntryInfoMap::const_iterator sitr = entryInfoMap.begin(); sitr != entryInfoMap.end(); ++sitr)
1030 {
1031 guid = sitr->first;
1032 groupGuid.Clear();
1034 ASSERT(p);
1035 if (sitr->second.roles == PLAYER_ROLE_LEADER)
1036 {
1037 ASSERT(p->GetGroup());
1038 groupGuid = p->GetGroup()->GetGUID();
1039 }
1040 encounterMask = 0;
1041 instanceGuid.Clear();
1042 if (InstancePlayerBind* bind = sInstanceSaveMgr->PlayerGetBoundInstance(guid, dungeonData->map, dungeonData->difficulty))
1043 if (bind->perm)
1044 {
1045 instanceGuid = ObjectGuid::Create<HighGuid::Instance>(bind->save->GetInstanceId());
1046 encounterMask = bind->save->GetCompletedEncounterMask();
1047 }
1048
1049 talents[0] = 0;
1050 talents[1] = 0;
1051 talents[2] = 0;
1052 p->GetTalentTreePoints(talents);
1059 maxPower = 0;
1060 if (p->IsClass(CLASS_DRUID))
1061 maxPower = p->GetMaxPower(POWER_MANA);
1062 else
1063 maxPower = (p->getPowerType() == POWER_RAGE || p->getPowerType() == POWER_RUNIC_POWER) ? p->GetMaxPower(p->getPowerType()) / 10 : p->GetMaxPower(p->getPowerType());
1064
1065 currInternalInfoMap[sitr->first] = RBInternalInfo(guid, sitr->second.comment, !groupGuid.IsEmpty(), groupGuid, sitr->second.roles, encounterMask, instanceGuid,
1066 1, p->GetLevel(), p->getClass(), p->getRace(), p->GetAverageItemLevel(),
1067 talents, p->GetAreaId(), p->GetArmor(), (uint32)std::max<int32>(0, spellDamage), (uint32)std::max<int32>(0, spellHeal),
1068 p->GetUInt32Value(PLAYER_FIELD_COMBAT_RATING_1 + static_cast<uint16>(CR_CRIT_MELEE)), p->GetUInt32Value(PLAYER_FIELD_COMBAT_RATING_1 + static_cast<uint16>(CR_CRIT_RANGED)), p->GetUInt32Value(PLAYER_FIELD_COMBAT_RATING_1 + static_cast<uint16>(CR_CRIT_SPELL)), std::max<float>(0.0f, mp5), std::max<float>(0.0f, mp5combat),
1069 std::max<uint32>(baseAP, rangedAP), (uint32)p->GetStat(STAT_AGILITY), p->GetMaxHealth(), maxPower, p->GetDefenseSkillValue(),
1071
1072 if (!groupGuid)
1073 continue;
1074 for (Group::member_citerator mitr = p->GetGroup()->GetMemberSlots().begin(); mitr != p->GetGroup()->GetMemberSlots().end(); ++mitr)
1075 {
1076 if (mitr->guid == sitr->first) // leader already added
1077 continue;
1078
1079 guid = mitr->guid;
1080 level = 1;
1081 Class = 0;
1082 race = 0;
1083 iLevel = 0.0f;
1084 talents[0] = 0;
1085 talents[1] = 0;
1086 talents[2] = 0;
1087 if (CharacterCacheEntry const* gpd = sCharacterCache->GetCharacterCacheByGuid(mitr->guid))
1088 {
1089 level = gpd->Level;
1090 Class = gpd->Class;
1091 race = gpd->Race;
1092 }
1094 if (mplr)
1095 {
1096 iLevel = mplr->GetAverageItemLevel();
1097 mplr->GetTalentTreePoints(talents);
1098 }
1099 currInternalInfoMap[mitr->guid] = RBInternalInfo(guid, emptyComment, false, groupGuid, 0, 0, ObjectGuid::Empty,
1100 (mplr ? 1 : 0), level, Class, race, iLevel,
1101 talents, 0, 0, 0, 0,
1102 0, 0, 0, 0, 0,
1103 0, 0, 0, 0, 0,
1104 0, 0, 0, 0, 0);
1105 }
1106 }
1107
1108 copy.clear();
1109 copy = currInternalInfoMap; // will be saved as prev at the end
1110
1111 // compare prev with curr to build difference packet
1112 deletedCounter = 0;
1113 groupCounter = 0;
1114 playerCounter = 0;
1115 buffer_deleted.clear();
1116 buffer_groups.clear();
1117 buffer_players.clear();
1118 deletedGroups.clear();
1119 deletedGroupsToErase.clear();
1120
1121 RBInternalInfoMap& prevInternalInfoMap = RBInternalInfoStorePrev[team][dungeonId];
1122 RBInternalInfoMap::iterator iter, iterTmp;
1123 for (RBInternalInfoMap::const_iterator sitr = prevInternalInfoMap.begin(); sitr != prevInternalInfoMap.end(); ++sitr)
1124 {
1125 iter = currInternalInfoMap.find(sitr->first);
1126 if (iter == currInternalInfoMap.end()) // was -> isn't
1127 {
1128 if (sitr->second.isGroupLeader)
1129 deletedGroups.insert(sitr->second.groupGuid);
1130 ++deletedCounter;
1131 buffer_deleted << sitr->second.guid;
1132 }
1133 else // was -> is
1134 {
1135 if (sitr->second.isGroupLeader) // was a leader
1136 {
1137 if (!iter->second.isGroupLeader) // leader -> no longer a leader
1138 deletedGroups.insert(sitr->second.groupGuid);
1139 else if (sitr->second.groupGuid != iter->second.groupGuid) // leader -> leader of another group
1140 {
1141 deletedGroups.insert(sitr->second.groupGuid);
1142 deletedGroupsToErase.insert(iter->second.groupGuid);
1143 ++groupCounter;
1144 RBPacketAppendGroup(iter->second, buffer_groups);
1145 }
1146 else if (sitr->second.comment != iter->second.comment || sitr->second.encounterMask != iter->second.encounterMask || sitr->second.instanceGuid != iter->second.instanceGuid) // leader -> nothing changed
1147 {
1148 ++groupCounter;
1149 RBPacketAppendGroup(iter->second, buffer_groups);
1150 }
1151 }
1152 else if (iter->second.isGroupLeader) // wasn't a leader -> is a leader
1153 {
1154 deletedGroupsToErase.insert(iter->second.groupGuid);
1155 ++groupCounter;
1156 RBPacketAppendGroup(iter->second, buffer_groups);
1157 }
1158
1159 if (!iter->second._online) // if offline, copy previous stats (itemLevel, talents, area, etc.)
1160 {
1161 iterTmp = copy.find(sitr->first); // copied container is for building a full packet, so modify it there (currInternalInfoMap is erased)
1162 iterTmp->second.CopyStats(sitr->second);
1163 if (!sitr->second.PlayerSameAs(iterTmp->second)) // player info changed
1164 {
1165 ++playerCounter;
1166 RBPacketAppendPlayer(iterTmp->second, buffer_players);
1167 }
1168 }
1169 else if (!sitr->second.PlayerSameAs(iter->second)) // player info changed
1170 {
1171 ++playerCounter;
1172 RBPacketAppendPlayer(iter->second, buffer_players);
1173 }
1174 currInternalInfoMap.erase(iter);
1175 }
1176 }
1177 // left entries (new)
1178 for (RBInternalInfoMap::const_iterator sitr = currInternalInfoMap.begin(); sitr != currInternalInfoMap.end(); ++sitr)
1179 {
1180 if (sitr->second.isGroupLeader)
1181 {
1182 deletedGroupsToErase.insert(sitr->second.groupGuid);
1183 ++groupCounter;
1184 RBPacketAppendGroup(sitr->second, buffer_groups);
1185 }
1186 ++playerCounter;
1187 RBPacketAppendPlayer(sitr->second, buffer_players);
1188 }
1189
1190 if (!deletedGroupsToErase.empty())
1191 {
1192 for (ObjectGuid const& toErase : deletedGroupsToErase)
1193 {
1194 deletedGroups.erase(toErase);
1195 }
1196 }
1197
1198 if (!deletedGroups.empty())
1199 {
1200 for (ObjectGuid const& deletedGroup : deletedGroups)
1201 {
1202 ++deletedCounter;
1203 buffer_deleted << deletedGroup;
1204 }
1205 }
1206
1207 WorldPacket differencePacket(SMSG_UPDATE_LFG_LIST, 1000);
1208 RBPacketBuildDifference(differencePacket, dungeonId, deletedCounter, buffer_deleted, groupCounter, buffer_groups, playerCounter, buffer_players);
1209 WorldPacket fullPacket(SMSG_UPDATE_LFG_LIST, 1000);
1210 RBPacketBuildFull(fullPacket, dungeonId, copy);
1211
1212 RBCacheStore[team][dungeonId] = fullPacket;
1213 prevInternalInfoMap = copy;
1214 currInternalInfoMap.clear();
1215
1216 if (entryInfoMap.empty())
1217 RBUsedDungeonsStore[team].erase(titr);
1218
1219 // send difference packet to browsing players
1220 for (RBSearchersMap::const_iterator sitr = RBSearchersStore[team].begin(); sitr != RBSearchersStore[team].end(); ++sitr)
1221 if (sitr->second == dungeonId)
1222 if (Player* p = ObjectAccessor::FindConnectedPlayer(sitr->first))
1223 p->GetSession()->SendPacket(&differencePacket);
1224
1225 break; // one dungeon updated in one LFGMgr::UpdateRaidBrowser
1226 }
1227
1228 // already updated all in this time interval
1229 if (neitr == RBUsedDungeonsStore[team].end())
1231 }
1232 }
#define sCharacterCache
Definition CharacterCache.h:83
std::uint16_t uint16
Definition Define.h:108
std::set< ObjectGuid > GuidSet
Definition ObjectGuid.h:253
@ Class
Requires the player to be a specific class.
@ POWER_RAGE
Definition SharedDefines.h:270
@ POWER_RUNIC_POWER
Definition SharedDefines.h:275
@ POWER_MANA
Definition SharedDefines.h:269
@ CLASS_DRUID
Definition SharedDefines.h:151
@ STAT_AGILITY
Definition SharedDefines.h:259
@ SPELL_SCHOOL_MASK_ALL
Definition SharedDefines.h:315
Milliseconds GetTimeMS()
Definition Timer.h:84
Milliseconds GetMSTimeDiff(Milliseconds oldMSTime, Milliseconds newMSTime)
Definition Timer.h:91
@ BASE_ATTACK
Definition Unit.h:210
@ RANGED_ATTACK
Definition Unit.h:212
@ CR_EXPERTISE
Definition Unit.h:241
@ CR_CRIT_MELEE
Definition Unit.h:226
@ CR_CRIT_RANGED
Definition Unit.h:227
@ CR_PARRY
Definition Unit.h:221
@ CR_DODGE
Definition Unit.h:220
@ CR_BLOCK
Definition Unit.h:222
@ CR_HASTE_SPELL
Definition Unit.h:237
@ CR_CRIT_SPELL
Definition Unit.h:228
@ PLAYER_FIELD_COMBAT_RATING_1
Definition UpdateFields.h:380
@ UNIT_FIELD_POWER_REGEN_INTERRUPTED_FLAT_MODIFIER
Definition UpdateFields.h:113
@ UNIT_FIELD_POWER_REGEN_FLAT_MODIFIER
Definition UpdateFields.h:112
void clear()
Definition ByteBuffer.h:122
MemberSlotList const & GetMemberSlots() const
Definition Group.h:242
MemberSlotList::const_iterator member_citerator
Definition Group.h:180
bool IsEmpty() const
Definition ObjectGuid.h:161
uint32 GetUInt32Value(uint16 index) const
Definition Object.cpp:305
float GetFloatValue(uint16 index) const
Definition Object.cpp:317
void GetTalentTreePoints(uint8(&specPoints)[3]) const
Definition Player.cpp:15262
float GetAverageItemLevel()
Definition Player.cpp:15703
int32 SpellBaseHealingBonusDone(SpellSchoolMask schoolMask)
Definition Unit.cpp:12786
float GetTotalAttackPowerValue(WeaponAttackType attType, Unit *pVictim=nullptr) const
Definition Unit.cpp:15520
uint32 GetDefenseSkillValue(Unit const *target=nullptr) const
Definition Unit.cpp:3653
uint32 GetMaxHealth() const
Definition Unit.h:1032
uint8 getClass() const
Definition Unit.h:793
uint8 getRace(bool original=false) const
Definition Unit.cpp:20865
uint32 GetMaxPower(Powers power) const
Definition Unit.h:1059
uint32 GetArmor() const
Definition Unit.h:1081
int32 SpellBaseDamageBonusDone(SpellSchoolMask schoolMask)
Definition Unit.cpp:12020
float GetStat(Stats stat) const
Definition Unit.h:997
Powers getPowerType() const
Definition Unit.h:1054
uint32 GetAreaId() const
Definition Object.cpp:3152
std::unordered_map< ObjectGuid, RBInternalInfo > RBInternalInfoMap
Definition LFGMgr.h:433
void RBPacketBuildDifference(WorldPacket &differencePacket, uint32 dungeonId, uint32 deletedCounter, ByteBuffer &buffer_deleted, uint32 groupCounter, ByteBuffer &buffer_groups, uint32 playerCounter, ByteBuffer &buffer_players)
Definition LFGMgr.cpp:1304
RBInternalInfoMapMap RBInternalInfoStorePrev[2]
Definition LFGMgr.h:435
std::unordered_map< ObjectGuid, RBEntryInfo > RBEntryInfoMap
Definition LFGMgr.h:426
void RBPacketBuildFull(WorldPacket &fullPacket, uint32 dungeonId, RBInternalInfoMap &infoMap)
Definition LFGMgr.cpp:1319
RBInternalInfoMapMap RBInternalInfoStoreCurr[2]
Definition LFGMgr.h:436
Milliseconds GetGameTimeMS()
Definition GameTime.cpp:43
Definition CharacterCache.h:28

References ASSERT, BASE_ATTACK, Class, CLASS_DRUID, ObjectGuid::Clear(), ByteBuffer::clear(), CR_BLOCK, CR_CRIT_MELEE, CR_CRIT_RANGED, CR_CRIT_SPELL, CR_DODGE, CR_EXPERTISE, CR_HASTE_SPELL, CR_PARRY, lfg::LFGDungeonData::difficulty, ObjectGuid::Empty, ObjectAccessor::FindConnectedPlayer(), WorldObject::GetAreaId(), Unit::GetArmor(), Player::GetAverageItemLevel(), Unit::getClass(), Unit::GetDefenseSkillValue(), Object::GetFloatValue(), GameTime::GetGameTimeMS(), Player::GetGroup(), Group::GetGUID(), Unit::GetLevel(), GetLFGDungeon(), Unit::GetMaxHealth(), Unit::GetMaxPower(), Group::GetMemberSlots(), GetMSTimeDiff(), Unit::getPowerType(), Unit::getRace(), Unit::GetStat(), Player::GetTalentTreePoints(), GetTimeMS(), Unit::GetTotalAttackPowerValue(), Object::GetUInt32Value(), Player::IsClass(), ObjectGuid::IsEmpty(), m_raidBrowserLastUpdatedDungeonId, m_raidBrowserUpdateTimer, lfg::LFGDungeonData::map, PLAYER_FIELD_COMBAT_RATING_1, lfg::PLAYER_ROLE_LEADER, POWER_MANA, POWER_RAGE, POWER_RUNIC_POWER, RaidBrowserStore, RANGED_ATTACK, RBCacheStore, RBInternalInfoStoreCurr, RBInternalInfoStorePrev, RBPacketAppendGroup(), RBPacketAppendPlayer(), RBPacketBuildDifference(), RBPacketBuildFull(), RBSearchersStore, RBUsedDungeonsStore, sCharacterCache, sInstanceSaveMgr, SMSG_UPDATE_LFG_LIST, SPELL_SCHOOL_MASK_ALL, Unit::SpellBaseDamageBonusDone(), Unit::SpellBaseHealingBonusDone(), STAT_AGILITY, UNIT_FIELD_POWER_REGEN_FLAT_MODIFIER, and UNIT_FIELD_POWER_REGEN_INTERRUPTED_FLAT_MODIFIER.

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
1401 {
1402 if (!gguid)
1403 return;
1404
1405 LfgRolesMap check_roles;
1406 LfgRoleCheckContainer::iterator itRoleCheck = RoleChecksStore.find(gguid);
1407 if (itRoleCheck == RoleChecksStore.end())
1408 return;
1409
1410 LfgRoleCheck& roleCheck = itRoleCheck->second;
1411 bool sendRoleChosen = roleCheck.state != LFG_ROLECHECK_DEFAULT && guid;
1412
1413 if (!guid)
1414 roleCheck.state = LFG_ROLECHECK_ABORTED;
1415 else if (roles < PLAYER_ROLE_TANK) // Player selected no role.
1416 roleCheck.state = LFG_ROLECHECK_NO_ROLE;
1417 else
1418 {
1419 roleCheck.roles[guid] = roles;
1420
1421 // Check if all players have selected a role
1422 LfgRolesMap::const_iterator itRoles = roleCheck.roles.begin();
1423 while (itRoles != roleCheck.roles.end() && itRoles->second != PLAYER_ROLE_NONE)
1424 ++itRoles;
1425
1426 if (itRoles == roleCheck.roles.end())
1427 {
1428 // use temporal var to check roles, CheckGroupRoles modifies the roles
1429 check_roles = roleCheck.roles;
1430 roleCheck.state = CheckGroupRoles(check_roles) ? LFG_ROLECHECK_FINISHED : LFG_ROLECHECK_WRONG_ROLES;
1431 }
1432 }
1433
1434 LfgDungeonSet dungeons;
1435 if (roleCheck.rDungeonId)
1436 dungeons.insert(roleCheck.rDungeonId);
1437 else
1438 dungeons = roleCheck.dungeons;
1439
1440 LfgJoinResultData joinData = LfgJoinResultData(LFG_JOIN_FAILED, roleCheck.state);
1441 for (LfgRolesMap::const_iterator it = roleCheck.roles.begin(); it != roleCheck.roles.end(); ++it)
1442 {
1443 ObjectGuid pguid = it->first;
1444
1445 if (sendRoleChosen)
1446 SendLfgRoleChosen(pguid, guid, roles);
1447
1448 SendLfgRoleCheckUpdate(pguid, roleCheck);
1449 switch (roleCheck.state)
1450 {
1452 continue;
1454 SetState(pguid, LFG_STATE_QUEUED);
1455 SetRoles(pguid, it->second);
1456 SendLfgUpdateParty(pguid, LfgUpdateData(LFG_UPDATETYPE_ADDED_TO_QUEUE, dungeons, GetComment(pguid)));
1457 break;
1458 default:
1459 if (roleCheck.leader == pguid)
1460 SendLfgJoinResult(pguid, joinData);
1462 RestoreState(pguid, "Rolecheck Failed");
1463 break;
1464 }
1465 }
1466
1467 if (roleCheck.state == LFG_ROLECHECK_FINISHED)
1468 {
1469 SetState(gguid, LFG_STATE_QUEUED);
1470 LFGQueue& queue = GetQueue(gguid);
1471 queue.AddQueueData(gguid, time_t(GameTime::GetGameTime().count()), roleCheck.dungeons, roleCheck.roles);
1472 RoleChecksStore.erase(itRoleCheck);
1473 }
1474 else if (roleCheck.state != LFG_ROLECHECK_INITIALITING)
1475 {
1476 RestoreState(gguid, "Rolecheck Failed");
1477 RoleChecksStore.erase(itRoleCheck);
1478 }
1479 }
void SendLfgRoleChosen(ObjectGuid guid, ObjectGuid pguid, uint8 roles)
Definition LFGMgr.cpp:2630
@ LFG_UPDATETYPE_ROLECHECK_FAILED
Definition LFG.h:54
@ LFG_ROLECHECK_WRONG_ROLES
Definition LFGMgr.h:128
@ LFG_ROLECHECK_ABORTED
Definition LFGMgr.h:129
@ LFG_ROLECHECK_DEFAULT
Definition LFGMgr.h:124
@ LFG_ROLECHECK_FINISHED
Definition LFGMgr.h:125
@ LFG_ROLECHECK_NO_ROLE
Definition LFGMgr.h:130

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

◆ 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().

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