AzeorthCore 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. More...
 
void LoadRewards ()
 Loads rewards for random dungeons. More...
 
void LoadLFGDungeons (bool reload=false)
 Loads dungeons from dbc and adds teleport coords. More...
 
bool selectedRandomLfgDungeon (ObjectGuid guid)
 Check if given guid applied for random dungeon. More...
 
bool inLfgDungeonMap (ObjectGuid guid, uint32 map, Difficulty difficulty)
 Check if given guid applied for given map and difficulty. Used to know. More...
 
LfgDungeonSet const & GetSelectedDungeons (ObjectGuid guid)
 Get selected dungeons. More...
 
LfgState GetState (ObjectGuid guid)
 Get current lfg state. More...
 
uint32 GetDungeon (ObjectGuid guid, bool asId=true)
 Get current dungeon. More...
 
uint32 GetDungeonMapId (ObjectGuid guid)
 Get the map id of the current dungeon. More...
 
uint8 GetKicksLeft (ObjectGuid gguid)
 Get kicks left in current group. More...
 
void _LoadFromDB (Field *fields, ObjectGuid guid)
 Load Lfg group info from DB. More...
 
void SetupGroupMember (ObjectGuid guid, ObjectGuid gguid)
 Initializes player data after loading group data from DB. More...
 
uint32 GetLFGDungeonEntry (uint32 id)
 Return Lfg dungeon entry for given dungeon id. More...
 
uint8 GetRoles (ObjectGuid guid)
 Get current player roles. More...
 
std::string const & GetComment (ObjectGuid gguid)
 Get current player comment (used for LFR) More...
 
uint32 GetOptions ()
 Gets current lfg options. More...
 
void SetOptions (uint32 options)
 Sets new lfg options. More...
 
bool isOptionEnabled (uint32 option)
 Checks if given lfg option is enabled. More...
 
void Clean ()
 Clears queue - Only for internal testing. More...
 
ObjectGuid GetLeader (ObjectGuid guid)
 Get leader of the group (using internal data) More...
 
void InitializeLockedDungeons (Player *player, uint8 level=0)
 Initializes locked dungeons for given player (called at login or level change) More...
 
void SetTeam (ObjectGuid guid, TeamId teamId)
 Sets player team. More...
 
void SetGroup (ObjectGuid guid, ObjectGuid group)
 Sets player group. More...
 
ObjectGuid GetGroup (ObjectGuid guid)
 Gets player group. More...
 
void SetLeader (ObjectGuid gguid, ObjectGuid leader)
 Sets the leader of the group. More...
 
void RemoveGroupData (ObjectGuid guid)
 Removes saved group data. More...
 
uint8 RemovePlayerFromGroup (ObjectGuid gguid, ObjectGuid guid)
 Removes a player from a group. More...
 
void AddPlayerToGroup (ObjectGuid gguid, ObjectGuid guid)
 Adds player to group. More...
 
void SetRandomPlayersCount (ObjectGuid guid, uint8 count)
 Xinef: Set Random Players Count. More...
 
uint8 GetRandomPlayersCount (ObjectGuid guid)
 Xinef: Get Random Players Count. More...
 
LfgLockMap const & GetLockedDungeons (ObjectGuid guid)
 Get locked dungeons. More...
 
LfgUpdateData GetLfgStatus (ObjectGuid guid)
 Returns current lfg status. More...
 
bool IsSeasonActive (uint32 dungeonId)
 Checks if Seasonal dungeon is active. More...
 
LfgReward const * GetRandomDungeonReward (uint32 dungeon, uint8 level)
 Gets the random dungeon reward corresponding to given dungeon and player level. More...
 
LfgDungeonSet GetRandomAndSeasonalDungeons (uint8 level, uint8 expansion)
 Returns all random and seasonal dungeons for given level and expansion. More...
 
void TeleportPlayer (Player *player, bool out, WorldLocation const *teleportLocation=nullptr)
 Teleport a player to/from selected dungeon. More...
 
void InitBoot (ObjectGuid gguid, ObjectGuid kicker, ObjectGuid victim, std::string const &reason)
 Inits new proposal to boot a player. More...
 
void UpdateBoot (ObjectGuid guid, bool accept)
 Updates player boot proposal with new player answer. More...
 
void UpdateProposal (uint32 proposalId, ObjectGuid guid, bool accept)
 Updates proposal to join dungeon with player answer. More...
 
void UpdateRoleCheck (ObjectGuid gguid, ObjectGuid guid=ObjectGuid::Empty, uint8 roles=PLAYER_ROLE_NONE)
 Updates the role check with player answer. More...
 
void SetRoles (ObjectGuid guid, uint8 roles)
 Sets player lfg roles. More...
 
void SetComment (ObjectGuid guid, std::string const &comment)
 Sets player lfr comment. More...
 
void JoinLfg (Player *player, uint8 roles, LfgDungeonSet &dungeons, std::string const &comment)
 Join Lfg with selected roles, dungeons and comment. More...
 
void LeaveLfg (ObjectGuid guid)
 Leaves lfg. More...
 
void LeaveAllLfgQueues (ObjectGuid guid, bool allowgroup, ObjectGuid groupguid=ObjectGuid::Empty)
 pussywizard: cleans all queues' data More...
 
void JoinRaidBrowser (Player *player, uint8 roles, LfgDungeonSet &dungeons, std::string comment)
 pussywizard: Raid Browser More...
 
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) More...
 
bool IsLfgGroup (ObjectGuid guid)
 Check if given group guid is lfg. More...
 
uint8 GetPlayerCount (ObjectGuid guid)
 Gets the player count of given group. More...
 
uint32 AddProposal (LfgProposal &proposal)
 Add a new Proposal. More...
 
bool AllQueued (Lfg5Guids const &check)
 Checks if all players are queued. More...
 
void ToggleTesting ()
 
bool IsTesting () const
 For 1 player queue testing. More...
 
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. More...
 
static bool HasIgnore (ObjectGuid guid1, ObjectGuid guid2)
 Checks if given players are ignoring each other. More...
 
static void SendLfgQueueStatus (ObjectGuid guid, LfgQueueStatusData const &data)
 Sends queue status to player. More...
 

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 More...
 
uint32 m_options
 Stores config options. More...
 
uint32 lastProposalId
 pussywizard, store it here because of splitting LFGMgr update into tasks More...
 
uint32 m_raidBrowserUpdateTimer [2]
 pussywizard More...
 
uint32 m_raidBrowserLastUpdatedDungeonId [2]
 pussywizard: for 2 factions More...
 
LfgQueueContainer QueuesStore
 Queues. More...
 
LfgCachedDungeonContainer CachedDungeonMapStore
 Stores all dungeons by groupType. More...
 
LfgRewardContainer RewardMapStore
 Stores rewards for random dungeons. More...
 
LFGDungeonContainer LfgDungeonStore
 
LfgRoleCheckContainer RoleChecksStore
 Current Role checks. More...
 
LfgProposalContainer ProposalsStore
 Current Proposals. More...
 
LfgPlayerBootContainer BootsStore
 Current player kicks. More...
 
LfgPlayerDataContainer PlayersStore
 Player data. More...
 
LfgGroupDataContainer GroupsStore
 Group data. More...
 
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
45 {
46 new LFGPlayerScript();
47 new LFGGroupScript();
48
49 for (uint8 team = 0; team < 2; ++team)
50 {
51 m_raidBrowserUpdateTimer[team] = 10000;
53 }
54 }
std::uint8_t uint8
Definition: Define.h:110
@ CONFIG_LFG_OPTIONSMASK
Definition: IWorld.h:365
#define sWorld
Definition: World.h:458
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

References m_raidBrowserLastUpdatedDungeonId, and m_raidBrowserUpdateTimer.

◆ ~LFGMgr()

lfg::LFGMgr::~LFGMgr ( )
private
57 {
58 for (LfgRewardContainer::iterator itr = RewardMapStore.begin(); itr != RewardMapStore.end(); ++itr)
59 delete itr->second;
60 }
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.

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

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
98 {
99 if (!guid.IsGroup())
100 return;
101
103 stmt->SetData(0, guid.GetCounter());
104 stmt->SetData(1, GetDungeon(guid));
105 stmt->SetData(2, GetState(guid));
106 CharacterDatabase.Execute(stmt);
107 }
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
@ CHAR_REP_LFG_DATA
Definition: CharacterDatabase.h:324
Definition: PreparedStatement.h:158
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition: PreparedStatement.h:78
LfgState GetState(ObjectGuid guid)
Get current lfg state.
Definition: LFGMgr.cpp:2344
uint32 GetDungeon(ObjectGuid guid, bool asId=true)
Get current dungeon.
Definition: LFGMgr.cpp:2368
LowType GetCounter() const
Definition: ObjectGuid.h:147

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.

2558 {
2559 GroupsStore[gguid].AddPlayer(guid);
2560 }
LfgGroupDataContainer GroupsStore
Group data.
Definition: LFGMgr.h:632

References GroupsStore.

Referenced by SetupGroupMember().

◆ AddProposal()

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

Add a new Proposal.

1786 {
1787 proposal.id = ++m_lfgProposalId;
1788 ProposalsStore[m_lfgProposalId] = proposal;
1789 return m_lfgProposalId;
1790 }
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.

2688 {
2689 bool ok = true;
2690
2691 if (check.empty())
2692 return false;
2693
2694 for (uint8 i = 0; i < 5 && check.guids[i]; ++i)
2695 {
2696 ObjectGuid guid = check.guids[i];
2697 if (GetState(guid) != LFG_STATE_QUEUED)
2698 {
2699 LFGQueue& queue = GetQueue(guid);
2700 queue.RemoveFromQueue(guid);
2701 ok = false;
2702 }
2703 }
2704
2705 return ok;
2706 }
@ LFG_STATE_QUEUED
Definition: LFG.h:73
LFGQueue & GetQueue(ObjectGuid guid)
Definition: LFGMgr.cpp:2670
Definition: ObjectGuid.h:120

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.

1502 {
1503 if (groles.empty())
1504 return 0;
1505
1506 uint8 damage = 0;
1507 uint8 tank = 0;
1508 uint8 healer = 0;
1509
1510 if (removeLeaderFlag)
1511 for (LfgRolesMap::iterator it = groles.begin(); it != groles.end(); ++it)
1512 it->second &= ~PLAYER_ROLE_LEADER;
1513
1514 for (LfgRolesMap::iterator it = groles.begin(); it != groles.end(); ++it)
1515 {
1516 if (it->second == PLAYER_ROLE_NONE)
1517 return 0;
1518
1519 if (it->second & PLAYER_ROLE_DAMAGE)
1520 {
1521 if (it->second != PLAYER_ROLE_DAMAGE)
1522 {
1523 it->second -= PLAYER_ROLE_DAMAGE;
1524 if (uint8 x = CheckGroupRoles(groles, false))
1525 return x;
1526 it->second += PLAYER_ROLE_DAMAGE;
1527 }
1528 else if (damage == LFG_DPS_NEEDED)
1529 return 0;
1530 else
1531 damage++;
1532 }
1533
1534 if (it->second & PLAYER_ROLE_HEALER)
1535 {
1536 if (it->second != PLAYER_ROLE_HEALER)
1537 {
1538 it->second -= PLAYER_ROLE_HEALER;
1539 if (uint8 x = CheckGroupRoles(groles, false))
1540 return x;
1541 it->second += PLAYER_ROLE_HEALER;
1542 }
1543 else if (healer == LFG_HEALERS_NEEDED)
1544 return 0;
1545 else
1546 healer++;
1547 }
1548
1549 if (it->second & PLAYER_ROLE_TANK)
1550 {
1551 if (it->second != PLAYER_ROLE_TANK)
1552 {
1553 it->second -= PLAYER_ROLE_TANK;
1554 if (uint8 x = CheckGroupRoles(groles, false))
1555 return x;
1556 it->second += PLAYER_ROLE_TANK;
1557 }
1558 else if (tank == LFG_TANKS_NEEDED)
1559 return 0;
1560 else
1561 tank++;
1562 }
1563 }
1564 if ((tank + healer + damage) == uint8(groles.size()))
1565 return (8 * tank + 4 * healer + damage);
1566 return 0;
1567 }
@ LFG_HEALERS_NEEDED
Definition: LFG.h:36
@ LFG_TANKS_NEEDED
Definition: LFG.h:35
@ LFG_DPS_NEEDED
Definition: LFG.h:37
@ PLAYER_ROLE_DAMAGE
Definition: LFG.h:46
@ PLAYER_ROLE_TANK
Definition: LFG.h:44
@ PLAYER_ROLE_NONE
Definition: LFG.h:42
@ PLAYER_ROLE_HEALER
Definition: LFG.h:45
static uint8 CheckGroupRoles(LfgRolesMap &groles, bool removeLeaderFlag=true)
Checks if given roles match, modifies given roles map with new roles.
Definition: LFGMgr.cpp:1501

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

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

