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

#include "LFGMgr.h"

Public Member Functions

void Update (uint32 diff, uint8 task)
 
void FinishDungeon (ObjectGuid gguid, uint32 dungeonId, const Map *currMap)
 Finish the dungeon for the given group. All check are performed using internal lfg data. 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, Group const *group=nullptr)
 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
47 {
48 for (uint8 team = 0; team < 2; ++team)
49 {
50 m_raidBrowserUpdateTimer[team] = 10000;
52 }
53 }
@ CONFIG_LFG_OPTIONSMASK
Definition: IWorld.h:366
std::uint8_t uint8
Definition: Define.h:109
#define sWorld
Definition: World.h:444
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
56 {
57 for (LfgRewardContainer::iterator itr = RewardMapStore.begin(); itr != RewardMapStore.end(); ++itr)
58 delete itr->second;
59 }
LfgRewardContainer RewardMapStore
Stores rewards for random dungeons.
Definition: LFGMgr.h:625

References RewardMapStore.

Member Function Documentation

◆ _LoadFromDB()

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

Load Lfg group info from DB.

68 {
69 if (!fields)
70 return;
71
72 if (!guid.IsGroup())
73 return;
74
75 SetLeader(guid, ObjectGuid::Create<HighGuid::Player>(fields[0].Get<uint32>()));
76
77 uint32 dungeon = fields[17].Get<uint32>();
78 uint8 state = fields[18].Get<uint8>();
79
80 if (!dungeon || !state)
81 return;
82
83 SetDungeon(guid, dungeon);
84
85 switch (state)
86 {
89 SetState(guid, (LfgState)state);
90 break;
91 default:
92 break;
93 }
94 }
std::uint32_t uint32
Definition: Define.h:107
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:2489
void SetState(ObjectGuid guid, LfgState state)
Definition: LFGMgr.cpp:2462
void SetLeader(ObjectGuid gguid, ObjectGuid leader)
Sets the leader of the group.
Definition: LFGMgr.cpp:2576
bool IsGroup() const
Definition: ObjectGuid.h:178

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

◆ _SaveToDB()

void lfg::LFGMgr::_SaveToDB ( ObjectGuid  guid)
private
97 {
98 if (!guid.IsGroup())
99 return;
100
102 stmt->SetData(0, guid.GetCounter());
103 stmt->SetData(1, GetDungeon(guid));
104 stmt->SetData(2, GetState(guid));
105 CharacterDatabase.Execute(stmt);
106 }
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:2358
uint32 GetDungeon(ObjectGuid guid, bool asId=true)
Get current dungeon.
Definition: LFGMgr.cpp:2382
LowType GetCounter() const
Definition: ObjectGuid.h:145

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.

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

References GroupsStore.

Referenced by SetupGroupMember().

◆ AddProposal()

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

Add a new Proposal.

1794 {
1795 proposal.id = ++m_lfgProposalId;
1796 ProposalsStore[m_lfgProposalId] = proposal;
1797 return m_lfgProposalId;
1798 }
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.

2702 {
2703 bool ok = true;
2704
2705 if (check.empty())
2706 return false;
2707
2708 for (uint8 i = 0; i < 5 && check.guids[i]; ++i)
2709 {
2710 ObjectGuid guid = check.guids[i];
2711 if (GetState(guid) != LFG_STATE_QUEUED)
2712 {
2713 LFGQueue& queue = GetQueue(guid);
2714 queue.RemoveFromQueue(guid);
2715 ok = false;
2716 }
2717 }
2718
2719 return ok;
2720 }
@ LFG_STATE_QUEUED
Definition: LFG.h:73
LFGQueue & GetQueue(ObjectGuid guid)
Definition: LFGMgr.cpp:2684
Definition: ObjectGuid.h:118

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.

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

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.