◆ Clean()

void lfg::LFGMgr::Clean ( )

Clears queue - Only for internal testing.

2710 {
2711 QueuesStore.clear();
2712 }
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
2519 {
2520 LOG_DEBUG("lfg", "LFGMgr::DecreaseKicksLeft: [{}]", guid.ToString());
2521 GroupsStore[guid].DecreaseKicksLeft();
2522 }
#define LOG_DEBUG(filterType__,...)
Definition: Log.h:171
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
2191 {
2192 uint32 gDungeonId = GetDungeon(gguid);
2193 if (gDungeonId != dungeonId)
2194 {
2195 LOG_DEBUG("lfg", "LFGMgr::FinishDungeon: [{}] Finished dungeon {} but group queued for {}. Ignoring", gguid.ToString(), dungeonId, gDungeonId);
2196 return;
2197 }
2198
2199 if (GetState(gguid) == LFG_STATE_FINISHED_DUNGEON) // Shouldn't happen. Do not reward multiple times
2200 {
2201 LOG_DEBUG("lfg", "LFGMgr::FinishDungeon: [{}] Already rewarded group. Ignoring", gguid.ToString());
2202 return;
2203 }
2204
2206 _SaveToDB(gguid); // pussywizard
2207
2208 const LfgGuidSet& players = GetPlayers(gguid);
2209 for (LfgGuidSet::const_iterator it = players.begin(); it != players.end(); ++it)
2210 {
2211 ObjectGuid guid = (*it);
2213 {
2214 LOG_DEBUG("lfg", "LFGMgr::FinishDungeon: [{}] Already rewarded player. Ignoring", guid.ToString());
2215 continue;
2216 }
2217
2218 uint32 rDungeonId = 0;
2219 const LfgDungeonSet& dungeons = GetSelectedDungeons(guid);
2220 if (!dungeons.empty())
2221 rDungeonId = (*dungeons.begin());
2222
2224
2225 // Give rewards only if its a random dungeon
2226 LFGDungeonData const* dungeon = GetLFGDungeon(rDungeonId);
2227
2228 if (!dungeon || (dungeon->type != LFG_TYPE_RANDOM && !dungeon->seasonal))
2229 {
2230 LOG_DEBUG("lfg", "LFGMgr::FinishDungeon: [{}] dungeon {} is not random or seasonal", guid.ToString(), rDungeonId);
2231 continue;
2232 }
2233
2234 Player* player = ObjectAccessor::FindPlayer(guid);
2235 if (!player || player->FindMap() != currMap) // pussywizard: currMap - multithreading crash if on other map (map id check is not enough, binding system is not reliable)
2236 {
2237 LOG_DEBUG("lfg", "LFGMgr::FinishDungeon: [{}] not found in world", guid.ToString());
2238 continue;
2239 }
2240
2241 LFGDungeonData const* dungeonDone = GetLFGDungeon(dungeonId);
2242 uint32 mapId = dungeonDone ? uint32(dungeonDone->map) : 0;
2243
2244 if (player->GetMapId() != mapId)
2245 {
2246 LOG_DEBUG("lfg", "LFGMgr::FinishDungeon: [{}] is in map {} and should be in {} to get reward", guid.ToString(), player->GetMapId(), mapId);
2247 continue;
2248 }
2249
2250 // Remove Dungeon Finder Cooldown if still exists
2252 {
2254 }
2255
2256 // Xinef: Update achievements, set correct amount of randomly grouped players
2257 if (dungeon->difficulty == DUNGEON_DIFFICULTY_HEROIC)
2258 if (uint8 count = GetRandomPlayersCount(player->GetGUID()))
2260
2261 LfgReward const* reward = GetRandomDungeonReward(rDungeonId, player->getLevel());
2262 if (!reward)
2263 continue;
2264
2265 bool done = false;
2266 Quest const* quest = sObjectMgr->GetQuestTemplate(reward->firstQuest);
2267 if (!quest)
2268 continue;
2269
2270 // if we can take the quest, means that we haven't done this kind of "run", IE: First Heroic Random of Day.
2271 if (player->CanRewardQuest(quest, false))
2272 player->RewardQuest(quest, 0, nullptr, false, true);
2273 else
2274 {
2275 done = true;
2276 quest = sObjectMgr->GetQuestTemplate(reward->otherQuest);
2277 if (!quest)
2278 continue;
2279 // we give reward without informing client (retail does this)
2280 player->RewardQuest(quest, 0, nullptr, false, true);
2281 }
2282
2283 // Give rewards
2284 LOG_DEBUG("lfg", "LFGMgr::FinishDungeon: [{}] done dungeon {}, {} previously done.", player->GetGUID().ToString(), GetDungeon(gguid), done ? " " : " not");
2285 LfgPlayerRewardData data = LfgPlayerRewardData(dungeon->Entry(), GetDungeon(gguid, false), done, quest);
2286 player->GetSession()->SendLfgPlayerReward(data);
2287 }
2288 }
#define sObjectMgr
Definition: ObjectMgr.h:1612
@ DUNGEON_DIFFICULTY_HEROIC
Definition: DBCEnums.h:275
@ ACHIEVEMENT_CRITERIA_TYPE_USE_LFD_TO_GROUP_WITH_PLAYERS
Definition: DBCEnums.h:228
GuidSet LfgGuidSet
Definition: LFG.h:112
@ LFG_SPELL_DUNGEON_COOLDOWN
Definition: LFGMgr.h:52
@ LFG_TYPE_RANDOM
Definition: LFGMgr.h:74
std::set< uint32 > LfgDungeonSet
Definition: LFG.h:109
Player * FindPlayer(ObjectGuid const guid)
Definition: ObjectAccessor.cpp:250
uint8 GetRandomPlayersCount(ObjectGuid guid)
Xinef: Get Random Players Count.
Definition: LFGMgr.cpp:2605
void _SaveToDB(ObjectGuid guid)
Definition: LFGMgr.cpp:97
LFGDungeonData const * GetLFGDungeon(uint32 id)
Definition: LFGMgr.cpp:170
LfgDungeonSet const & GetSelectedDungeons(ObjectGuid guid)
Get selected dungeons.
Definition: LFGMgr.cpp:2400
LfgReward const * GetRandomDungeonReward(uint32 dungeon, uint8 level)
Gets the random dungeon reward corresponding to given dungeon and player level.
Definition: LFGMgr.cpp:2314
LfgGuidSet const & GetPlayers(ObjectGuid guid)
Definition: LFGMgr.cpp:2585
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:106
Map * FindMap() const
Definition: Object.h:518
uint32 GetMapId() const
Definition: Position.h:276
Definition: Player.h:1046
void UpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscValue1=0, uint32 miscValue2=0, Unit *unit=nullptr)
Definition: PlayerUpdates.cpp:2125
bool CanRewardQuest(Quest const *quest, bool msg)
Definition: PlayerQuest.cpp:383
WorldSession * GetSession() const
Definition: Player.h:1947
void RewardQuest(Quest const *quest, uint32 reward, Object *questGiver, bool announce=true, bool isLFGReward=false)
Definition: PlayerQuest.cpp:657
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
Definition: Unit.cpp:6454
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:5624
uint8 getLevel() const
Definition: Unit.h:1418
Definition: QuestDef.h:207
void SendLfgPlayerReward(lfg::LfgPlayerRewardData const &lfgPlayerRewardData)
Definition: LFGHandler.cpp:466

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)

2395 {
2396 LOG_DEBUG("lfg", "LFGMgr::GetComment: [{}] = {}", guid.ToString(), PlayersStore[guid].GetComment());
2397 return PlayersStore[guid].GetComment();
2398 }
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)
1480 {
1481 lockMap.clear();
1482 for (LfgGuidSet::const_iterator it = players.begin(); it != players.end() && !dungeons.empty(); ++it)
1483 {
1484 ObjectGuid guid = (*it);
1485 LfgLockMap const& cachedLockMap = GetLockedDungeons(guid);
1486 for (LfgLockMap::const_iterator it2 = cachedLockMap.begin(); it2 != cachedLockMap.end() && !dungeons.empty(); ++it2)
1487 {
1488 uint32 dungeonId = (it2->first & 0x00FFFFFF); // Compare dungeon ids
1489 LfgDungeonSet::iterator itDungeon = dungeons.find(dungeonId);
1490 if (itDungeon != dungeons.end())
1491 {
1492 dungeons.erase(itDungeon);
1493 lockMap[guid][dungeonId] = it2->second;
1494 }
1495 }
1496 }
1497 if (!dungeons.empty())
1498 lockMap.clear();
1499 }
std::map< uint32, uint32 > LfgLockMap
Definition: LFG.h:110
LfgLockMap const & GetLockedDungeons(ObjectGuid guid)
Get locked dungeons.
Definition: LFGMgr.cpp:2406

References GetLockedDungeons().

Referenced by JoinLfg().

◆ GetDungeon()

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

Get current dungeon.

2369 {
2370 uint32 dungeon = GroupsStore[guid].GetDungeon(asId);
2371 LOG_DEBUG("lfg", "LFGMgr::GetDungeon: [{}] asId: {} = {}", guid.ToString(), asId, dungeon);
2372 return dungeon;
2373 }

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.

2376 {
2377 uint32 dungeonId = GroupsStore[guid].GetDungeon(true);
2378 uint32 mapId = 0;
2379 if (dungeonId)
2380 if (LFGDungeonData const* dungeon = GetLFGDungeon(dungeonId))
2381 mapId = dungeon->map;
2382
2383 LOG_DEBUG("lfg", "LFGMgr::GetDungeonMapId: [{}] = {} (DungeonId = {})", guid.ToString(), mapId, dungeonId);
2384 return mapId;
2385 }

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.
2301 {
2302 LFGDungeonData const* dungeon = GetLFGDungeon(randomdungeon);
2303 uint32 group = dungeon ? dungeon->group : 0;
2304 return CachedDungeonMapStore[group];
2305 }
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
2336 {
2337 LFGDungeonData const* dungeon = GetLFGDungeon(dungeonId);
2338 if (!dungeon)
2339 return LFG_TYPE_NONE;
2340
2341 return LfgType(dungeon->type);
2342 }
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.

2576 {
2577 return PlayersStore[guid].GetGroup();
2578 }

References PlayersStore.

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

◆ GetKicksLeft()

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

Get kicks left in current group.

2413 {
2414 uint8 kicks = GroupsStore[guid].GetKicksLeft();
2415 LOG_DEBUG("lfg", "LFGMgr::GetKicksLeft: [{}] = {}", guid.ToString(), kicks);
2416 return kicks;
2417 }

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

◆ GetLeader()

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

Get leader of the group (using internal data)

2596 {
2597 return GroupsStore[guid].GetLeader();
2598 }

References GroupsStore.

Referenced by GetQueue(), and LeaveLfg().

◆ GetLFGDungeon()

LFGDungeonData const * lfg::LFGMgr::GetLFGDungeon ( uint32  id)
private
171 {
172 LFGDungeonContainer::const_iterator itr = LfgDungeonStore.find(id);
173 if (itr != LfgDungeonStore.end())
174 return &(itr->second);
175
176 return nullptr;
177 }
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.

2791 {
2792 if (id)
2793 if (LFGDungeonData const* dungeon = GetLFGDungeon(id))
2794 return dungeon->Entry();
2795
2796 return 0;
2797 }

References GetLFGDungeon().

Referenced by LoadRewards().

◆ GetLfgStatus()

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

Returns current lfg status.

2730 {
2731 LfgPlayerData& playerData = PlayersStore[guid];
2732 return LfgUpdateData(LFG_UPDATETYPE_UPDATE_STATUS, playerData.GetState(), playerData.GetSelectedDungeons());
2733 }
@ LFG_UPDATETYPE_UPDATE_STATUS
Definition: LFG.h:64

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.

2407 {
2408 LOG_DEBUG("lfg", "LFGMgr::GetLockedDungeons: [{}]", guid.ToString());
2409 return PlayersStore[guid].GetLockedDungeons();
2410 }

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)

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

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

◆ GetOptions()

uint32 lfg::LFGMgr::GetOptions ( )

Gets current lfg options.

2720 {
2721 return m_options;
2722 }

References m_options.

◆ GetPlayerCount()

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

Gets the player count of given group.

2591 {
2592 return GroupsStore[guid].GetPlayerCount();
2593 }

References GroupsStore.

◆ GetPlayers()

LfgGuidSet const & lfg::LFGMgr::GetPlayers ( ObjectGuid  guid)
private
2586 {
2587 return GroupsStore[guid].GetPlayers();
2588 }

References GroupsStore.

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

◆ GetQueue()

LFGQueue & lfg::LFGMgr::GetQueue ( ObjectGuid  guid)
private
2671 {
2672 uint8 queueId = 0;
2673 if (guid.IsGroup())
2674 {
2675 LfgGuidSet const& players = GetPlayers(guid);
2676 ObjectGuid pguid = players.empty() ? ObjectGuid::Empty : (*players.begin());
2677 if (pguid)
2678 queueId = GetTeam(pguid);
2679 else
2680 queueId = GetTeam(GetLeader(guid));
2681 }
2682 else
2683 queueId = GetTeam(guid);
2684 return QueuesStore[queueId];
2685 }
ObjectGuid GetLeader(ObjectGuid guid)
Get leader of the group (using internal data)
Definition: LFGMgr.cpp:2595
TeamId GetTeam(ObjectGuid guid)
Definition: LFGMgr.cpp:2547
static ObjectGuid const Empty
Definition: ObjectGuid.h:122

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.

2800 {
2801 LfgDungeonSet randomDungeons;
2802 for (lfg::LFGDungeonContainer::const_iterator itr = LfgDungeonStore.begin(); itr != LfgDungeonStore.end(); ++itr)
2803 {
2804 lfg::LFGDungeonData const& dungeon = itr->second;
2805 if ((dungeon.type == lfg::LFG_TYPE_RANDOM || (dungeon.seasonal && sLFGMgr->IsSeasonActive(dungeon.id)))
2806 && dungeon.expansion <= expansion && dungeon.minlevel <= level && level <= dungeon.maxlevel)
2807 randomDungeons.insert(dungeon.Entry());
2808 }
2809 return randomDungeons;
2810 }
#define sLFGMgr
Definition: LFGMgr.h:638
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
2315 {
2316 LfgReward const* rew = nullptr;
2317 LfgRewardContainerBounds bounds = RewardMapStore.equal_range(dungeon & 0x00FFFFFF);
2318 for (LfgRewardContainer::const_iterator itr = bounds.first; itr != bounds.second; ++itr)
2319 {
2320 rew = itr->second;
2321 // ordered properly at loading
2322 if (itr->second->maxLevel >= level)
2323 break;
2324 }
2325
2326 return rew;
2327 }
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.

2606 {
2607 return PlayersStore[guid].GetRandomPlayersCount();
2608 }

References PlayersStore.

Referenced by FinishDungeon().

◆ GetRoles()

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

Get current player roles.

2388 {
2389 uint8 roles = PlayersStore[guid].GetRoles();
2390 LOG_DEBUG("lfg", "LFGMgr::GetRoles: [{}] = {}", guid.ToString(), roles);
2391 return roles;
2392 }

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

Referenced by UpdateProposal().

◆ GetSelectedDungeons()

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

Get selected dungeons.

2401 {
2402 LOG_DEBUG("lfg", "LFGMgr::GetSelectedDungeons: [{}]", guid.ToString());
2403 return PlayersStore[guid].GetSelectedDungeons();
2404 }

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.

2345 {
2346 LfgState state;
2347 if (guid.IsGroup())
2348 state = GroupsStore[guid].GetState();
2349 else
2350 state = PlayersStore[guid].GetState();
2351
2352 LOG_DEBUG("lfg", "LFGMgr::GetState: [{}] = {}", guid.ToString(), state);
2353 return state;
2354 }

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
2548 {
2549 return PlayersStore[guid].GetTeam();
2550 }

References PlayersStore.

Referenced by GetQueue().

◆ HasIgnore()

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

Checks if given players are ignoring each other.

2611 {
2614 return plr1 && plr2 && (plr1->GetSocial()->HasIgnore(guid2) || plr2->GetSocial()->HasIgnore(guid1));
2615 }
Player * FindConnectedPlayer(ObjectGuid const guid)
Definition: ObjectAccessor.cpp:262
PlayerSocial * GetSocial()
Definition: Player.h:1121
bool HasIgnore(ObjectGuid ignore_guid) const
Definition: SocialMgr.cpp:193

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
2012 {
2013 SetState(gguid, LFG_STATE_BOOT);
2014
2015 LfgPlayerBoot& boot = BootsStore[gguid];
2016 boot.inProgress = true;
2017 boot.cancelTime = time_t(GameTime::GetGameTime().count()) + LFG_TIME_BOOT;
2018 boot.reason = reason;
2019 boot.victim = victim;
2020
2021 LfgGuidSet const& players = GetPlayers(gguid);
2022
2023 // Set votes
2024 for (LfgGuidSet::const_iterator itr = players.begin(); itr != players.end(); ++itr)
2025 {
2026 ObjectGuid guid = (*itr);
2027 SetState(guid, LFG_STATE_BOOT);
2028 boot.votes[guid] = LFG_ANSWER_PENDING;
2029 }
2030
2031 boot.votes[victim] = LFG_ANSWER_DENY; // Victim auto vote NO
2032 boot.votes[kicker] = LFG_ANSWER_AGREE; // Kicker auto vote YES
2033
2034 // Notify players
2035 for (LfgGuidSet::const_iterator it = players.begin(); it != players.end(); ++it)
2036 SendLfgBootProposalUpdate(*it, boot);
2037 }
@ LFG_STATE_BOOT
Definition: LFG.h:75
@ LFG_TIME_BOOT
Definition: LFGMgr.h:49
@ LFG_ANSWER_AGREE
Definition: LFG.h:103
@ LFG_ANSWER_PENDING
Definition: LFG.h:101
@ LFG_ANSWER_DENY
Definition: LFG.h:102
Seconds GetGameTime()
Definition: GameTime.cpp:38
void SendLfgBootProposalUpdate(ObjectGuid guid, LfgPlayerBoot const &boot)
Definition: LFGMgr.cpp:2647
LfgPlayerBootContainer BootsStore
Current player kicks.
Definition: LFGMgr.h:630

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,
uint8  level = 0 
)

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
392 {
393 ObjectGuid guid = player->GetGUID();
394 if (!level)
395 level = player->getLevel();
396 uint8 expansion = player->GetSession()->Expansion();
397 LfgDungeonSet const& dungeons = GetDungeonsByRandom(0);
398 LfgLockMap lock;
399
400 bool onlySeasonalBosses = m_options == LFG_OPTION_ENABLE_SEASONAL_BOSSES;
401
402 float avgItemLevel = player->GetAverageItemLevelForDF();
403
404 for (LfgDungeonSet::const_iterator it = dungeons.begin(); it != dungeons.end(); ++it)
405 {
406 LFGDungeonData const* dungeon = GetLFGDungeon(*it);
407 if (!dungeon) // should never happen - We provide a list from sLFGDungeonStore
408 continue;
409 MapEntry const* mapEntry = sMapStore.LookupEntry(dungeon->map);
410 DungeonProgressionRequirements const* ar = sObjectMgr->GetAccessRequirement(dungeon->map, Difficulty(dungeon->difficulty));
411
412 uint32 lockData = 0;
413 if (dungeon->expansion > expansion || (onlySeasonalBosses && !dungeon->seasonal))
415 else if (DisableMgr::IsDisabledFor(DISABLE_TYPE_MAP, dungeon->map, player))
417 else if (DisableMgr::IsDisabledFor(DISABLE_TYPE_LFG_MAP, dungeon->map, player))
419 else if (dungeon->difficulty > DUNGEON_DIFFICULTY_NORMAL && (!mapEntry || !mapEntry->IsRaid()) && sInstanceSaveMgr->PlayerIsPermBoundToInstance(player->GetGUID(), dungeon->map, Difficulty(dungeon->difficulty)))
421 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))
423 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))
425 else if (dungeon->seasonal && !IsSeasonActive(dungeon->id))
427 else if (ar)
428 {
429 // Check required items
430 for (const ProgressionRequirement* itemRequirement : ar->items)
431 {
432 if (itemRequirement->faction == TEAM_NEUTRAL || itemRequirement->faction == player->GetTeamId(true))
433 {
434 if (!player->HasItemCount(itemRequirement->id, 1))
435 {
437 break;
438 }
439 }
440 }
441
442 //Check for quests
443 for (const ProgressionRequirement* questRequirement : ar->quests)
444 {
445 if (questRequirement->faction == TEAM_NEUTRAL || questRequirement->faction == player->GetTeamId(true))
446 {
447 if (!player->GetQuestRewardStatus(questRequirement->id))
448 {
450 break;
451 }
452 }
453 }
454
455 //Check for ilvl
456 if (ar->reqItemLevel && (float)ar->reqItemLevel > avgItemLevel)
457 {
459 }
460
461 //Check if player has the required achievements
462 for (const ProgressionRequirement* achievementRequirement : ar->achievements)
463 {
464 if (achievementRequirement->faction == TEAM_NEUTRAL || achievementRequirement->faction == player->GetTeamId(true))
465 {
466 if (!player->HasAchieved(achievementRequirement->id))
467 {
469 break;
470 }
471 }
472 }
473 }
474
475 sScriptMgr->OnInitializeLockedDungeons(player, level, lockData, dungeon);
476
477 /* TODO VoA closed if WG is not under team control (LFG_LOCKSTATUS_RAID_LOCKED)
478 lockData = LFG_LOCKSTATUS_TOO_LOW_GEAR_SCORE;
479 lockData = LFG_LOCKSTATUS_TOO_HIGH_GEAR_SCORE;
480 lockData = LFG_LOCKSTATUS_ATTUNEMENT_TOO_LOW_LEVEL;
481 lockData = LFG_LOCKSTATUS_ATTUNEMENT_TOO_HIGH_LEVEL;
482 */
483
484 if (lockData)
485 lock[dungeon->Entry()] = lockData;
486 }
487
488 sScriptMgr->OnAfterInitializeLockedDungeons(player);
489
490 SetLockedDungeons(guid, lock);
491 }
@ DISABLE_TYPE_MAP
Definition: DisableMgr.h:31
@ DISABLE_TYPE_LFG_MAP
Definition: DisableMgr.h:37
DBCStorage< MapEntry > sMapStore(MapEntryfmt)
#define sInstanceSaveMgr
Definition: InstanceSaveMgr.h:202
#define sScriptMgr
Definition: ScriptMgr.h:2690
@ CONFIG_DUNGEON_ACCESS_REQUIREMENTS_LFG_DBC_LEVEL_OVERRIDE
Definition: IWorld.h:180
Difficulty
Definition: DBCEnums.h:271
@ DUNGEON_DIFFICULTY_NORMAL
Definition: DBCEnums.h:274
@ TEAM_NEUTRAL
Definition: SharedDefines.h:734
bool IsDisabledFor(DisableType type, uint32 entry, Unit const *unit, uint8 flags)
Definition: DisableMgr.cpp:304
@ LFG_LOCKSTATUS_INSUFFICIENT_EXPANSION
Definition: LFG.h:84
@ LFG_LOCKSTATUS_TOO_LOW_LEVEL
Definition: LFG.h:85
@ LFG_LOCKSTATUS_RAID_LOCKED
Definition: LFG.h:89
@ LFG_LOCKSTATUS_TOO_LOW_GEAR_SCORE
Definition: LFG.h:87
@ LFG_LOCKSTATUS_MISSING_ITEM
Definition: LFG.h:93
@ LFG_LOCKSTATUS_TOO_HIGH_LEVEL
Definition: LFG.h:86
@ LFG_LOCKSTATUS_MISSING_ACHIEVEMENT
Definition: LFG.h:95
@ LFG_LOCKSTATUS_NOT_IN_SEASON
Definition: LFG.h:94
@ LFG_LOCKSTATUS_QUEST_NOT_COMPLETED
Definition: LFG.h:92
@ LFG_OPTION_ENABLE_SEASONAL_BOSSES
Definition: LFGMgr.h:43
void SetLockedDungeons(ObjectGuid guid, LfgLockMap const &lock)
Definition: LFGMgr.cpp:2512
LfgDungeonSet const & GetDungeonsByRandom(uint32 randomdungeon)
Definition: LFGMgr.cpp:2300
bool IsSeasonActive(uint32 dungeonId)
Checks if Seasonal dungeon is active.
Definition: LFGMgr.cpp:2735
Definition: Player.h:925
TeamId faction
Definition: Player.h:927
uint32 id
Definition: Player.h:926
Definition: Player.h:934
std::vector< ProgressionRequirement * > items
Definition: Player.h:939
std::vector< ProgressionRequirement * > quests
Definition: Player.h:938
uint8 levelMax
Definition: Player.h:936
uint8 levelMin
Definition: Player.h:935
uint16 reqItemLevel
Definition: Player.h:937
std::vector< ProgressionRequirement * > achievements
Definition: Player.h:940
float GetAverageItemLevelForDF()
Definition: Player.cpp:15435
bool GetQuestRewardStatus(uint32 quest_id) const
Definition: PlayerQuest.cpp:1392
bool HasItemCount(uint32 item, uint32 count=1, bool inBankAlso=false) const
Definition: PlayerStorage.cpp:688
TeamId GetTeamId(bool original=false) const
Definition: Player.h:2058
bool HasAchieved(uint32 achievementId) const
Definition: Player.cpp:13608
uint8 Expansion() const
Definition: WorldSession.h:371
Definition: DBCStructure.h:1308
bool IsRaid() const
Definition: DBCStructure.h:1337