2724 {
2725 QueuesStore.clear();
2726 }
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
2533 {
2534 LOG_DEBUG("lfg", "LFGMgr::DecreaseKicksLeft: [{}]", guid.ToString());
2535 GroupsStore[guid].DecreaseKicksLeft();
2536 }
#define LOG_DEBUG(filterType__,...)
Definition: Log.h:168
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
2205 {
2206 uint32 gDungeonId = GetDungeon(gguid);
2207 if (gDungeonId != dungeonId)
2208 {
2209 LOG_DEBUG("lfg", "LFGMgr::FinishDungeon: [{}] Finished dungeon {} but group queued for {}. Ignoring", gguid.ToString(), dungeonId, gDungeonId);
2210 return;
2211 }
2212
2213 if (GetState(gguid) == LFG_STATE_FINISHED_DUNGEON) // Shouldn't happen. Do not reward multiple times
2214 {
2215 LOG_DEBUG("lfg", "LFGMgr::FinishDungeon: [{}] Already rewarded group. Ignoring", gguid.ToString());
2216 return;
2217 }
2218
2220 _SaveToDB(gguid); // pussywizard
2221
2222 const LfgGuidSet& players = GetPlayers(gguid);
2223 for (LfgGuidSet::const_iterator it = players.begin(); it != players.end(); ++it)
2224 {
2225 ObjectGuid guid = (*it);
2227 {
2228 LOG_DEBUG("lfg", "LFGMgr::FinishDungeon: [{}] Already rewarded player. Ignoring", guid.ToString());
2229 continue;
2230 }
2231
2232 uint32 rDungeonId = 0;
2233 const LfgDungeonSet& dungeons = GetSelectedDungeons(guid);
2234 if (!dungeons.empty())
2235 rDungeonId = (*dungeons.begin());
2236
2238
2239 // Give rewards only if its a random dungeon
2240 LFGDungeonData const* dungeon = GetLFGDungeon(rDungeonId);
2241
2242 if (!dungeon || (dungeon->type != LFG_TYPE_RANDOM && !dungeon->seasonal))
2243 {
2244 LOG_DEBUG("lfg", "LFGMgr::FinishDungeon: [{}] dungeon {} is not random or seasonal", guid.ToString(), rDungeonId);
2245 continue;
2246 }
2247
2248 Player* player = ObjectAccessor::FindPlayer(guid);
2249 if (!player || player->FindMap() != currMap) // pussywizard: currMap - multithreading crash if on other map (map id check is not enough, binding system is not reliable)
2250 {
2251 LOG_DEBUG("lfg", "LFGMgr::FinishDungeon: [{}] not found in world", guid.ToString());
2252 continue;
2253 }
2254
2255 LFGDungeonData const* dungeonDone = GetLFGDungeon(dungeonId);
2256 uint32 mapId = dungeonDone ? uint32(dungeonDone->map) : 0;
2257
2258 if (player->GetMapId() != mapId)
2259 {
2260 LOG_DEBUG("lfg", "LFGMgr::FinishDungeon: [{}] is in map {} and should be in {} to get reward", guid.ToString(), player->GetMapId(), mapId);
2261 continue;
2262 }
2263
2264 // Remove Dungeon Finder Cooldown if still exists
2266 {
2268 }
2269
2270 // Xinef: Update achievements, set correct amount of randomly grouped players
2271 if (dungeon->difficulty == DUNGEON_DIFFICULTY_HEROIC)
2272 if (uint8 count = GetRandomPlayersCount(player->GetGUID()))
2274
2275 LfgReward const* reward = GetRandomDungeonReward(rDungeonId, player->GetLevel());
2276 if (!reward)
2277 continue;
2278
2279 bool done = false;
2280 Quest const* quest = sObjectMgr->GetQuestTemplate(reward->firstQuest);
2281 if (!quest)
2282 continue;
2283
2284 // if we can take the quest, means that we haven't done this kind of "run", IE: First Heroic Random of Day.
2285 if (player->CanRewardQuest(quest, false))
2286 player->RewardQuest(quest, 0, nullptr, false, true);
2287 else
2288 {
2289 done = true;
2290 quest = sObjectMgr->GetQuestTemplate(reward->otherQuest);
2291 if (!quest)
2292 continue;
2293 // we give reward without informing client (retail does this)
2294 player->RewardQuest(quest, 0, nullptr, false, true);
2295 }
2296
2297 // Give rewards
2298 LOG_DEBUG("lfg", "LFGMgr::FinishDungeon: [{}] done dungeon {}, {} previously done.", player->GetGUID().ToString(), GetDungeon(gguid), done ? " " : " not");
2299 LfgPlayerRewardData data = LfgPlayerRewardData(dungeon->Entry(), GetDungeon(gguid, false), done, quest);
2300 player->GetSession()->SendLfgPlayerReward(data);
2301 }
2302 }
#define sObjectMgr
Definition: ObjectMgr.h:1623
@ DUNGEON_DIFFICULTY_HEROIC
Definition: DBCEnums.h:270
@ ACHIEVEMENT_CRITERIA_TYPE_USE_LFD_TO_GROUP_WITH_PLAYERS
Definition: DBCEnums.h:223
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:248
uint8 GetRandomPlayersCount(ObjectGuid guid)
Xinef: Get Random Players Count.
Definition: LFGMgr.cpp:2619
void _SaveToDB(ObjectGuid guid)
Definition: LFGMgr.cpp:96
LFGDungeonData const * GetLFGDungeon(uint32 id)
Definition: LFGMgr.cpp:169
LfgDungeonSet const & GetSelectedDungeons(ObjectGuid guid)
Get selected dungeons.
Definition: LFGMgr.cpp:2414
LfgReward const * GetRandomDungeonReward(uint32 dungeon, uint8 level)
Gets the random dungeon reward corresponding to given dungeon and player level.
Definition: LFGMgr.cpp:2328
LfgGuidSet const & GetPlayers(ObjectGuid guid)
Definition: LFGMgr.cpp:2599
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:109
Map * FindMap() const
Definition: Object.h:532
uint32 GetMapId() const
Definition: Position.h:276
Definition: Player.h:1064
void UpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscValue1=0, uint32 miscValue2=0, Unit *unit=nullptr)
Definition: PlayerUpdates.cpp:2127
bool CanRewardQuest(Quest const *quest, bool msg)
Definition: PlayerQuest.cpp:384
WorldSession * GetSession() const
Definition: Player.h:1975
void RewardQuest(Quest const *quest, uint32 reward, Object *questGiver, bool announce=true, bool isLFGReward=false)
Definition: PlayerQuest.cpp:658
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
Definition: Unit.cpp:5652
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:4874
uint8 GetLevel() const
Definition: Unit.h:759
Definition: QuestDef.h:209
void SendLfgPlayerReward(lfg::LfgPlayerRewardData const &lfgPlayerRewardData)
Definition: LFGHandler.cpp:469

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)

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