References DungeonProgressionRequirements::achievements, 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(), ProgressionRequirement::faction, Player::GetAverageItemLevelForDF(), GetDungeonsByRandom(), Object::GetGUID(), Unit::getLevel(), GetLFGDungeon(), Player::GetQuestRewardStatus(), Player::GetSession(), Player::GetTeamId(), Player::HasAchieved(), Player::HasItemCount(), lfg::LFGDungeonData::id, ProgressionRequirement::id, DisableMgr::IsDisabledFor(), 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, 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.

2778 {
2779 if (!guid.IsGroup())
2780 guid = GetGroup(guid);
2781
2782 if (uint32 dungeonId = GetDungeon(guid, true))
2783 if (LFGDungeonData const* dungeon = GetLFGDungeon(dungeonId))
2784 if (uint32(dungeon->map) == map && dungeon->difficulty == difficulty)
2785 return true;
2786
2787 return false;
2788 }
ObjectGuid GetGroup(ObjectGuid guid)
Gets player group.
Definition: LFGMgr.cpp:2575

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

◆ instance()

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

References instance().

Referenced by instance().

◆ IsLfgGroup()

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

Check if given group guid is lfg.

2666 {
2667 return guid && guid.IsGroup() && GroupsStore[guid].IsLfgGroup();
2668 }

References GroupsStore, and ObjectGuid::IsGroup().

◆ isOptionEnabled()

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

Checks if given lfg option is enabled.

2715 {
2716 return m_options & option;
2717 }

References m_options.

Referenced by Update().

◆ IsSeasonActive()

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

Checks if Seasonal dungeon is active.

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

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, GroupReference::next(), 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

892 {
893 // pussywizard: client limit for comment length is 64 @ 3.3.5a
894 if (comment.size() > 64)
895 comment = comment.substr(0, 64);
896
897 RBEntryInfo entry(roles, comment);
898 for (LfgDungeonSet::const_iterator itr = dungeons.begin(); itr != dungeons.end(); ++itr)
899 if (GetLFGDungeon(*itr)) // ensure dungeon data exists for such dungeon id
900 {
901 RaidBrowserStore[player->GetTeamId()][*itr][player->GetGUID()] = entry;
902 RBUsedDungeonsStore[player->GetTeamId()].insert(*itr);
903 }
904 }
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

1337 {
1338 ObjectGuid pguid, gguid;
1339 if (guid.IsGroup())
1340 gguid = guid;
1341 else if (groupguid && groupguid.IsGroup())
1342 {
1343 pguid = guid;
1344 gguid = groupguid;
1345 }
1346 else
1347 {
1348 pguid = guid;
1349 gguid = GetGroup(guid);
1350 }
1351 if (!allowgroup)
1352 gguid.Clear();
1353
1354 if (pguid)
1355 for (lfg::LfgQueueContainer::iterator itr = QueuesStore.begin(); itr != QueuesStore.end(); ++itr)
1356 itr->second.RemoveFromQueue(pguid);
1357 if (gguid)
1358 for (lfg::LfgQueueContainer::iterator itr = QueuesStore.begin(); itr != QueuesStore.end(); ++itr)
1359 itr->second.RemoveFromQueue(gguid);
1360
1361 if (pguid && !gguid)
1362 {
1363 if (GetState(pguid) == LFG_STATE_QUEUED)
1364 {
1366 SetState(pguid, LFG_STATE_NONE);
1367 }
1368 }
1369 if (gguid)
1370 {
1371 if (GetState(gguid) == LFG_STATE_QUEUED)
1372 {
1373 SetState(gguid, LFG_STATE_NONE);
1374 const LfgGuidSet& players = GetPlayers(gguid);
1375 for (LfgGuidSet::const_iterator it = players.begin(); it != players.end(); ++it)
1376 {
1379 }
1380 }
1381 }
1382 }
@ LFG_STATE_NONE
Definition: LFG.h:71
@ LFG_UPDATETYPE_REMOVED_FROM_QUEUE
Definition: LFG.h:58
void SendLfgUpdateParty(ObjectGuid guid, LfgUpdateData const &data)
Definition: LFGMgr.cpp:2635
void SendLfgUpdatePlayer(ObjectGuid guid, LfgUpdateData const &data)
Definition: LFGMgr.cpp:2629
void Clear()
Definition: ObjectGuid.h:140

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
811 {
812 LOG_DEBUG("lfg", "LFGMgr::Leave: [{}]", guid.ToString());
813 ObjectGuid gguid = guid.IsGroup() ? guid : GetGroup(guid);
814 LfgState state = GetState(guid);
815 switch (state)
816 {
817 case LFG_STATE_QUEUED:
818 if (gguid)
819 {
820 LFGQueue& queue = GetQueue(gguid);
821 queue.RemoveFromQueue(gguid);
822 uint32 dungeonId = GetDungeon(gguid);
823 SetState(gguid, LFG_STATE_NONE);
824 const LfgGuidSet& players = GetPlayers(gguid);
825 for (LfgGuidSet::const_iterator it = players.begin(); it != players.end(); ++it)
826 {
829 }
830 if (Group* group = sGroupMgr->GetGroupByGUID(gguid.GetCounter()))
831 {
832 if (group->isLFGGroup())
833 {
834 SetDungeon(gguid, dungeonId);
835 }
836 }
837 }
838 else
839 {
840 LFGQueue& queue = GetQueue(guid);
841 queue.RemoveFromQueue(guid);
844 }
845 break;
847 if (gguid)
848 UpdateRoleCheck(gguid); // No player to update role = LFG_ROLECHECK_ABORTED
849 break;
851 {
852 // Remove from Proposals
853 LfgProposalContainer::iterator it = ProposalsStore.begin();
854 ObjectGuid pguid = gguid == guid ? GetLeader(gguid) : guid;
855 while (it != ProposalsStore.end())
856 {
857 LfgProposalPlayerContainer::iterator itPlayer = it->second.players.find(pguid);
858 if (itPlayer != it->second.players.end())
859 {
860 // Mark the player/leader of group who left as didn't accept the proposal
861 itPlayer->second.accept = LFG_ANSWER_DENY;
862 break;
863 }
864 ++it;
865 }
866
867 // Remove from queue - if proposal is found, RemoveProposal will call RemoveFromQueue
868 if (it != ProposalsStore.end())
870 break;
871 }
872 case LFG_STATE_NONE:
873 break;
876 case LFG_STATE_BOOT:
877 if (guid != gguid) // Player
879 break;
881 LeaveRaidBrowser(guid);
882 SetCanOverrideRBState(guid, true);
884 SetCanOverrideRBState(guid, false);
887 break;
888 }
889 }
#define sGroupMgr
Definition: GroupMgr.h:51
@ LFG_UPDATETYPE_PROPOSAL_DECLINED
Definition: LFG.h:60
@ LFG_UPDATETYPE_LEAVE_RAIDBROWSER
Definition: LFG.h:53
void LeaveRaidBrowser(ObjectGuid guid)
Definition: LFGMgr.cpp:906
void RemoveProposal(LfgProposalContainer::iterator itProposal, LfgUpdateType type)
Definition: LFGMgr.cpp:1902
void SetCanOverrideRBState(ObjectGuid guid, bool val)
Definition: LFGMgr.cpp:2470

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)
907 {
908 for (uint8 team = 0; team < 2; ++team)
909 for (RBStoreMap::iterator itr = RaidBrowserStore[team].begin(); itr != RaidBrowserStore[team].end(); ++itr)
910 itr->second.erase(guid);
911 }

References RaidBrowserStore.

Referenced by LeaveLfg().

◆ LfrSearchAdd()

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

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

◆ LfrSearchRemove()

void lfg::LFGMgr::LfrSearchRemove ( Player p)
946 {
947 RBSearchersStore[p->GetTeamId()].erase(p->GetGUID());
948 }

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

◆ LfrSetComment()

void lfg::LFGMgr::LfrSetComment ( Player p,
std::string  comment 
)
2494 {
2495 // pussywizard: client limit for comment length is 64 @ 3.3.5a
2496 if (comment.size() > 64)
2497 comment = comment.substr(0, 64);
2498
2499 uint8 teamId = p->GetTeamId();
2500 RBEntryInfoMap::iterator iter;
2501 for (RBStoreMap::iterator itr = RaidBrowserStore[teamId].begin(); itr != RaidBrowserStore[teamId].end(); ++itr)
2502 if ((iter = itr->second.find(p->GetGUID())) != itr->second.end())
2503 iter->second.comment = comment;
2504 }

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

◆ LoadLFGDungeons()

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

Loads dungeons from dbc and adds teleport coords.

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

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::type, 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.

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

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
1574 {
1575 LfgGuidList players;
1576 GuidUnorderedSet playersToTeleport;
1577
1578 for (LfgProposalPlayerContainer::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it)
1579 {
1580 ObjectGuid guid = it->first;
1581 if (guid == proposal.leader)
1582 players.push_front(guid);
1583 else
1584 players.push_back(guid);
1585
1586 if (proposal.isNew || GetGroup(guid) != proposal.group)
1587 playersToTeleport.insert(guid);
1588 }
1589
1590 // Set the dungeon difficulty
1591 LFGDungeonData const* dungeon = GetLFGDungeon(proposal.dungeonId);
1592 ASSERT(dungeon);
1593
1594 bool isPremadeGroup = false;
1595 Group* grp = proposal.group ? sGroupMgr->GetGroupByGUID(proposal.group.GetCounter()) : nullptr;
1596 if (!grp)
1597 {
1598 ObjectGuid groupGUID;
1599 for (ObjectGuid const& guid : players)
1600 {
1601 if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
1602 {
1603 Group* group = player->GetGroup();
1604 if (!group || (groupGUID && groupGUID != group->GetGUID()))
1605 {
1606 isPremadeGroup = false;
1607 break;
1608 }
1609
1610 groupGUID = group->GetGUID();
1611 isPremadeGroup = true;
1612 }
1613 }
1614 }
1615
1616 ObjectGuid oldGroupGUID;
1617 for (LfgGuidList::const_iterator it = players.begin(); it != players.end(); ++it)
1618 {
1619 ObjectGuid pguid = (*it);
1621 if (!player)
1622 continue;
1623
1624 Group* group = player->GetGroup();
1625 if (isPremadeGroup && !grp)
1626 {
1627 oldGroupGUID = group->GetGUID();
1628 grp = group;
1629 grp->ConvertToLFG(false);
1631 }
1632
1633 // Xinef: Apply Random Buff
1634 if (grp && !grp->IsLfgWithBuff())
1635 {
1636 if (!group || group->GetGUID() != oldGroupGUID)
1637 grp->AddLfgBuffFlag();
1638 else
1639 oldGroupGUID = group->GetGUID();
1640 }
1641
1642 // Xinef: Store amount of random players player grouped with
1643 if (group)
1644 {
1646 oldGroupGUID = group->GetGUID();
1647 if (group != grp)
1648 group->RemoveMember(player->GetGUID());
1649 }
1650 else
1652
1653 if (!grp)
1654 {
1655 grp = new Group();
1656 grp->ConvertToLFG();
1657 grp->Create(player);
1658 ObjectGuid gguid = grp->GetGUID();
1660 sGroupMgr->AddGroup(grp);
1661 }
1662 else if (group != grp)
1663 {
1664 // pussywizard:
1665 if (!grp->IsFull())
1666 grp->AddMember(player);
1667 //else // some cleanup? LeaveLFG?
1668 // ;
1669 }
1670
1671 grp->SetLfgRoles(pguid, proposal.players.find(pguid)->second.role);
1672 }
1673
1674 // pussywizard: crashfix, group wasn't created when iterating players (no player found by guid), proposal is deleted by the calling function
1675 if (!grp)
1676 return;
1677
1678 grp->SetDungeonDifficulty(Difficulty(dungeon->difficulty));
1679 ObjectGuid gguid = grp->GetGUID();
1680 SetDungeon(gguid, dungeon->Entry());
1682
1683 _SaveToDB(gguid);
1684
1685 // Select a player inside to be teleported to
1686 WorldLocation const* teleportLocation = nullptr;
1687 bool leaderTeleportIncluded = false;
1688 for (GroupReference* itr = grp->GetFirstMember(); itr != nullptr; itr = itr->next())
1689 {
1690 if (Player* plr = itr->GetSource())
1691 {
1692 if (grp->IsLeader(plr->GetGUID()) && playersToTeleport.find(plr->GetGUID()) != playersToTeleport.end())
1693 {
1694 leaderTeleportIncluded = true;
1695 }
1696
1697 if (plr->GetMapId() == uint32(dungeon->map) && !proposal.isNew)
1698 {
1699 teleportLocation = plr;
1700 break;
1701 }
1702
1703 // Remove from battleground queues
1704 for (uint8 i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
1705 {
1706 if (BattlegroundQueueTypeId bgQueueTypeId = plr->GetBattlegroundQueueTypeId(i))
1707 {
1708 if (bgQueueTypeId != BATTLEGROUND_QUEUE_NONE)
1709 {
1710 plr->RemoveBattlegroundQueueId(bgQueueTypeId);
1711 sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId).RemovePlayer(plr->GetGUID(), true);
1712 }
1713 }
1714 }
1715 }
1716 }
1717
1718 bool randomDungeon = false;
1719 std::vector<Player*> playersTeleported;
1720 // Teleport Player
1721 for (GuidUnorderedSet::const_iterator it = playersToTeleport.begin(); it != playersToTeleport.end(); ++it)
1722 {
1723 if (Player* player = ObjectAccessor::FindPlayer(*it))
1724 {
1725 if (player->GetGroup() != grp) // pussywizard: could not add because group was full
1726 continue;
1727
1728 // Add the cooldown spell if queued for a random dungeon
1729 // xinef: add aura
1730 if ((randomDungeon || selectedRandomLfgDungeon(player->GetGUID())) && !player->HasAura(LFG_SPELL_DUNGEON_COOLDOWN))
1731 {
1732 randomDungeon = true;
1733 // if player is debugging, don't add dungeon cooldown
1734 if (!m_Testing)
1735 {
1736 player->AddAura(LFG_SPELL_DUNGEON_COOLDOWN, player);
1737 }
1738 }
1739
1740 if (player->GetMapId() == uint32(dungeon->map))
1741 {
1742 // check instance id with leader
1743 if (!leaderTeleportIncluded)
1744 {
1745 if (InstancePlayerBind* ilb = sInstanceSaveMgr->PlayerGetBoundInstance(grp->GetLeaderGUID(), dungeon->map, player->GetDungeonDifficulty()))
1746 {
1747 if (player->GetInstanceId() == ilb->save->GetInstanceId())
1748 {
1749 // Do not teleport if in the same map and instance as leader
1750 continue;
1751 }
1752 }
1753 }
1754
1755 // Remove bind to that map
1756 sInstanceSaveMgr->PlayerUnbindInstance(player->GetGUID(), dungeon->map, player->GetDungeonDifficulty(), true);
1757 }
1758 else
1759 {
1760 // RDF removes all binds to that map
1761 if (randomDungeon && !sInstanceSaveMgr->PlayerIsPermBoundToInstance(player->GetGUID(), dungeon->map, player->GetDungeonDifficulty()))
1762 {
1763 sInstanceSaveMgr->PlayerUnbindInstance(player->GetGUID(), dungeon->map, player->GetDungeonDifficulty(), true);
1764 }
1765 }
1766
1767 playersTeleported.push_back(player);
1768 }
1769 }
1770
1771 for (Player* player : playersTeleported)
1772 {
1773 TeleportPlayer(player, false, teleportLocation);
1774 }
1775
1776 if (randomDungeon)
1778 if (Difficulty(dungeon->difficulty) == DUNGEON_DIFFICULTY_HEROIC)
1779 grp->AddLfgHeroicFlag();
1780
1781 // Update group info
1782 grp->SendUpdate();
1783 }
#define ASSERT
Definition: Errors.h:68
#define sBattlegroundMgr
Definition: BattlegroundMgr.h:188
std::unordered_set< ObjectGuid > GuidUnorderedSet
Definition: ObjectGuid.h:259
BattlegroundQueueTypeId
Definition: SharedDefines.h:3591
@ BATTLEGROUND_QUEUE_NONE
Definition: SharedDefines.h:3592
#define PLAYER_MAX_BATTLEGROUND_QUEUES
Definition: SharedDefines.h:148
GuidList LfgGuidList
Definition: LFG.h:113
void TeleportPlayer(Player *player, bool out, WorldLocation const *teleportLocation=nullptr)
Teleport a player to/from selected dungeon.
Definition: LFGMgr.cpp:2108
bool selectedRandomLfgDungeon(ObjectGuid guid)
Check if given guid applied for random dungeon.
Definition: LFGMgr.cpp:2761
void SetRandomPlayersCount(ObjectGuid guid, uint8 count)
Xinef: Set Random Players Count.
Definition: LFGMgr.cpp:2600
uint32 GetInstanceId() const
Definition: Object.h:431
Definition: Position.h:251
Difficulty GetDungeonDifficulty() const
Definition: Player.h:1870
Aura * AddAura(uint32 spellId, Unit *target)
Definition: Unit.cpp:19751
void AddLfgRandomInstanceFlag()
Definition: Group.h:308
void SetDungeonDifficulty(Difficulty difficulty)
Definition: Group.cpp:2013
void SetLfgRoles(ObjectGuid guid, const uint8 roles)
Definition: Group.cpp:2190
bool AddMember(Player *player)
Definition: Group.cpp:390
bool IsLeader(ObjectGuid guid) const
Definition: Group.cpp:2276
void SendUpdate()
Definition: Group.cpp:1633
bool IsLfgWithBuff() const
Definition: Group.h:310
bool RemoveMember(ObjectGuid guid, const RemoveMethod &method=GROUP_REMOVEMETHOD_DEFAULT, ObjectGuid kicker=ObjectGuid::Empty, const char *reason=nullptr)
Definition: Group.cpp:546
void AddLfgBuffFlag()
Definition: Group.h:307
void ConvertToLFG(bool restricted=true)
Definition: Group.cpp:260
void AddLfgHeroicFlag()
Definition: Group.h:309
bool Create(Player *leader)
Definition: Group.cpp:108
bool IsFull() const
Definition: Group.cpp:2200
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, GroupReference::next(), 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 
)
1226 {
1227 buffer << info.groupGuid;
1229 buffer << (uint32)flags;
1230 if (flags & LFG_UPDATE_FLAG_COMMENT)
1231 buffer << info.comment;
1232 if (flags & LFG_UPDATE_FLAG_ROLES)
1233 for (uint8 j = 0; j < 3; ++j)
1234 buffer << (uint8)0;
1235 if (!(flags & LFG_UPDATE_FLAG_BINDED))
1236 return;
1237 buffer << info.instanceGuid;
1238 buffer << (uint32)info.encounterMask;
1239 }
@ 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 
)
1242 {
1243 buffer << info.guid;
1244 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);
1245 buffer << (uint32)flags;
1246
1248 {
1249 buffer << (uint8)info._level;
1250 buffer << (uint8)info._class;
1251 buffer << (uint8)info._race;
1252 buffer << (uint8)info._talents0;
1253 buffer << (uint8)info._talents1;
1254 buffer << (uint8)info._talents2;
1255 buffer << (uint32)info._armor;
1256 buffer << (uint32)info._spellDamage;
1257 buffer << (uint32)info._spellHeal;
1258 buffer << (uint32)info._critRatingMelee;
1259 buffer << (uint32)info._critRatingRanged;
1260 buffer << (uint32)info._critRatingSpell;
1261 buffer << (float)info._mp5;
1262 buffer << (float)info._mp5combat;
1263 buffer << (uint32)info._attackPower;
1264 buffer << (uint32)info._agility;
1265 buffer << (uint32)info._health;
1266 buffer << (uint32)info._mana;
1267 buffer << (uint32)info._online; // talentpoints, used as online/offline marker :D
1268 buffer << (float)info._avgItemLevel; // avgitemlevel
1269 buffer << (uint32)info._defenseSkill;
1270 buffer << (uint32)info._dodgeRating;
1271 buffer << (uint32)info._blockRating;
1272 buffer << (uint32)info._parryRating;
1273 buffer << (uint32)info._hasteRating;
1274 buffer << (uint32)info._expertiseRating;
1275 }
1276
1277 if (flags & LFG_UPDATE_FLAG_COMMENT)
1278 buffer << (info.groupGuid ? std::string("") : info.comment);
1279 if (flags & LFG_UPDATE_FLAG_GROUPLEADER)
1280 buffer << (uint8)1; // isLFM
1281 if (flags & LFG_UPDATE_FLAG_GROUPGUID)
1282 buffer << info.groupGuid;
1283 if (flags & LFG_UPDATE_FLAG_ROLES)
1284 buffer << (uint8)(info.groupGuid ? (info.isGroupLeader ? PLAYER_ROLE_LEADER : 0) : info.roles);
1285 if (flags & LFG_UPDATE_FLAG_AREA)
1286 buffer << (uint32)info._area;
1287 if (flags & LFG_UPDATE_FLAG_STATUS)
1288 buffer << (uint8)0;
1289 if (!(flags & LFG_UPDATE_FLAG_BINDED))
1290 return;
1291 buffer << info.instanceGuid;
1292 buffer << (uint32)info.encounterMask;
1293 }
@ 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 
)
1296 {
1297 differencePacket << (uint32)LFG_TYPE_RAID;
1298 differencePacket << (uint32)dungeonId;
1299 differencePacket << (uint8)1;
1300 differencePacket << (uint32)deletedCounter;
1301 differencePacket.append(buffer_deleted);
1302 differencePacket << (uint32)groupCounter;
1303 differencePacket << (uint32)0;
1304 differencePacket.append(buffer_groups);
1305 differencePacket << (uint32)playerCounter;
1306 differencePacket << (uint32)0;
1307 differencePacket.append(buffer_players);
1308 }
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 
)
1311 {
1312 fullPacket << (uint32)LFG_TYPE_RAID;
1313 fullPacket << (uint32)dungeonId;
1314 fullPacket << (uint8)0;
1315 uint32 groupCounter = 0, playerCounter = 0;
1316 ByteBuffer buffer_groups, buffer_players;
1317 for (RBInternalInfoMap::const_iterator itr = infoMap.begin(); itr != infoMap.end(); ++itr)
1318 {
1319 if (itr->second.isGroupLeader)
1320 {
1321 ++groupCounter;
1322 RBPacketAppendGroup(itr->second, buffer_groups);
1323 }
1324 ++playerCounter;
1325 RBPacketAppendPlayer(itr->second, buffer_players);
1326 }
1327 fullPacket << (uint32)groupCounter;
1328 fullPacket << (uint32)0;
1329 fullPacket.append(buffer_groups);
1330 fullPacket << (uint32)playerCounter;
1331 fullPacket << (uint32)0;
1332 fullPacket.append(buffer_players);
1333 }
void RBPacketAppendGroup(const RBInternalInfo &info, ByteBuffer &buffer)
Definition: LFGMgr.cpp:1225
void RBPacketAppendPlayer(const RBInternalInfo &info, ByteBuffer &buffer)
Definition: LFGMgr.cpp:1241
Definition: ByteBuffer.h:70

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

Referenced by UpdateRaidBrowser().

◆ RemoveGroupData()

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

Removes saved group data.