References GetLockedDungeons().

Referenced by JoinLfg().

◆ GetDungeon()

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

Get current dungeon.

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

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.

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

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.
2315 {
2316 LFGDungeonData const* dungeon = GetLFGDungeon(randomdungeon);
2317 uint32 group = dungeon ? dungeon->group : 0;
2318 return CachedDungeonMapStore[group];
2319 }
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
2350 {
2351 LFGDungeonData const* dungeon = GetLFGDungeon(dungeonId);
2352 if (!dungeon)
2353 return LFG_TYPE_NONE;
2354
2355 return LfgType(dungeon->type);
2356 }
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.

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

References PlayersStore.

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

◆ GetKicksLeft()

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

Get kicks left in current group.

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

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

◆ GetLeader()

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

Get leader of the group (using internal data)

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

References GroupsStore.

Referenced by GetQueue(), and LeaveLfg().

◆ GetLFGDungeon()

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

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

References GetLFGDungeon().

Referenced by LoadRewards().

◆ GetLfgStatus()

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

Returns current lfg status.

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

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

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)

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

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

◆ GetOptions()

uint32 lfg::LFGMgr::GetOptions ( )

Gets current lfg options.

2734 {
2735 return m_options;
2736 }

References m_options.

◆ GetPlayerCount()

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

Gets the player count of given group.

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

References GroupsStore.

◆ GetPlayers()

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

References GroupsStore.

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

◆ GetQueue()

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

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.

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

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

◆ GetRandomDungeonReward()

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

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

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

Parameters
[in]dungeondungeon id
[in]levelPlayer level
Returns
Reward
2329 {
2330 LfgReward const* rew = nullptr;
2331 LfgRewardContainerBounds bounds = RewardMapStore.equal_range(dungeon & 0x00FFFFFF);
2332 for (LfgRewardContainer::const_iterator itr = bounds.first; itr != bounds.second; ++itr)
2333 {
2334 rew = itr->second;
2335 // ordered properly at loading
2336 if (itr->second->maxLevel >= level)
2337 break;
2338 }
2339
2340 return rew;
2341 }
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.

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

References PlayersStore.

Referenced by FinishDungeon().

◆ GetRoles()

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

Get current player roles.

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

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

Referenced by UpdateProposal().

◆ GetSelectedDungeons()

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

Get selected dungeons.

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

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.

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

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

References PlayersStore.

Referenced by GetQueue().

◆ HasIgnore()

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

Checks if given players are ignoring each other.

2625 {
2628 return plr1 && plr2 && (plr1->GetSocial()->HasIgnore(guid2) || plr2->GetSocial()->HasIgnore(guid1));
2629 }
Player * FindConnectedPlayer(ObjectGuid const guid)
Definition: ObjectAccessor.cpp:260
PlayerSocial * GetSocial()
Definition: Player.h:1141
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
2020 {
2021 SetState(gguid, LFG_STATE_BOOT);
2022
2023 LfgPlayerBoot& boot = BootsStore[gguid];
2024 boot.inProgress = true;
2025 boot.cancelTime = time_t(GameTime::GetGameTime().count()) + LFG_TIME_BOOT;
2026 boot.reason = reason;
2027 boot.victim = victim;
2028
2029 LfgGuidSet const& players = GetPlayers(gguid);
2030
2031 // Set votes
2032 for (LfgGuidSet::const_iterator itr = players.begin(); itr != players.end(); ++itr)
2033 {
2034 ObjectGuid guid = (*itr);
2035 SetState(guid, LFG_STATE_BOOT);
2036 boot.votes[guid] = LFG_ANSWER_PENDING;
2037 }
2038
2039 boot.votes[victim] = LFG_ANSWER_DENY; // Victim auto vote NO
2040 boot.votes[kicker] = LFG_ANSWER_AGREE; // Kicker auto vote YES
2041
2042 // Notify players
2043 for (LfgGuidSet::const_iterator it = players.begin(); it != players.end(); ++it)
2044 SendLfgBootProposalUpdate(*it, boot);
2045 }
@ 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:2661
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,
Group const *  group = nullptr 
)

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

Generate the dungeon lock map for a given player