2525 {
2526 LOG_DEBUG("lfg", "LFGMgr::RemoveGroupData: [{}]", guid.ToString());
2527 LfgGroupDataContainer::iterator it = GroupsStore.find(guid);
2528 if (it == GroupsStore.end())
2529 return;
2530
2531 LfgState state = GetState(guid);
2532 // If group is being formed after proposal success do nothing more
2533 LfgGuidSet const& players = it->second.GetPlayers();
2534 for (auto iterator = players.begin(); iterator != players.end(); ++iterator)
2535 {
2536 ObjectGuid objectGuid = (*iterator);
2537 SetGroup(*iterator, ObjectGuid::Empty);
2538 if (state != LFG_STATE_PROPOSAL)
2539 {
2540 SetState(*iterator, LFG_STATE_NONE);
2541 SendLfgUpdateParty(objectGuid, LfgUpdateData(LFG_UPDATETYPE_REMOVED_FROM_QUEUE));
2542 }
2543 }
2544 GroupsStore.erase(it);
2545 }
void SetGroup(ObjectGuid guid, ObjectGuid group)
Sets player group.
Definition: LFGMgr.cpp:2580

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.

2553 {
2554 return GroupsStore[gguid].RemovePlayer(guid);
2555 }

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

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
2420 {
2421 if (guid.IsGroup())
2422 {
2423 LfgGroupData& data = GroupsStore[guid];
2424 /*if (sLog->ShouldLog(LOG_FILTER_LFG, LOG_LEVEL_DEBUG))
2425 {
2426 std::string const& ps = GetStateString(data.GetState());
2427 std::string const& os = GetStateString(data.GetOldState());
2428 LOG_TRACE("lfg", "LFGMgr::RestoreState: Group: [{}] ({}) State: {}, oldState: {}",
2429 guid.ToString(), debugMsg, ps, os);
2430 }*/
2431
2432 data.RestoreState();
2433 }
2434 else
2435 {
2436 LfgPlayerData& data = PlayersStore[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: Player: [{}] ({}) State: {}, oldState: {}",
2442 guid.ToString(), debugMsg, ps, os);
2443 }*/
2444 data.RestoreState();
2445 }
2446 }

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.

2762 {
2763 if (GetState(guid) != LFG_STATE_NONE)
2764 {
2765 LfgDungeonSet const& dungeons = GetSelectedDungeons(guid);
2766 if (!dungeons.empty())
2767 {
2768 LFGDungeonData const* dungeon = GetLFGDungeon(*dungeons.begin());
2769 if (dungeon && (dungeon->type == LFG_TYPE_RANDOM || dungeon->seasonal))
2770 return true;
2771 }
2772 }
2773
2774 return false;
2775 }

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
2648 {
2649 if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
2650 player->GetSession()->SendLfgBootProposalUpdate(boot);
2651 }

References ObjectAccessor::FindConnectedPlayer().

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

◆ SendLfgJoinResult()

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

References ObjectAccessor::FindConnectedPlayer().

Referenced by Update(), and UpdateRoleCheck().

◆ SendLfgQueueStatus()

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

Sends queue status to player.

2660 {
2661 if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
2662 player->GetSession()->SendLfgQueueStatus(data);
2663 }

References ObjectAccessor::FindConnectedPlayer().

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

◆ SendLfgRoleCheckUpdate()

void lfg::LFGMgr::SendLfgRoleCheckUpdate ( ObjectGuid  guid,
LfgRoleCheck const &  roleCheck 
)
private
2624 {
2625 if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
2626 player->GetSession()->SendLfgRoleCheckUpdate(roleCheck);
2627 }

References ObjectAccessor::FindConnectedPlayer().

Referenced by Update(), and UpdateRoleCheck().

◆ SendLfgRoleChosen()

void lfg::LFGMgr::SendLfgRoleChosen ( ObjectGuid  guid,
ObjectGuid  pguid,
uint8  roles 
)
private
2618 {
2619 if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
2620 player->GetSession()->SendLfgRoleChosen(pguid, roles);
2621 }

References ObjectAccessor::FindConnectedPlayer().

Referenced by UpdateRoleCheck().

◆ SendLfgUpdateParty()

void lfg::LFGMgr::SendLfgUpdateParty ( ObjectGuid  guid,
LfgUpdateData const &  data 
)
private
2636 {
2637 if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
2638 player->GetSession()->SendLfgUpdateParty(data);
2639 }

References ObjectAccessor::FindConnectedPlayer().

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

◆ SendLfgUpdatePlayer()

void lfg::LFGMgr::SendLfgUpdatePlayer ( ObjectGuid  guid,
LfgUpdateData const &  data 
)
private
2630 {
2631 if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
2632 player->GetSession()->SendLfgUpdatePlayer(data);
2633 }

References ObjectAccessor::FindConnectedPlayer().

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

◆ SendLfgUpdateProposal()

void lfg::LFGMgr::SendLfgUpdateProposal ( ObjectGuid  guid,
LfgProposal const &  proposal 
)
private
2654 {
2655 if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
2656 player->GetSession()->SendLfgUpdateProposal(proposal);
2657 }

References ObjectAccessor::FindConnectedPlayer().

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

◆ SendRaidBrowserCachedList()

void lfg::LFGMgr::SendRaidBrowserCachedList ( Player player,
uint32  dungeonId 
)
951 {
952 RBCacheMap::iterator itr = RBCacheStore[player->GetTeamId()].find(dungeonId);
953 if (itr != RBCacheStore[player->GetTeamId()].end())
954 {
955 player->GetSession()->SendPacket(&(itr->second));
956 return;
957 }
958 // send empty packet if cache not found
960 data << (uint32)LFG_TYPE_RAID;
961 data << (uint32)dungeonId;
962 data << (uint8)0;
963 data << (uint32)0;
964 data << (uint32)0;
965 data << (uint32)0;
966 data << (uint32)0;
967 player->GetSession()->SendPacket(&data);
968 }
@ SMSG_UPDATE_LFG_LIST
Definition: Opcodes.h:894
RBCacheMap RBCacheStore[2]
Definition: LFGMgr.h:432
Definition: WorldPacket.h:27
void SendPacket(WorldPacket const *packet)
Send a packet to the client.
Definition: WorldSession.cpp:208

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 
)
914 {
915 if (dungeons.empty())
916 {
917 RBEntryInfoMap::iterator iter;
918 uint8 team = p->GetTeamId();
919 bool setComment = true;
920 for (RBStoreMap::iterator itr = RaidBrowserStore[team].begin(); itr != RaidBrowserStore[team].end(); ++itr)
921 if ((iter = itr->second.find(p->GetGUID())) != itr->second.end())
922 {
923 dungeons.insert(itr->first);
924 if (setComment)
925 {
926 comment = iter->second.comment;
927 setComment = false;
928 }
929 }
930 }
931 LfgJoinResultData joinData;
932 p->GetSession()->SendLfgJoinResult(joinData);
933 LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_JOIN_RAIDBROWSER, dungeons, comment);
934 if (p->GetGroup())
935 p->GetSession()->SendLfgUpdateParty(updateData);
936 else
937 p->GetSession()->SendLfgUpdatePlayer(updateData);
938 }
@ LFG_UPDATETYPE_JOIN_RAIDBROWSER
Definition: LFG.h:54
void SendLfgUpdateParty(lfg::LfgUpdateData const &updateData)
Definition: LFGHandler.cpp:330

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
2471 {
2472 PlayersStore[guid].SetCanOverrideRBState(val);
2473 }

References PlayersStore.

Referenced by LeaveLfg().

◆ SetComment()

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

Sets player lfr comment.

2488 {
2489 LOG_DEBUG("lfg", "LFGMgr::SetComment: [{}] comment: {}", guid.ToString(), comment);
2490 PlayersStore[guid].SetComment(comment);
2491 }

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

Referenced by JoinLfg().

◆ SetDungeon()

void lfg::LFGMgr::SetDungeon ( ObjectGuid  guid,
uint32  dungeon 
)
2476 {
2477 LOG_DEBUG("lfg", "LFGMgr::SetDungeon: [{}] dungeon {}", guid.ToString(), dungeon);
2478 GroupsStore[guid].SetDungeon(dungeon);
2479 }

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.

2581 {
2582 PlayersStore[guid].SetGroup(group);
2583 }

References PlayersStore.

Referenced by RemoveGroupData(), and SetupGroupMember().

◆ SetLeader()

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

Sets the leader of the group.

2563 {
2564 GroupsStore[gguid].SetLeader(leader);
2565 }

References GroupsStore.

Referenced by _LoadFromDB().

◆ SetLockedDungeons()

void lfg::LFGMgr::SetLockedDungeons ( ObjectGuid  guid,
LfgLockMap const &  lock 
)
private
2513 {
2514 LOG_DEBUG("lfg", "LFGMgr::SetLockedDungeons: [{}]", guid.ToString());
2515 PlayersStore[guid].SetLockedDungeons(lock);
2516 }

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

Referenced by InitializeLockedDungeons().

◆ SetOptions()

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

Sets new lfg options.

2725 {
2726 m_options = options;
2727 }

References m_options.

◆ SetRandomPlayersCount()

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

Xinef: Set Random Players Count.

2601 {
2602 PlayersStore[guid].SetRandomPlayersCount(count);
2603 }

References PlayersStore.

Referenced by MakeNewGroup().

◆ SetRoles()

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

Sets player lfg roles.

2482 {
2483 LOG_DEBUG("lfg", "LFGMgr::SetRoles: [{}] roles: {}", guid.ToString(), roles);
2484 PlayersStore[guid].SetRoles(roles);
2485 }

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

Referenced by JoinLfg(), and UpdateRoleCheck().

◆ SetSelectedDungeons()

void lfg::LFGMgr::SetSelectedDungeons ( ObjectGuid  guid,
LfgDungeonSet const &  dungeons 
)
private
2507 {
2508 LOG_DEBUG("lfg", "LFGMgr::SetLockedDungeons: [{}]", guid.ToString());
2509 PlayersStore[guid].SetSelectedDungeons(dungeons);
2510 }

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

Referenced by JoinLfg(), and SetupGroupMember().

◆ SetState()

void lfg::LFGMgr::SetState ( ObjectGuid  guid,
LfgState  state 
)
private
2449 {
2450 if (guid.IsGroup())
2451 {
2452 LfgGroupData& data = GroupsStore[guid];
2453 std::string ns = GetStateString(state);
2454 std::string ps = GetStateString(data.GetState());
2455 std::string os = GetStateString(data.GetOldState());
2456 LOG_DEBUG("lfg", "LFGMgr::SetState: Group: [{}] newState: {}, previous: {}, oldState: {}", guid.ToString(), ns, ps, os);
2457 data.SetState(state);
2458 }
2459 else
2460 {
2461 LfgPlayerData& data = PlayersStore[guid];
2462 std::string ns = GetStateString(state);
2463 std::string ps = GetStateString(data.GetState());
2464 std::string os = GetStateString(data.GetOldState());
2465 LOG_DEBUG("lfg", "LFGMgr::SetState: Player: [{}] newState: {}, previous: {}, oldState: {}", guid.ToString(), ns, ps, os);
2466 data.SetState(state);
2467 }
2468 }
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.

2568 {
2570 teamId = TEAM_ALLIANCE; // @Not Sure About That TeamId is supposed to be uint8 Team = 0(@TrinityCore)
2571
2572 PlayersStore[guid].SetTeam(teamId);
2573 }
@ CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP
Definition: IWorld.h:92
@ TEAM_ALLIANCE
Definition: SharedDefines.h:732

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.