Parameters
[in]playerPlayer we need to initialize the lock status map
391 {
392 ObjectGuid guid = player->GetGUID();
393
394 uint8 level = player->GetLevel();
395 uint8 expansion = player->GetSession()->Expansion();
396 LfgDungeonSet const& dungeons = GetDungeonsByRandom(0);
397 LfgLockMap lock;
398
399 bool onlySeasonalBosses = m_options == LFG_OPTION_ENABLE_SEASONAL_BOSSES;
400
401 float avgItemLevel = player->GetAverageItemLevelForDF();
402
403 for (LfgDungeonSet::const_iterator it = dungeons.begin(); it != dungeons.end(); ++it)
404 {
405 LFGDungeonData const* dungeon = GetLFGDungeon(*it);
406 if (!dungeon) // should never happen - We provide a list from sLFGDungeonStore
407 continue;
408 MapEntry const* mapEntry = sMapStore.LookupEntry(dungeon->map);
409 DungeonProgressionRequirements const* ar = sObjectMgr->GetAccessRequirement(dungeon->map, Difficulty(dungeon->difficulty));
410
411 uint32 lockData = 0;
412 if (dungeon->expansion > expansion || (onlySeasonalBosses && !dungeon->seasonal))
414 else if (DisableMgr::IsDisabledFor(DISABLE_TYPE_MAP, dungeon->map, player))
416 else if (DisableMgr::IsDisabledFor(DISABLE_TYPE_LFG_MAP, dungeon->map, player))
418 else if (dungeon->difficulty > DUNGEON_DIFFICULTY_NORMAL && (!mapEntry || !mapEntry->IsRaid()) && sInstanceSaveMgr->PlayerIsPermBoundToInstance(player->GetGUID(), dungeon->map, Difficulty(dungeon->difficulty)))
420 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))
422 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))
424 else if (dungeon->seasonal && !IsSeasonActive(dungeon->id))
426 else if (ar)
427 {
428 // Check required items
429 for (const ProgressionRequirement* itemRequirement : ar->items)
430 {
431 if (!itemRequirement->checkLeaderOnly || !group || group->GetLeaderGUID() == player->GetGUID())
432 {
433 if (itemRequirement->faction == TEAM_NEUTRAL || itemRequirement->faction == player->GetTeamId(true))
434 {
435 if (!player->HasItemCount(itemRequirement->id, 1))
436 {
438 break;
439 }
440 }
441 }
442 }
443
444 //Check for quests
445 for (const ProgressionRequirement* questRequirement : ar->quests)
446 {
447 if (!questRequirement->checkLeaderOnly || !group || group->GetLeaderGUID() == player->GetGUID())
448 {
449 if (questRequirement->faction == TEAM_NEUTRAL || questRequirement->faction == player->GetTeamId(true))
450 {
451 if (!player->GetQuestRewardStatus(questRequirement->id))
452 {
454 break;
455 }
456 }
457 }
458 }
459
460 //Check for ilvl
461 if (ar->reqItemLevel && (float)ar->reqItemLevel > avgItemLevel)
462 {
464 }
465
466 //Check if player has the required achievements
467 for (const ProgressionRequirement* achievementRequirement : ar->achievements)
468 {
469 if (!achievementRequirement->checkLeaderOnly || !group || group->GetLeaderGUID() == player->GetGUID())
470 {
471 if (achievementRequirement->faction == TEAM_NEUTRAL || achievementRequirement->faction == player->GetTeamId(true))
472 {
473 if (!player->HasAchieved(achievementRequirement->id))
474 {
476 break;
477 }
478 }
479 }
480 }
481 }
482
483 sScriptMgr->OnInitializeLockedDungeons(player, level, lockData, dungeon);
484
485 /* TODO VoA closed if WG is not under team control (LFG_LOCKSTATUS_RAID_LOCKED)
486 lockData = LFG_LOCKSTATUS_TOO_LOW_GEAR_SCORE;
487 lockData = LFG_LOCKSTATUS_TOO_HIGH_GEAR_SCORE;
488 lockData = LFG_LOCKSTATUS_ATTUNEMENT_TOO_LOW_LEVEL;
489 lockData = LFG_LOCKSTATUS_ATTUNEMENT_TOO_HIGH_LEVEL;
490 */
491
492 if (lockData)
493 lock[dungeon->Entry()] = lockData;
494 }
495
496 sScriptMgr->OnAfterInitializeLockedDungeons(player);
497
498 SetLockedDungeons(guid, lock);
499 }
DBCStorage< MapEntry > sMapStore(MapEntryfmt)
#define sInstanceSaveMgr
Definition: InstanceSaveMgr.h:202
#define sScriptMgr
Definition: ScriptMgr.h:709
@ DISABLE_TYPE_MAP
Definition: DisableMgr.h:31
@ DISABLE_TYPE_LFG_MAP
Definition: DisableMgr.h:37
@ CONFIG_DUNGEON_ACCESS_REQUIREMENTS_LFG_DBC_LEVEL_OVERRIDE
Definition: IWorld.h:171
Difficulty
Definition: DBCEnums.h:266
@ DUNGEON_DIFFICULTY_NORMAL
Definition: DBCEnums.h:269
@ TEAM_NEUTRAL
Definition: SharedDefines.h:762
bool IsDisabledFor(DisableType type, uint32 entry, Unit const *unit, uint8 flags)
Definition: DisableMgr.cpp:306
@ 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:2526
LfgDungeonSet const & GetDungeonsByRandom(uint32 randomdungeon)
Definition: LFGMgr.cpp:2314
bool IsSeasonActive(uint32 dungeonId)
Checks if Seasonal dungeon is active.
Definition: LFGMgr.cpp:2749
Definition: Player.h:933
TeamId faction
Definition: Player.h:935
uint32 id
Definition: Player.h:934
bool checkLeaderOnly
Definition: Player.h:938
Definition: Player.h:942
std::vector< ProgressionRequirement * > items
Definition: Player.h:947
std::vector< ProgressionRequirement * > quests
Definition: Player.h:946
uint8 levelMax
Definition: Player.h:944
uint8 levelMin
Definition: Player.h:943
uint16 reqItemLevel
Definition: Player.h:945
std::vector< ProgressionRequirement * > achievements
Definition: Player.h:948
float GetAverageItemLevelForDF()
Definition: Player.cpp:15694
bool GetQuestRewardStatus(uint32 quest_id) const
Definition: PlayerQuest.cpp:1409
bool HasItemCount(uint32 item, uint32 count=1, bool inBankAlso=false) const
Definition: PlayerStorage.cpp:678
TeamId GetTeamId(bool original=false) const
Definition: Player.h:2085
bool HasAchieved(uint32 achievementId) const
Definition: Player.cpp:13864
uint8 Expansion() const
Definition: WorldSession.h:373
Definition: DBCStructure.h:1325
bool IsRaid() const
Definition: DBCStructure.h:1354