2752 {
2753 LfgDungeonSet dungeons;
2754 dungeons.insert(GetDungeon(gguid));
2755 SetSelectedDungeons(guid, dungeons);
2756 SetState(guid, GetState(gguid));
2757 SetGroup(guid, gguid);
2758 AddPlayerToGroup(gguid, guid);
2759 }
void AddPlayerToGroup(ObjectGuid gguid, ObjectGuid guid)
Adds player to group.
Definition: LFGMgr.cpp:2557

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)
2109 {
2110 LFGDungeonData const* dungeon = nullptr;
2111 Group* group = player->GetGroup();
2112
2113 if (group && group->isLFGGroup())
2114 dungeon = GetLFGDungeon(GetDungeon(group->GetGUID()));
2115
2116 if (!dungeon)
2117 {
2119 return;
2120 }
2121
2122 if (out)
2123 {
2124 if (player->GetMapId() == uint32(dungeon->map))
2125 player->TeleportToEntryPoint();
2126
2127 return;
2128 }
2129
2131
2132 if (!player->IsAlive())
2133 {
2135 }
2136 else if (player->IsFalling() || player->HasUnitState(UNIT_STATE_JUMPING))
2137 {
2139 }
2140 else if (player->IsMirrorTimerActive(FATIGUE_TIMER))
2141 {
2143 }
2144 else if (player->GetVehicle())
2145 {
2147 }
2148 else if (player->GetCharmGUID() || player->IsInCombat())
2149 {
2151 }
2152 else
2153 {
2154 uint32 mapid = dungeon->map;
2155 float x = dungeon->x;
2156 float y = dungeon->y;
2157 float z = dungeon->z;
2158 float orientation = dungeon->o;
2159
2160 if (teleportLocation)
2161 {
2162 teleportLocation->GetWorldLocation(mapid, x, y, z, orientation);
2163 }
2164
2165 if (!player->GetMap()->IsDungeon() || player->GetEntryPoint().GetMapId() == MAPID_INVALID)
2166 {
2167 player->SetEntryPoint();
2168 }
2169
2170 if (!player->TeleportTo(mapid, x, y, z, orientation, 0, nullptr, mapid == player->GetMapId()))
2171 {
2173 }
2174 }
2175
2176 if (error != LFG_TELEPORTERROR_OK)
2177 player->GetSession()->SendLfgTeleportError(uint8(error));
2178
2179 //LOG_DEBUG("lfg", "TeleportPlayer: Player {} is being teleported in to map {} "
2180 // "(x: {}, y: {}, z: {}) Result: {}", player->GetName(), dungeon->map,
2181 // dungeon->x, dungeon->y, dungeon->z, error);
2182 }
#define MAPID_INVALID
Definition: Position.h:248
@ FATIGUE_TIMER
Definition: Player.h:575
@ UNIT_STATE_JUMPING
Definition: Unit.h:343
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
Map * GetMap() const
Definition: Object.h:517
void SetEntryPoint()
Definition: Player.cpp:11026
bool IsMirrorTimerActive(MirrorTimerType type)
Definition: Player.h:2011
bool TeleportToEntryPoint()
Definition: Player.cpp:1580
WorldLocation const & GetEntryPoint() const
Definition: Player.h:2326
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options=0, Unit *target=nullptr, bool newInstance=false)
Definition: Player.cpp:1313
bool IsFalling() const
Definition: Player.cpp:2123
Vehicle * GetVehicle() const
Definition: Unit.h:2622
bool IsAlive() const
Definition: Unit.h:2024
ObjectGuid GetCharmGUID() const
Definition: Unit.h:2038
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1398
bool IsInCombat() const
Definition: Unit.h:1724
bool IsDungeon() const
Definition: Map.h:447
void SendLfgTeleportError(uint8 err)
Definition: LFGHandler.cpp:605

References FATIGUE_TIMER, Unit::GetCharmGUID(), GetDungeon(), Player::GetEntryPoint(), Player::GetGroup(), Group::GetGUID(), GetLFGDungeon(), WorldObject::GetMap(), WorldLocation::GetMapId(), 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, 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 ( )
799 {
802 }
@ LANG_DEBUG_LFG_ON
Definition: Language.h:1333
@ LANG_DEBUG_LFG_OFF
Definition: Language.h:1334

References LANG_DEBUG_LFG_OFF, LANG_DEBUG_LFG_ON, m_Testing, and sWorld.