References DungeonProgressionRequirements::achievements, ProgressionRequirement::checkLeaderOnly, 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(), Group::GetLeaderGUID(), 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.

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

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

◆ instance()

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

References instance().

Referenced by instance().

◆ IsLfgGroup()

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

Check if given group guid is lfg.

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

References GroupsStore, and ObjectGuid::IsGroup().

◆ isOptionEnabled()

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

Checks if given lfg option is enabled.

2729 {
2730 return m_options & option;
2731 }

References m_options.

Referenced by Update().

◆ IsSeasonActive()

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

Checks if Seasonal dungeon is active.

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

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

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

1345 {
1346 ObjectGuid pguid, gguid;
1347 if (guid.IsGroup())
1348 gguid = guid;
1349 else if (groupguid && groupguid.IsGroup())
1350 {
1351 pguid = guid;
1352 gguid = groupguid;
1353 }
1354 else
1355 {
1356 pguid = guid;
1357 gguid = GetGroup(guid);
1358 }
1359 if (!allowgroup)
1360 gguid.Clear();
1361
1362 if (pguid)
1363 for (lfg::LfgQueueContainer::iterator itr = QueuesStore.begin(); itr != QueuesStore.end(); ++itr)
1364 itr->second.RemoveFromQueue(pguid);
1365 if (gguid)
1366 for (lfg::LfgQueueContainer::iterator itr = QueuesStore.begin(); itr != QueuesStore.end(); ++itr)
1367 itr->second.RemoveFromQueue(gguid);
1368
1369 if (pguid && !gguid)
1370 {
1371 if (GetState(pguid) == LFG_STATE_QUEUED)
1372 {
1374 SetState(pguid, LFG_STATE_NONE);
1375 }
1376 }
1377 if (gguid)
1378 {
1379 if (GetState(gguid) == LFG_STATE_QUEUED)
1380 {
1381 SetState(gguid, LFG_STATE_NONE);
1382 const LfgGuidSet& players = GetPlayers(gguid);
1383 for (LfgGuidSet::const_iterator it = players.begin(); it != players.end(); ++it)
1384 {
1387 }
1388 }
1389 }
1390 }
@ 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:2649
void SendLfgUpdatePlayer(ObjectGuid guid, LfgUpdateData const &data)
Definition: LFGMgr.cpp:2643
void Clear()
Definition: ObjectGuid.h:138

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
819 {
820 LOG_DEBUG("lfg", "LFGMgr::Leave: [{}]", guid.ToString());
821 ObjectGuid gguid = guid.IsGroup() ? guid : GetGroup(guid);
822 LfgState state = GetState(guid);
823 switch (state)
824 {
825 case LFG_STATE_QUEUED:
826 if (gguid)
827 {
828 LFGQueue& queue = GetQueue(gguid);
829 queue.RemoveFromQueue(gguid);
830 uint32 dungeonId = GetDungeon(gguid);
831 SetState(gguid, LFG_STATE_NONE);
832 const LfgGuidSet& players = GetPlayers(gguid);
833 for (LfgGuidSet::const_iterator it = players.begin(); it != players.end(); ++it)
834 {
837 }
838 if (Group* group = sGroupMgr->GetGroupByGUID(gguid.GetCounter()))
839 {
840 if (group->isLFGGroup())
841 {
842 SetDungeon(gguid, dungeonId);
843 }
844 }
845 }
846 else
847 {
848 LFGQueue& queue = GetQueue(guid);
849 queue.RemoveFromQueue(guid);
852 }
853 break;
855 if (gguid)
856 UpdateRoleCheck(gguid); // No player to update role = LFG_ROLECHECK_ABORTED
857 break;
859 {
860 // Remove from Proposals
861 LfgProposalContainer::iterator it = ProposalsStore.begin();
862 ObjectGuid pguid = gguid == guid ? GetLeader(gguid) : guid;
863 while (it != ProposalsStore.end())
864 {
865 LfgProposalPlayerContainer::iterator itPlayer = it->second.players.find(pguid);
866 if (itPlayer != it->second.players.end())
867 {
868 // Mark the player/leader of group who left as didn't accept the proposal
869 itPlayer->second.accept = LFG_ANSWER_DENY;
870 break;
871 }
872 ++it;
873 }
874
875 // Remove from queue - if proposal is found, RemoveProposal will call RemoveFromQueue
876 if (it != ProposalsStore.end())
878 break;
879 }
880 case LFG_STATE_NONE:
881 break;
884 case LFG_STATE_BOOT:
885 if (guid != gguid) // Player
887 break;
889 LeaveRaidBrowser(guid);
890 SetCanOverrideRBState(guid, true);
892 SetCanOverrideRBState(guid, false);
895 break;
896 }
897 }
#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:914
void RemoveProposal(LfgProposalContainer::iterator itProposal, LfgUpdateType type)
Definition: LFGMgr.cpp:1910
void SetCanOverrideRBState(ObjectGuid guid, bool val)
Definition: LFGMgr.cpp:2484

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)
915 {
916 for (uint8 team = 0; team < 2; ++team)
917 for (RBStoreMap::iterator itr = RaidBrowserStore[team].begin(); itr != RaidBrowserStore[team].end(); ++itr)
918 itr->second.erase(guid);
919 }

References RaidBrowserStore.

Referenced by LeaveLfg().

◆ LfrSearchAdd()

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

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

◆ LfrSearchRemove()

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

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

◆ LfrSetComment()

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

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

◆ LoadLFGDungeons()

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

Loads dungeons from dbc and adds teleport coords.

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

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

◆ LoadRewards()

void lfg::LFGMgr::LoadRewards ( )

Loads rewards for random dungeons.

Load rewards for completing dungeons.

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

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

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

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.

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

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

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.

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

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

References ObjectAccessor::FindConnectedPlayer().

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

◆ SendLfgJoinResult()

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

References ObjectAccessor::FindConnectedPlayer().

Referenced by Update(), and UpdateRoleCheck().

◆ SendLfgQueueStatus()

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

Sends queue status to player.

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

References ObjectAccessor::FindConnectedPlayer().

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

◆ SendLfgRoleCheckUpdate()

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

References ObjectAccessor::FindConnectedPlayer().

Referenced by Update(), and UpdateRoleCheck().

◆ SendLfgRoleChosen()

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

References ObjectAccessor::FindConnectedPlayer().

Referenced by UpdateRoleCheck().

◆ SendLfgUpdateParty()

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

References ObjectAccessor::FindConnectedPlayer().

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

◆ SendLfgUpdatePlayer()

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

References ObjectAccessor::FindConnectedPlayer().

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

◆ SendLfgUpdateProposal()

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

References ObjectAccessor::FindConnectedPlayer().

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

◆ SendRaidBrowserCachedList()

void lfg::LFGMgr::SendRaidBrowserCachedList ( Player player,
uint32  dungeonId 
)
959 {
960 RBCacheMap::iterator itr = RBCacheStore[player->GetTeamId()].find(dungeonId);
961 if (itr != RBCacheStore[player->GetTeamId()].end())
962 {
963 player->GetSession()->SendPacket(&(itr->second));
964 return;
965 }
966 // send empty packet if cache not found
968 data << (uint32)LFG_TYPE_RAID;
969 data << (uint32)dungeonId;
970 data << (uint8)0;
971 data << (uint32)0;
972 data << (uint32)0;
973 data << (uint32)0;
974 data << (uint32)0;
975 player->GetSession()->SendPacket(&data);
976 }
@ 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:214

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

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
2485 {
2486 PlayersStore[guid].SetCanOverrideRBState(val);
2487 }

References PlayersStore.

Referenced by LeaveLfg().

◆ SetComment()

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

Sets player lfr comment.

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

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

Referenced by JoinLfg().

◆ SetDungeon()

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

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.

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

References PlayersStore.

Referenced by RemoveGroupData(), and SetupGroupMember().

◆ SetLeader()

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

Sets the leader of the group.

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

References GroupsStore.

Referenced by _LoadFromDB().

◆ SetLockedDungeons()

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

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

Referenced by InitializeLockedDungeons().

◆ SetOptions()

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