◆ Update()

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

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
2046 {
2047 ObjectGuid gguid = GetGroup(guid);
2048 if (!gguid)
2049 return;
2050
2051 LfgPlayerBootContainer::iterator itBoot = BootsStore.find(gguid);
2052 if (itBoot == BootsStore.end())
2053 return;
2054
2055 LfgPlayerBoot& boot = itBoot->second;
2056
2057 if (boot.votes[guid] != LFG_ANSWER_PENDING) // Cheat check: Player can't vote twice
2058 return;
2059
2060 boot.votes[guid] = LfgAnswer(accept);
2061
2062 uint8 votesNum = 0;
2063 uint8 agreeNum = 0;
2064 for (LfgAnswerContainer::const_iterator itVotes = boot.votes.begin(); itVotes != boot.votes.end(); ++itVotes)
2065 {
2066 if (itVotes->second != LFG_ANSWER_PENDING)
2067 {
2068 ++votesNum;
2069 if (itVotes->second == LFG_ANSWER_AGREE)
2070 ++agreeNum;
2071 }
2072 }
2073
2074 // if we don't have enough votes (agree or deny) do nothing
2075 if (agreeNum < LFG_GROUP_KICK_VOTES_NEEDED && (votesNum - agreeNum) < LFG_GROUP_KICK_VOTES_NEEDED)
2076 return;
2077
2078 // Send update info to all players
2079 boot.inProgress = false;
2080 for (LfgAnswerContainer::const_iterator itVotes = boot.votes.begin(); itVotes != boot.votes.end(); ++itVotes)
2081 {
2082 ObjectGuid pguid = itVotes->first;
2083 if (pguid != boot.victim)
2084 {
2086 SendLfgBootProposalUpdate(pguid, boot);
2087 }
2088 }
2089
2091 if (agreeNum == LFG_GROUP_KICK_VOTES_NEEDED) // Vote passed - Kick player
2092 {
2093 if (Group* group = sGroupMgr->GetGroupByGUID(gguid.GetCounter()))
2095
2096 DecreaseKicksLeft(gguid);
2097 }
2098 BootsStore.erase(itBoot);
2099 }
@ GROUP_REMOVEMETHOD_KICK_LFG
Definition: SharedDefines.h:3562
@ LFG_GROUP_KICK_VOTES_NEEDED
Definition: LFGMgr.h:55
LfgAnswer
Answer state (Also used to check compatibilites)
Definition: LFG.h:100
void DecreaseKicksLeft(ObjectGuid guid)
Definition: LFGMgr.cpp:2518
static void RemoveFromGroup(Group *group, ObjectGuid guid, RemoveMethod method=GROUP_REMOVEMETHOD_DEFAULT, ObjectGuid kicker=ObjectGuid::Empty, const char *reason=nullptr)
Definition: Player.cpp:2309

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
1800 {
1801 // Check if the proposal exists
1802 LfgProposalContainer::iterator itProposal = ProposalsStore.find(proposalId);
1803 if (itProposal == ProposalsStore.end())
1804 return;
1805
1806 LfgProposal& proposal = itProposal->second;
1807
1808 // Check if proposal have the current player
1809 LfgProposalPlayerContainer::iterator itProposalPlayer = proposal.players.find(guid);
1810 if (itProposalPlayer == proposal.players.end())
1811 return;
1812
1813 LfgProposalPlayer& player = itProposalPlayer->second;
1814 player.accept = LfgAnswer(accept);
1815
1816 LOG_DEBUG("lfg", "LFGMgr::UpdateProposal: Player [{}] of proposal {} selected: {}", guid.ToString(), proposalId, accept);
1817 if (!accept)
1818 {
1820 return;
1821 }
1822
1823 // check if all have answered and reorder players (leader first)
1824 bool allAnswered = true;
1825 for (LfgProposalPlayerContainer::const_iterator itPlayers = proposal.players.begin(); itPlayers != proposal.players.end(); ++itPlayers)
1826 if (itPlayers->second.accept != LFG_ANSWER_AGREE) // No answer (-1) or not accepted (0)
1827 allAnswered = false;
1828
1829 if (!m_Testing && !allAnswered)
1830 {
1831 for (LfgProposalPlayerContainer::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it)
1832 SendLfgUpdateProposal(it->first, proposal);
1833
1834 return;
1835 }
1836
1837 bool sendUpdate = proposal.state != LFG_PROPOSAL_SUCCESS;
1838 proposal.state = LFG_PROPOSAL_SUCCESS;
1839 time_t joinTime = GameTime::GetGameTime().count();
1840
1841 LFGQueue& queue = GetQueue(guid);
1842 LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_GROUP_FOUND);
1843 for (LfgProposalPlayerContainer::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it)
1844 {
1845 ObjectGuid pguid = it->first;
1846 ObjectGuid gguid = it->second.group;
1847 uint32 dungeonId = (*GetSelectedDungeons(pguid).begin());
1848 int32 waitTime = -1;
1849 if (sendUpdate)
1850 SendLfgUpdateProposal(pguid, proposal);
1851
1852 if (gguid)
1853 {
1854 waitTime = int32((joinTime - queue.GetJoinTime(gguid)) / IN_MILLISECONDS);
1855 SendLfgUpdateParty(pguid, updateData);
1856 }
1857 else
1858 {
1859 waitTime = int32((joinTime - queue.GetJoinTime(pguid)) / IN_MILLISECONDS);
1860 SendLfgUpdatePlayer(pguid, updateData);
1861 }
1862 updateData.updateType = LFG_UPDATETYPE_REMOVED_FROM_QUEUE;
1863 SendLfgUpdatePlayer(pguid, updateData);
1864 SendLfgUpdateParty(pguid, updateData);
1865
1866 // Update timers
1867 uint8 role = GetRoles(pguid);
1868 role &= ~PLAYER_ROLE_LEADER;
1869 switch (role)
1870 {
1871 case PLAYER_ROLE_DAMAGE:
1872 queue.UpdateWaitTimeDps(waitTime, dungeonId);
1873 break;
1874 case PLAYER_ROLE_HEALER:
1875 queue.UpdateWaitTimeHealer(waitTime, dungeonId);
1876 break;
1877 case PLAYER_ROLE_TANK:
1878 queue.UpdateWaitTimeTank(waitTime, dungeonId);
1879 break;
1880 default:
1881 queue.UpdateWaitTimeAvg(waitTime, dungeonId);
1882 break;
1883 }
1884
1886 }
1887
1888 // Remove players/groups from Queue
1889 for (uint8 i = 0; i < 5 && proposal.queues.guids[i]; ++i)
1890 queue.RemoveQueueData(proposal.queues.guids[i]);
1891
1892 MakeNewGroup(proposal);
1893 ProposalsStore.erase(itProposal);
1894 }
std::int32_t int32
Definition: Define.h:104
@ LFG_UPDATETYPE_GROUP_FOUND
Definition: LFG.h:61
uint8 GetRoles(ObjectGuid guid)
Get current player roles.
Definition: LFGMgr.cpp:2387
void MakeNewGroup(LfgProposal const &proposal)
Definition: LFGMgr.cpp:1573

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)
971 {
972 for (uint8 team = 0; team < 2; ++team)
973 {
974 if (m_raidBrowserUpdateTimer[team] > diff)
975 m_raidBrowserUpdateTimer[team] -= diff;
976 else
977 m_raidBrowserUpdateTimer[team] = 0;
978 }
979
980 if (GetMSTimeDiff(GameTime::GetGameTimeMS(), GetTimeMS()) > 98ms) // prevent lagging
981 {
982 return;
983 }
984
985 ObjectGuid guid, groupGuid, instanceGuid;
986 uint8 level, Class, race, talents[3];
987 float iLevel, mp5, mp5combat, baseAP, rangedAP;
988 int32 spellDamage, spellHeal;
989 uint32 dungeonId, encounterMask, maxPower;
990 uint32 deletedCounter, groupCounter, playerCounter;
991 ByteBuffer buffer_deleted, buffer_groups, buffer_players;
992 std::string emptyComment;
993 GuidSet deletedGroups, deletedGroupsToErase;
995
996 for (uint8 team = 0; team < 2; ++team)
997 {
998 if (m_raidBrowserLastUpdatedDungeonId[team] == 0) // new loop
999 {
1000 if (m_raidBrowserUpdateTimer[team] > 0) // allowed only with some time interval
1001 continue;
1002 else // reset timer
1003 m_raidBrowserUpdateTimer[team] = 5000;
1004 }
1005
1006 RBUsedDungeonsSet::const_iterator neitr, titr;
1007 for (neitr = RBUsedDungeonsStore[team].begin(); neitr != RBUsedDungeonsStore[team].end(); )
1008 {
1009 titr = neitr++;
1010 dungeonId = (*titr);
1011
1012 // go to next dungeon than previously (one dungeon updated in one LFGMgr::UpdateRaidBrowser)
1013 if (dungeonId <= m_raidBrowserLastUpdatedDungeonId[team])
1014 continue;
1015 m_raidBrowserLastUpdatedDungeonId[team] = dungeonId;
1016
1017 RBEntryInfoMap& entryInfoMap = RaidBrowserStore[team][dungeonId];
1018 LFGDungeonData const* dungeonData = GetLFGDungeon(dungeonId); // checked if exists before inserting to the container
1019 RBInternalInfoMap& currInternalInfoMap = RBInternalInfoStoreCurr[team][dungeonId];
1020 for (RBEntryInfoMap::const_iterator sitr = entryInfoMap.begin(); sitr != entryInfoMap.end(); ++sitr)
1021 {
1022 guid = sitr->first;
1023 groupGuid.Clear();
1025 ASSERT(p);
1026 if (sitr->second.roles == PLAYER_ROLE_LEADER)
1027 {
1028 ASSERT(p->GetGroup());
1029 groupGuid = p->GetGroup()->GetGUID();
1030 }
1031 encounterMask = 0;
1032 instanceGuid.Clear();
1033 if (InstancePlayerBind* bind = sInstanceSaveMgr->PlayerGetBoundInstance(guid, dungeonData->map, dungeonData->difficulty))
1034 if (bind->perm)
1035 {
1036 instanceGuid = ObjectGuid::Create<HighGuid::Instance>(bind->save->GetInstanceId());
1037 encounterMask = bind->save->GetCompletedEncounterMask();
1038 }
1039
1040 talents[0] = 0;
1041 talents[1] = 0;
1042 talents[2] = 0;
1043 p->GetTalentTreePoints(talents);
1050 maxPower = 0;
1051 if (p->getClass() == CLASS_DRUID)
1052 maxPower = p->GetMaxPower(POWER_MANA);
1053 else
1054 maxPower = (p->getPowerType() == POWER_RAGE || p->getPowerType() == POWER_RUNIC_POWER) ? p->GetMaxPower(p->getPowerType()) / 10 : p->GetMaxPower(p->getPowerType());
1055
1056 currInternalInfoMap[sitr->first] = RBInternalInfo(guid, sitr->second.comment, !groupGuid.IsEmpty(), groupGuid, sitr->second.roles, encounterMask, instanceGuid,
1057 1, p->getLevel(), p->getClass(), p->getRace(), p->GetAverageItemLevel(),
1058 talents, p->GetAreaId(), p->GetArmor(), (uint32)std::max<int32>(0, spellDamage), (uint32)std::max<int32>(0, spellHeal),
1059 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),
1060 std::max<uint32>(baseAP, rangedAP), (uint32)p->GetStat(STAT_AGILITY), p->GetMaxHealth(), maxPower, p->GetDefenseSkillValue(),
1062
1063 if (!groupGuid)
1064 continue;
1065 for (Group::member_citerator mitr = p->GetGroup()->GetMemberSlots().begin(); mitr != p->GetGroup()->GetMemberSlots().end(); ++mitr)
1066 {
1067 if (mitr->guid == sitr->first) // leader already added
1068 continue;
1069
1070 guid = mitr->guid;
1071 level = 1;
1072 Class = 0;
1073 race = 0;
1074 iLevel = 0.0f;
1075 talents[0] = 0;
1076 talents[1] = 0;
1077 talents[2] = 0;
1078 if (CharacterCacheEntry const* gpd = sCharacterCache->GetCharacterCacheByGuid(mitr->guid))
1079 {
1080 level = gpd->Level;
1081 Class = gpd->Class;
1082 race = gpd->Race;
1083 }
1085 if (mplr)
1086 {
1087 iLevel = mplr->GetAverageItemLevel();
1088 mplr->GetTalentTreePoints(talents);
1089 }
1090 currInternalInfoMap[mitr->guid] = RBInternalInfo(guid, emptyComment, false, groupGuid, 0, 0, ObjectGuid::Empty,
1091 (mplr ? 1 : 0), level, Class, race, iLevel,
1092 talents, 0, 0, 0, 0,
1093 0, 0, 0, 0, 0,
1094 0, 0, 0, 0, 0,
1095 0, 0, 0, 0, 0);
1096 }
1097 }
1098
1099 copy.clear();
1100 copy = currInternalInfoMap; // will be saved as prev at the end
1101
1102 // compare prev with curr to build difference packet
1103 deletedCounter = 0;
1104 groupCounter = 0;
1105 playerCounter = 0;
1106 buffer_deleted.clear();
1107 buffer_groups.clear();
1108 buffer_players.clear();
1109 deletedGroups.clear();
1110 deletedGroupsToErase.clear();
1111
1112 RBInternalInfoMap& prevInternalInfoMap = RBInternalInfoStorePrev[team][dungeonId];
1113 RBInternalInfoMap::iterator iter, iterTmp;
1114 for (RBInternalInfoMap::const_iterator sitr = prevInternalInfoMap.begin(); sitr != prevInternalInfoMap.end(); ++sitr)
1115 {
1116 iter = currInternalInfoMap.find(sitr->first);
1117 if (iter == currInternalInfoMap.end()) // was -> isn't
1118 {
1119 if (sitr->second.isGroupLeader)
1120 deletedGroups.insert(sitr->second.groupGuid);
1121 ++deletedCounter;
1122 buffer_deleted << sitr->second.guid;
1123 }
1124 else // was -> is
1125 {
1126 if (sitr->second.isGroupLeader) // was a leader
1127 {
1128 if (!iter->second.isGroupLeader) // leader -> no longer a leader
1129 deletedGroups.insert(sitr->second.groupGuid);
1130 else if (sitr->second.groupGuid != iter->second.groupGuid) // leader -> leader of another group
1131 {
1132 deletedGroups.insert(sitr->second.groupGuid);
1133 deletedGroupsToErase.insert(iter->second.groupGuid);
1134 ++groupCounter;
1135 RBPacketAppendGroup(iter->second, buffer_groups);
1136 }
1137 else if (sitr->second.comment != iter->second.comment || sitr->second.encounterMask != iter->second.encounterMask || sitr->second.instanceGuid != iter->second.instanceGuid) // leader -> nothing changed
1138 {
1139 ++groupCounter;
1140 RBPacketAppendGroup(iter->second, buffer_groups);
1141 }
1142 }
1143 else if (iter->second.isGroupLeader) // wasn't a leader -> is a leader
1144 {
1145 deletedGroupsToErase.insert(iter->second.groupGuid);
1146 ++groupCounter;
1147 RBPacketAppendGroup(iter->second, buffer_groups);
1148 }
1149
1150 if (!iter->second._online) // if offline, copy previous stats (itemLevel, talents, area, etc.)
1151 {
1152 iterTmp = copy.find(sitr->first); // copied container is for building a full packet, so modify it there (currInternalInfoMap is erased)
1153 iterTmp->second.CopyStats(sitr->second);
1154 if (!sitr->second.PlayerSameAs(iterTmp->second)) // player info changed
1155 {
1156 ++playerCounter;
1157 RBPacketAppendPlayer(iterTmp->second, buffer_players);
1158 }
1159 }
1160 else if (!sitr->second.PlayerSameAs(iter->second)) // player info changed
1161 {
1162 ++playerCounter;
1163 RBPacketAppendPlayer(iter->second, buffer_players);
1164 }
1165 currInternalInfoMap.erase(iter);
1166 }
1167 }
1168 // left entries (new)
1169 for (RBInternalInfoMap::const_iterator sitr = currInternalInfoMap.begin(); sitr != currInternalInfoMap.end(); ++sitr)
1170 {
1171 if (sitr->second.isGroupLeader)
1172 {
1173 deletedGroupsToErase.insert(sitr->second.groupGuid);
1174 ++groupCounter;
1175 RBPacketAppendGroup(sitr->second, buffer_groups);
1176 }
1177 ++playerCounter;
1178 RBPacketAppendPlayer(sitr->second, buffer_players);
1179 }
1180
1181 if (!deletedGroupsToErase.empty())
1182 {
1183 for (ObjectGuid const& toErase : deletedGroupsToErase)
1184 {
1185 deletedGroups.erase(toErase);
1186 }
1187 }
1188
1189 if (!deletedGroups.empty())
1190 {
1191 for (ObjectGuid const& deletedGroup : deletedGroups)
1192 {
1193 ++deletedCounter;
1194 buffer_deleted << deletedGroup;
1195 }
1196 }
1197
1198 WorldPacket differencePacket(SMSG_UPDATE_LFG_LIST, 1000);
1199 RBPacketBuildDifference(differencePacket, dungeonId, deletedCounter, buffer_deleted, groupCounter, buffer_groups, playerCounter, buffer_players);
1200 WorldPacket fullPacket(SMSG_UPDATE_LFG_LIST, 1000);
1201 RBPacketBuildFull(fullPacket, dungeonId, copy);
1202
1203 RBCacheStore[team][dungeonId] = fullPacket;
1204 prevInternalInfoMap = copy;
1205 currInternalInfoMap.clear();
1206
1207 if (entryInfoMap.empty())
1208 RBUsedDungeonsStore[team].erase(titr);
1209
1210 // send difference packet to browsing players
1211 for (RBSearchersMap::const_iterator sitr = RBSearchersStore[team].begin(); sitr != RBSearchersStore[team].end(); ++sitr)
1212 if (sitr->second == dungeonId)
1213 if (Player* p = ObjectAccessor::FindConnectedPlayer(sitr->first))
1214 p->GetSession()->SendPacket(&differencePacket);
1215
1216 break; // one dungeon updated in one LFGMgr::UpdateRaidBrowser
1217 }
1218
1219 // already updated all in this time interval
1220 if (neitr == RBUsedDungeonsStore[team].end())
1222 }
1223 }
std::uint16_t uint16
Definition: Define.h:109
Milliseconds GetTimeMS()
Definition: Timer.h:84
Milliseconds GetMSTimeDiff(Milliseconds oldMSTime, Milliseconds newMSTime)
Definition: Timer.h:91
#define sCharacterCache
Definition: CharacterCache.h:83
std::set< ObjectGuid > GuidSet
Definition: ObjectGuid.h:255
@ 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
@ BASE_ATTACK
Definition: Unit.h:396
@ RANGED_ATTACK
Definition: Unit.h:398
@ CR_EXPERTISE
Definition: Unit.h:427
@ CR_CRIT_MELEE
Definition: Unit.h:412
@ CR_CRIT_RANGED
Definition: Unit.h:413
@ CR_PARRY
Definition: Unit.h:407
@ CR_DODGE
Definition: Unit.h:406
@ CR_BLOCK
Definition: Unit.h:408
@ CR_HASTE_SPELL
Definition: Unit.h:423
@ CR_CRIT_SPELL
Definition: Unit.h:414
@ POWER_RAGE
Definition: SharedDefines.h:242
@ POWER_RUNIC_POWER
Definition: SharedDefines.h:247
@ POWER_MANA
Definition: SharedDefines.h:241
@ CLASS_DRUID
Definition: SharedDefines.h:123
@ STAT_AGILITY
Definition: SharedDefines.h:231
@ SPELL_SCHOOL_MASK_ALL
Definition: SharedDefines.h:287
Milliseconds GetGameTimeMS()
Definition: GameTime.cpp:43
Definition: CharacterCache.h:28
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:1295
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:1310
RBInternalInfoMapMap RBInternalInfoStoreCurr[2]
Definition: LFGMgr.h:436
uint32 GetUInt32Value(uint16 index) const
Definition: Object.cpp:307
float GetFloatValue(uint16 index) const
Definition: Object.cpp:319
uint32 GetAreaId() const
Definition: Object.cpp:3068
bool IsEmpty() const
Definition: ObjectGuid.h:163
void GetTalentTreePoints(uint8(&specPoints)[3]) const
Definition: Player.cpp:14973
float GetAverageItemLevel()
Definition: Player.cpp:15414
int32 SpellBaseHealingBonusDone(SpellSchoolMask schoolMask)
Definition: Unit.cpp:13462
float GetTotalAttackPowerValue(WeaponAttackType attType, Unit *pVictim=nullptr) const
Definition: Unit.cpp:16141
uint32 GetDefenseSkillValue(Unit const *target=nullptr) const
Definition: Unit.cpp:4091
uint32 GetMaxHealth() const
Definition: Unit.h:1439
uint8 getClass() const
Definition: Unit.h:1424
uint8 getRace(bool original=false) const
Definition: Unit.cpp:21878
uint32 GetMaxPower(Powers power) const
Definition: Unit.h:1460
uint32 GetArmor() const
Definition: Unit.h:1430
int32 SpellBaseDamageBonusDone(SpellSchoolMask schoolMask)
Definition: Unit.cpp:12704
float GetStat(Stats stat) const
Definition: Unit.h:1428
Powers getPowerType() const
Definition: Unit.h:1457
MemberSlotList const & GetMemberSlots() const
Definition: Group.h:240
MemberSlotList::const_iterator member_citerator
Definition: Group.h:179
void clear()
Definition: ByteBuffer.h:122

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

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