Sets new lfg options.

2739 {
2740 m_options = options;
2741 }

References m_options.

◆ SetRandomPlayersCount()

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

Xinef: Set Random Players Count.

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

References PlayersStore.

Referenced by MakeNewGroup().

◆ SetRoles()

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

Sets player lfg roles.

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

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

Referenced by JoinLfg(), and UpdateRoleCheck().

◆ SetSelectedDungeons()

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

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

Referenced by JoinLfg(), and SetupGroupMember().

◆ SetState()

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

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

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.

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

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)
2117 {
2118 LFGDungeonData const* dungeon = nullptr;
2119 Group* group = player->GetGroup();
2120
2121 if (group && group->isLFGGroup())
2122 dungeon = GetLFGDungeon(GetDungeon(group->GetGUID()));
2123
2124 if (!dungeon)
2125 {
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 if (out && error == LFG_TELEPORTERROR_OK)
2153 {
2154 if (player->GetMapId() == uint32(dungeon->map))
2155 player->TeleportToEntryPoint();
2156
2157 return;
2158 }
2159 else
2160 {
2161 uint32 mapid = dungeon->map;
2162 float x = dungeon->x;
2163 float y = dungeon->y;
2164 float z = dungeon->z;
2165 float orientation = dungeon->o;
2166
2167 if (teleportLocation)
2168 {
2169 teleportLocation->GetWorldLocation(mapid, x, y, z, orientation);
2170 }
2171
2172 if (!player->GetMap()->IsDungeon() || player->GetEntryPoint().GetMapId() == MAPID_INVALID)
2173 {
2174 player->SetEntryPoint();
2175 }
2176
2177 if (!player->TeleportTo(mapid, x, y, z, orientation, 0, nullptr, mapid == player->GetMapId()))
2178 {
2180 }
2181 }
2182
2183 if (error != LFG_TELEPORTERROR_OK)
2184 {
2185 player->GetSession()->SendLfgTeleportError(uint8(error));
2186
2187 LOG_DEBUG("lfg", "Player [{}] could NOT be teleported in to map [{}] (x: {}, y: {}, z: {}) Error: {}",
2188 player->GetName(), dungeon->map, dungeon->x, dungeon->y, dungeon->z, error);
2189 }
2190 else
2191 {
2192 LOG_DEBUG("lfg", "Player [{}] is being teleported in to map [{}] (x: {}, y: {}, z: {})",
2193 player->GetName(), dungeon->map, dungeon->x, dungeon->y, dungeon->z);
2194 }
2195
2196 }
#define MAPID_INVALID
Definition: Position.h:248
@ FATIGUE_TIMER
Definition: Player.h:574
@ UNIT_STATE_JUMPING
Definition: UnitDefines.h:167
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:531
void SetEntryPoint()
Definition: Player.cpp:11238
bool IsMirrorTimerActive(MirrorTimerType type)
Definition: Player.h:2038
bool TeleportToEntryPoint()
Definition: Player.cpp:1597
WorldLocation const & GetEntryPoint() const
Definition: Player.h:2354
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options=0, Unit *target=nullptr, bool newInstance=false)
Definition: Player.cpp:1330
bool IsFalling() const
Definition: Player.cpp:2156
Vehicle * GetVehicle() const
Definition: Unit.h:1697
bool IsAlive() const
Definition: Unit.h:1151
ObjectGuid GetCharmGUID() const
Definition: Unit.h:1165
bool HasUnitState(const uint32 f) const
Definition: Unit.h:739
bool IsInCombat() const
Definition: Unit.h:1032
bool IsDungeon() const
Definition: Map.h:448
void SendLfgTeleportError(uint8 err)
Definition: LFGHandler.cpp:608

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

Referenced by MakeNewGroup().

◆ ToggleTesting()

void lfg::LFGMgr::ToggleTesting ( )
807 {
810 }
@ LANG_DEBUG_LFG_ON
Definition: Language.h:1331
@ LANG_DEBUG_LFG_OFF
Definition: Language.h:1332
Definition: Chat.h:39
void SendWorldText(std::string_view str)
Definition: Chat.cpp:133

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

◆ Update()

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

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

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

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

Referenced by Update().

◆ UpdateRoleCheck()

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

Updates the role check with player answer.

Update the Role check info with the player selected role.

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

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