TrinityCore
Loading...
Searching...
No Matches
LFGMgr.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "LFGMgr.h"
19#include "DatabaseEnv.h"
20#include "DB2Stores.h"
21#include "DisableMgr.h"
22#include "GameEventMgr.h"
23#include "GameTime.h"
24#include "Group.h"
25#include "GroupMgr.h"
26#include "InstanceLockMgr.h"
27#include "LFGGroupData.h"
28#include "LFGPlayerData.h"
29#include "LFGQueue.h"
30#include "Log.h"
31#include "Map.h"
32#include "ObjectAccessor.h"
33#include "ObjectMgr.h"
34#include "Player.h"
35#include "RBAC.h"
36#include "SharedDefines.h"
37#include "SocialMgr.h"
38#include "World.h"
39#include "WorldSession.h"
40#include <sstream>
41
42namespace lfg
43{
44
45LFGDungeonData::LFGDungeonData() : id(0), name(), map(0), type(0), expansion(0), group(0), contentTuningId(0),
46 difficulty(DIFFICULTY_NONE), seasonal(false), x(0.0f), y(0.0f), z(0.0f), o(0.0f), requiredItemLevel(0), finalDungeonEncounterId(0)
47{
48}
49
50LFGDungeonData::LFGDungeonData(LFGDungeonsEntry const* dbc) : id(dbc->ID), name(dbc->Name[sWorld->GetDefaultDbcLocale()]), map(dbc->MapID),
51 type(uint8(dbc->TypeID)), expansion(uint8(dbc->ExpansionLevel)), group(uint8(dbc->GroupID)),
52 contentTuningId(uint32(dbc->ContentTuningID)), difficulty(Difficulty(dbc->DifficultyID)),
53 seasonal((dbc->Flags[0] & LFG_FLAG_SEASONAL) != 0), x(0.0f), y(0.0f), z(0.0f), o(0.0f),
54 requiredItemLevel(0), finalDungeonEncounterId(0)
55{
56 if (JournalEncounterEntry const* journalEncounter = sJournalEncounterStore.LookupEntry(dbc->FinalEncounterID))
57 finalDungeonEncounterId = journalEncounter->DungeonEncounterID;
58}
59
60LFGMgr::LFGMgr() : m_QueueTimer(0), m_lfgProposalId(1),
61 m_options(sWorld->getIntConfig(CONFIG_LFG_OPTIONSMASK))
62{
63}
64
66{
67 for (LfgRewardContainer::iterator itr = RewardMapStore.begin(); itr != RewardMapStore.end(); ++itr)
68 delete itr->second;
69}
70
72{
73 if (!fields)
74 return;
75
76 if (!guid.IsParty())
77 return;
78
79 SetLeader(guid, ObjectGuid::Create<HighGuid::Player>(fields[0].GetUInt64()));
80
81 uint32 dungeon = fields[19].GetUInt32();
82 uint8 state = fields[20].GetUInt8();
83
84 if (!dungeon || !state)
85 return;
86
87 SetDungeon(guid, dungeon);
88
89 switch (state)
90 {
93 SetState(guid, (LfgState)state);
94 break;
95 default:
96 break;
97 }
98}
99
101{
102 if (!guid.IsParty())
103 return;
104
105 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
106
108 stmt->setUInt32(0, db_guid);
109 trans->Append(stmt);
110
111 stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_LFG_DATA);
112 stmt->setUInt32(0, db_guid);
113 stmt->setUInt32(1, GetDungeon(guid));
114 stmt->setUInt32(2, GetState(guid));
115 trans->Append(stmt);
116
117 CharacterDatabase.CommitTransaction(trans);
118}
119
122{
123 uint32 oldMSTime = getMSTime();
124
125 for (LfgRewardContainer::iterator itr = RewardMapStore.begin(); itr != RewardMapStore.end(); ++itr)
126 delete itr->second;
127 RewardMapStore.clear();
128
129 // ORDER BY is very important for GetRandomDungeonReward!
130 QueryResult result = WorldDatabase.Query("SELECT dungeonId, maxLevel, firstQuestId, otherQuestId FROM lfg_dungeon_rewards ORDER BY dungeonId, maxLevel ASC");
131
132 if (!result)
133 {
134 TC_LOG_INFO("server.loading", ">> Loaded 0 lfg dungeon rewards. DB table `lfg_dungeon_rewards` is empty!");
135 return;
136 }
137
138 uint32 count = 0;
139
140 Field* fields = nullptr;
141 do
142 {
143 fields = result->Fetch();
144 uint32 dungeonId = fields[0].GetUInt32();
145 uint32 maxLevel = fields[1].GetUInt8();
146 uint32 firstQuestId = fields[2].GetUInt32();
147 uint32 otherQuestId = fields[3].GetUInt32();
148
149 if (!GetLFGDungeonEntry(dungeonId))
150 {
151 TC_LOG_ERROR("sql.sql", "Dungeon {} specified in table `lfg_dungeon_rewards` does not exist!", dungeonId);
152 continue;
153 }
154
155 if (!maxLevel || maxLevel > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
156 {
157 TC_LOG_ERROR("sql.sql", "Level {} specified for dungeon {} in table `lfg_dungeon_rewards` can never be reached!", maxLevel, dungeonId);
158 maxLevel = sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL);
159 }
160
161 if (!firstQuestId || !sObjectMgr->GetQuestTemplate(firstQuestId))
162 {
163 TC_LOG_ERROR("sql.sql", "First quest {} specified for dungeon {} in table `lfg_dungeon_rewards` does not exist!", firstQuestId, dungeonId);
164 continue;
165 }
166
167 if (otherQuestId && !sObjectMgr->GetQuestTemplate(otherQuestId))
168 {
169 TC_LOG_ERROR("sql.sql", "Other quest {} specified for dungeon {} in table `lfg_dungeon_rewards` does not exist!", otherQuestId, dungeonId);
170 otherQuestId = 0;
171 }
172
173 RewardMapStore.insert(LfgRewardContainer::value_type(dungeonId, new LfgReward(maxLevel, firstQuestId, otherQuestId)));
174 ++count;
175 }
176 while (result->NextRow());
177
178 TC_LOG_INFO("server.loading", ">> Loaded {} lfg dungeon rewards in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
179}
180
182{
183 LFGDungeonContainer::const_iterator itr = LfgDungeonStore.find(id);
184 if (itr != LfgDungeonStore.end())
185 return &(itr->second);
186
187 return nullptr;
188}
189
191{
192 uint32 oldMSTime = getMSTime();
193
194 LfgDungeonStore.clear();
195
196 // Initialize Dungeon map with data from dbcs
197 for (uint32 i = 0; i < sLFGDungeonsStore.GetNumRows(); ++i)
198 {
199 LFGDungeonsEntry const* dungeon = sLFGDungeonsStore.LookupEntry(i);
200 if (!dungeon)
201 continue;
202
203 if (!sDB2Manager.GetMapDifficultyData(dungeon->MapID, Difficulty(dungeon->DifficultyID)))
204 continue;
205
206 switch (dungeon->TypeID)
207 {
208 case LFG_TYPE_DUNGEON:
209 case LFG_TYPE_HEROIC:
210 case LFG_TYPE_RAID:
211 case LFG_TYPE_RANDOM:
212 LfgDungeonStore[dungeon->ID] = LFGDungeonData(dungeon);
213 break;
214 }
215 }
216
217 // Fill teleport locations from DB
218 QueryResult result = WorldDatabase.Query("SELECT dungeonId, position_x, position_y, position_z, orientation, requiredItemLevel FROM lfg_dungeon_template");
219 if (!result)
220 {
221 TC_LOG_INFO("server.loading", ">> Loaded 0 lfg dungeon templates. DB table `lfg_dungeon_template` is empty!");
222 return;
223 }
224
225 uint32 count = 0;
226
227 do
228 {
229 Field* fields = result->Fetch();
230 uint32 dungeonId = fields[0].GetUInt32();
231 LFGDungeonContainer::iterator dungeonItr = LfgDungeonStore.find(dungeonId);
232 if (dungeonItr == LfgDungeonStore.end())
233 {
234 TC_LOG_ERROR("sql.sql", "table `lfg_dungeon_template` contains coordinates for wrong dungeon {}", dungeonId);
235 continue;
236 }
237
238 LFGDungeonData& data = dungeonItr->second;
239 data.x = fields[1].GetFloat();
240 data.y = fields[2].GetFloat();
241 data.z = fields[3].GetFloat();
242 data.o = fields[4].GetFloat();
243 data.requiredItemLevel = fields[5].GetUInt16();
244
245 ++count;
246 }
247 while (result->NextRow());
248
249 TC_LOG_INFO("server.loading", ">> Loaded {} lfg dungeon templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
250
251 CachedDungeonMapStore.clear();
252
253 // Fill all other teleport coords from areatriggers
254 for (LFGDungeonContainer::iterator itr = LfgDungeonStore.begin(); itr != LfgDungeonStore.end(); ++itr)
255 {
256 LFGDungeonData& dungeon = itr->second;
257
258 // No teleport coords in database, load from areatriggers
259 if (dungeon.type != LFG_TYPE_RANDOM && dungeon.x == 0.0f && dungeon.y == 0.0f && dungeon.z == 0.0f)
260 {
261 AreaTriggerTeleport const* at = sObjectMgr->GetMapEntranceTrigger(dungeon.map);
262 if (!at)
263 {
264 TC_LOG_ERROR("sql.sql", "Failed to load dungeon {} (Id: {}), cant find areatrigger for map {}", dungeon.name, dungeon.id, dungeon.map);
265 continue;
266 }
267
268 dungeon.map = at->Loc.GetMapId();
269 dungeon.x = at->Loc.GetPositionX();
270 dungeon.y = at->Loc.GetPositionY();
271 dungeon.z = at->Loc.GetPositionZ();
272 dungeon.o = at->Loc.GetOrientation();
273 }
274
275 if (dungeon.type != LFG_TYPE_RANDOM)
276 CachedDungeonMapStore[dungeon.group].insert(dungeon.id);
277 CachedDungeonMapStore[0].insert(dungeon.id);
278 }
279}
280
282{
283 static LFGMgr instance;
284 return &instance;
285}
286
288{
290 return;
291
292 time_t currTime = GameTime::GetGameTime();
293
294 // Remove obsolete role checks
295 for (LfgRoleCheckContainer::iterator it = RoleChecksStore.begin(); it != RoleChecksStore.end();)
296 {
297 LfgRoleCheckContainer::iterator itRoleCheck = it++;
298 LfgRoleCheck& roleCheck = itRoleCheck->second;
299 if (currTime < roleCheck.cancelTime)
300 continue;
302
303 for (LfgRolesMap::const_iterator itRoles = roleCheck.roles.begin(); itRoles != roleCheck.roles.end(); ++itRoles)
304 {
305 ObjectGuid guid = itRoles->first;
306 RestoreState(guid, "Remove Obsolete RoleCheck");
307 SendLfgRoleCheckUpdate(guid, roleCheck);
308 if (guid == roleCheck.leader)
310 }
311
312 RestoreState(itRoleCheck->first, "Remove Obsolete RoleCheck");
313 RoleChecksStore.erase(itRoleCheck);
314 }
315
316 // Remove obsolete proposals
317 for (LfgProposalContainer::iterator it = ProposalsStore.begin(); it != ProposalsStore.end();)
318 {
319 LfgProposalContainer::iterator itRemove = it++;
320 if (itRemove->second.cancelTime < currTime)
322 }
323
324 // Remove obsolete kicks
325 for (LfgPlayerBootContainer::iterator it = BootsStore.begin(); it != BootsStore.end();)
326 {
327 LfgPlayerBootContainer::iterator itBoot = it++;
328 LfgPlayerBoot& boot = itBoot->second;
329 if (boot.cancelTime < currTime)
330 {
331 boot.inProgress = false;
332 for (LfgAnswerContainer::const_iterator itVotes = boot.votes.begin(); itVotes != boot.votes.end(); ++itVotes)
333 {
334 ObjectGuid pguid = itVotes->first;
335 if (pguid != boot.victim)
336 SendLfgBootProposalUpdate(pguid, boot);
337 }
338 SetVoteKick(itBoot->first, false);
339 BootsStore.erase(itBoot);
340 }
341 }
342
343 uint32 lastProposalId = m_lfgProposalId;
344 // Check if a proposal can be formed with the new groups being added
345 for (LfgQueueContainer::iterator it = QueuesStore.begin(); it != QueuesStore.end(); ++it)
346 if (uint8 newProposals = it->second.FindGroups())
347 TC_LOG_DEBUG("lfg.update", "Found {} new groups in queue {}", newProposals, it->first);
348
349 if (lastProposalId != m_lfgProposalId)
350 {
351 // FIXME lastProposalId ? lastProposalId +1 ?
352 for (LfgProposalContainer::const_iterator itProposal = ProposalsStore.find(m_lfgProposalId); itProposal != ProposalsStore.end(); ++itProposal)
353 {
354 uint32 proposalId = itProposal->first;
355 LfgProposal& proposal = ProposalsStore[proposalId];
356
357 ObjectGuid guid;
358 for (LfgProposalPlayerContainer::const_iterator itPlayers = proposal.players.begin(); itPlayers != proposal.players.end(); ++itPlayers)
359 {
360 guid = itPlayers->first;
362 ObjectGuid gguid = GetGroup(guid);
363 if (!gguid.IsEmpty())
364 {
367 }
368 else
370 SendLfgUpdateProposal(guid, proposal);
371 }
372
373 if (proposal.state == LFG_PROPOSAL_SUCCESS)
374 UpdateProposal(proposalId, guid, true);
375 }
376 }
377
378 // Update all players status queue info
380 {
381 m_QueueTimer = 0;
382 for (LfgQueueContainer::iterator it = QueuesStore.begin(); it != QueuesStore.end(); ++it)
383 it->second.UpdateQueueTimers(it->first, currTime);
384 }
385 else
386 m_QueueTimer += diff;
387}
388
398void LFGMgr::JoinLfg(Player* player, uint8 roles, LfgDungeonSet& dungeons)
399{
400 if (!player || !player->GetSession() || dungeons.empty())
401 return;
402
403 // Sanitize input roles
404 roles &= PLAYER_ROLE_ANY;
405 roles = FilterClassRoles(player, roles);
406
407 // At least 1 role must be selected
409 return;
410
411 Group* grp = player->GetGroup();
412 ObjectGuid guid = player->GetGUID();
413 ObjectGuid gguid = grp ? grp->GetGUID() : guid;
414 LfgJoinResultData joinData;
415 GuidSet players;
416 uint32 rDungeonId = 0;
417 bool isContinue = grp && grp->isLFGGroup() && GetState(gguid) != LFG_STATE_FINISHED_DUNGEON;
418
419 // Do not allow to change dungeon in the middle of a current dungeon
420 if (isContinue)
421 {
422 dungeons.clear();
423 dungeons.insert(GetDungeon(gguid));
424 }
425
426 // Already in queue?
427 LfgState state = GetState(gguid);
428 if (state == LFG_STATE_QUEUED)
429 {
430 LFGQueue& queue = GetQueue(gguid);
431 queue.RemoveFromQueue(gguid);
432 }
433
434 // Check player or group member restrictions
436 joinData.result = LFG_JOIN_NO_SLOTS;
437 else if (player->InBattleground() || player->InArena() || player->InBattlegroundQueue())
439 else if (player->HasAura(LFG_SPELL_DUNGEON_DESERTER))
441 else if (!isContinue && player->HasAura(LFG_SPELL_DUNGEON_COOLDOWN))
443 else if (dungeons.empty())
444 joinData.result = LFG_JOIN_NO_SLOTS;
445 else if (player->HasAura(9454)) // check Freeze debuff
446 joinData.result = LFG_JOIN_NO_SLOTS;
447 else if (grp)
448 {
449 if (grp->GetMembersCount() > MAX_GROUP_SIZE)
451 else
452 {
453 uint8 memberCount = 0;
454 for (GroupReference const& itr : grp->GetMembers())
455 {
456 Player* plrg = itr.GetSource();
461 else if (!isContinue && plrg->HasAura(LFG_SPELL_DUNGEON_COOLDOWN))
463 else if (plrg->InBattleground() || plrg->InArena() || plrg->InBattlegroundQueue())
465 else if (plrg->HasAura(9454)) // check Freeze debuff
466 {
467 joinData.result = LFG_JOIN_NO_SLOTS;
468 joinData.playersMissingRequirement.push_back(plrg->GetName());
469 }
470 ++memberCount;
471 players.insert(plrg->GetGUID());
472
473 if (joinData.result != LFG_JOIN_OK)
474 break;
475 }
476
477 if (joinData.result == LFG_JOIN_OK && memberCount != grp->GetMembersCount())
479 }
480 }
481 else
482 players.insert(player->GetGUID());
483
484 // Check if all dungeons are valid
485 bool isRaid = false;
486 if (joinData.result == LFG_JOIN_OK)
487 {
488 bool isDungeon = false;
489 for (LfgDungeonSet::const_iterator it = dungeons.begin(); it != dungeons.end() && joinData.result == LFG_JOIN_OK; ++it)
490 {
491 LfgType type = GetDungeonType(*it);
492 switch (type)
493 {
494 case LFG_TYPE_RANDOM:
495 if (dungeons.size() > 1) // Only allow 1 random dungeon
496 joinData.result = LFG_JOIN_INVALID_SLOT;
497 else
498 rDungeonId = (*dungeons.begin());
499 [[fallthrough]]; // Random can only be dungeon or heroic dungeon
500 case LFG_TYPE_HEROIC:
501 case LFG_TYPE_DUNGEON:
502 if (isRaid)
504 isDungeon = true;
505 break;
506 case LFG_TYPE_RAID:
507 if (isDungeon)
509 isRaid = true;
510 break;
511 default:
512 joinData.result = LFG_JOIN_INVALID_SLOT;
513 break;
514 }
515 }
516
517 // it could be changed
518 if (joinData.result == LFG_JOIN_OK)
519 {
520 // Expand random dungeons and check restrictions
521 if (rDungeonId)
522 dungeons = GetDungeonsByRandom(rDungeonId);
523
524 // if we have lockmap then there are no compatible dungeons
525 GetCompatibleDungeons(&dungeons, players, &joinData.lockmap, &joinData.playersMissingRequirement, isContinue);
526 if (dungeons.empty())
527 joinData.result = LFG_JOIN_NO_SLOTS;
528 }
529 }
530
531 // Can't join. Send result
532 if (joinData.result != LFG_JOIN_OK)
533 {
534 TC_LOG_DEBUG("lfg.join", "{} joining with {} members. Result: {}, Dungeons: {}",
535 guid.ToString(), grp ? grp->GetMembersCount() : 1, joinData.result, ConcatenateDungeons(dungeons));
536
537 if (!dungeons.empty()) // Only should show lockmap when have no dungeons available
538 joinData.lockmap.clear();
539 player->GetSession()->SendLfgJoinResult(joinData);
540 return;
541 }
542
543 if (isRaid)
544 {
545 TC_LOG_DEBUG("lfg.join", "{} trying to join raid browser and it's disabled.", guid.ToString());
546 return;
547 }
548
550 ticket.RequesterGuid = guid;
551 ticket.Id = GetQueueId(gguid);
553 ticket.Time = int32(GameTime::GetGameTime());
554 std::string debugNames = "";
555 if (grp) // Begin rolecheck
556 {
557 // Create new rolecheck
558 LfgRoleCheck& roleCheck = RoleChecksStore[gguid];
561 roleCheck.leader = guid;
562 roleCheck.dungeons = dungeons;
563 roleCheck.rDungeonId = rDungeonId;
564
565 if (rDungeonId)
566 {
567 dungeons.clear();
568 dungeons.insert(rDungeonId);
569 }
570
572 // Send update to player
574 for (GroupReference const& itr : grp->GetMembers())
575 {
576 Player* plrg = itr.GetSource();
577 ObjectGuid pguid = plrg->GetGUID();
578 plrg->GetSession()->SendLfgUpdateStatus(updateData, true);
580 SetTicket(pguid, ticket);
581 if (!isContinue)
582 SetSelectedDungeons(pguid, dungeons);
583 roleCheck.roles[pguid] = 0;
584 if (!debugNames.empty())
585 debugNames.append(", ");
586 debugNames.append(plrg->GetName());
587 }
588 // Update leader role
589 UpdateRoleCheck(gguid, guid, roles);
590 }
591 else // Add player to queue
592 {
593 LfgRolesMap rolesMap;
594 rolesMap[guid] = roles;
595 LFGQueue& queue = GetQueue(guid);
596 queue.AddQueueData(guid, GameTime::GetGameTime(), dungeons, rolesMap);
597
598 if (!isContinue)
599 {
600 if (rDungeonId)
601 {
602 dungeons.clear();
603 dungeons.insert(rDungeonId);
604 }
605 SetSelectedDungeons(guid, dungeons);
606 }
607 // Send update to player
608 SetTicket(guid, ticket);
609 SetRoles(guid, roles);
613 player->GetSession()->SendLfgJoinResult(joinData);
614 debugNames.append(player->GetName());
615 }
616
617 TC_LOG_DEBUG("lfg.join", "{} joined ({}), Members: {}. Dungeons ({}): {}", guid.ToString(),
618 grp ? "group" : "player", debugNames, uint32(dungeons.size()), ConcatenateDungeons(dungeons));
619}
620
627void LFGMgr::LeaveLfg(ObjectGuid guid, bool disconnected)
628{
629 ObjectGuid gguid = guid.IsParty() ? guid : GetGroup(guid);
630
631 TC_LOG_DEBUG("lfg.leave", "{} left ({})", guid.ToString(), guid == gguid ? "group" : "player");
632
633 LfgState state = GetState(guid);
634 switch (state)
635 {
636 case LFG_STATE_QUEUED:
637 if (!gguid.IsEmpty())
638 {
639 LfgState newState = LFG_STATE_NONE;
640 LfgState oldState = GetOldState(gguid);
641
642 // Set the new state to LFG_STATE_DUNGEON/LFG_STATE_FINISHED_DUNGEON if the group is already in a dungeon
643 // This is required in case a LFG group vote-kicks a player in a dungeon, queues, then leaves the queue (maybe to queue later again)
644 if (Group* group = sGroupMgr->GetGroupByGUID(gguid))
645 if (group->isLFGGroup() && GetDungeon(gguid) && (oldState == LFG_STATE_DUNGEON || oldState == LFG_STATE_FINISHED_DUNGEON))
646 newState = oldState;
647
648 LFGQueue& queue = GetQueue(gguid);
649 queue.RemoveFromQueue(gguid);
650 SetState(gguid, newState);
651 GuidSet const& players = GetPlayers(gguid);
652 for (GuidSet::const_iterator it = players.begin(); it != players.end(); ++it)
653 {
654 SetState(*it, newState);
656 }
657 }
658 else
659 {
660 LFGQueue& queue = GetQueue(guid);
661 queue.RemoveFromQueue(guid);
664 }
665 break;
667 if (!gguid.IsEmpty())
668 UpdateRoleCheck(gguid); // No player to update role = LFG_ROLECHECK_ABORTED
669 break;
671 {
672 // Remove from Proposals
673 LfgProposalContainer::iterator it = ProposalsStore.begin();
674 ObjectGuid pguid = gguid == guid ? GetLeader(gguid) : guid;
675 while (it != ProposalsStore.end())
676 {
677 LfgProposalPlayerContainer::iterator itPlayer = it->second.players.find(pguid);
678 if (itPlayer != it->second.players.end())
679 {
680 // Mark the player/leader of group who left as didn't accept the proposal
681 itPlayer->second.accept = LFG_ANSWER_DENY;
682 break;
683 }
684 ++it;
685 }
686
687 // Remove from queue - if proposal is found, RemoveProposal will call RemoveFromQueue
688 if (it != ProposalsStore.end())
690 break;
691 }
692 case LFG_STATE_NONE:
694 break;
697 if (guid != gguid && !disconnected) // Player
699 break;
700 }
701}
702
704{
705 auto itr = PlayersStore.find(guid);
706 if (itr != PlayersStore.end())
707 return &itr->second.GetTicket();
708
709 return nullptr;
710}
711
719void LFGMgr::UpdateRoleCheck(ObjectGuid gguid, ObjectGuid guid /* = ObjectGuid::Empty */, uint8 roles /* = PLAYER_ROLE_NONE */)
720{
721 if (!gguid)
722 return;
723
724 LfgRolesMap check_roles;
725 LfgRoleCheckContainer::iterator itRoleCheck = RoleChecksStore.find(gguid);
726 if (itRoleCheck == RoleChecksStore.end())
727 return;
728
729 // Sanitize input roles
730 roles &= PLAYER_ROLE_ANY;
731
732 if (!guid.IsEmpty())
733 {
734 if (Player* player = ObjectAccessor::FindPlayer(guid))
735 roles = FilterClassRoles(player, roles);
736 else
737 return;
738 }
739
740 LfgRoleCheck& roleCheck = itRoleCheck->second;
741 bool sendRoleChosen = roleCheck.state != LFG_ROLECHECK_DEFAULT && !guid.IsEmpty();
742
743 if (!guid)
744 roleCheck.state = LFG_ROLECHECK_ABORTED;
745 else if (roles < PLAYER_ROLE_TANK) // Player selected no role.
746 roleCheck.state = LFG_ROLECHECK_NO_ROLE;
747 else
748 {
749 roleCheck.roles[guid] = roles;
750
751 // Check if all players have selected a role
752 LfgRolesMap::const_iterator itRoles = roleCheck.roles.begin();
753 while (itRoles != roleCheck.roles.end() && itRoles->second != PLAYER_ROLE_NONE)
754 ++itRoles;
755
756 if (itRoles == roleCheck.roles.end())
757 {
758 // use temporal var to check roles, CheckGroupRoles modifies the roles
759 check_roles = roleCheck.roles;
761 }
762 }
763
764 LfgDungeonSet dungeons;
765 if (roleCheck.rDungeonId)
766 dungeons.insert(roleCheck.rDungeonId);
767 else
768 dungeons = roleCheck.dungeons;
769
771 for (LfgRolesMap::const_iterator it = roleCheck.roles.begin(); it != roleCheck.roles.end(); ++it)
772 {
773 ObjectGuid pguid = it->first;
774
775 if (sendRoleChosen)
776 SendLfgRoleChosen(pguid, guid, roles);
777
778 SendLfgRoleCheckUpdate(pguid, roleCheck);
779 switch (roleCheck.state)
780 {
782 continue;
785 SetRoles(pguid, it->second);
787 break;
788 default:
789 if (roleCheck.leader == pguid)
790 SendLfgJoinResult(pguid, joinData);
792 RestoreState(pguid, "Rolecheck Failed");
793 break;
794 }
795 }
796
797 if (roleCheck.state == LFG_ROLECHECK_FINISHED)
798 {
800 LFGQueue& queue = GetQueue(gguid);
801 queue.AddQueueData(gguid, time_t(GameTime::GetGameTime()), roleCheck.dungeons, roleCheck.roles);
802 RoleChecksStore.erase(itRoleCheck);
803 }
804 else if (roleCheck.state != LFG_ROLECHECK_INITIALITING)
805 {
806 RestoreState(gguid, "Rolecheck Failed");
807 RoleChecksStore.erase(itRoleCheck);
808 }
809}
810
818void LFGMgr::GetCompatibleDungeons(LfgDungeonSet* dungeons, GuidSet const& players, LfgLockPartyMap* lockMap, std::vector<std::string_view>* playersMissingRequirement, bool isContinue)
819{
820 lockMap->clear();
821
822 std::map<uint32, uint32> lockedDungeons;
823 std::unordered_set<uint32> dungeonsToRemove;
824
825 for (GuidSet::const_iterator it = players.begin(); it != players.end() && !dungeons->empty(); ++it)
826 {
827 ObjectGuid guid = (*it);
828 LfgLockMap cachedLockMap = GetLockedDungeons(guid);
830 for (LfgLockMap::const_iterator it2 = cachedLockMap.begin(); it2 != cachedLockMap.end() && !dungeons->empty(); ++it2)
831 {
832 uint32 dungeonId = (it2->first & 0x00FFFFFF); // Compare dungeon ids
833 LfgDungeonSet::iterator itDungeon = dungeons->find(dungeonId);
834 if (itDungeon != dungeons->end())
835 {
836 bool eraseDungeon = true;
837
838 // Don't remove the dungeon if team members are trying to continue a locked instance
839 if (it2->second.lockStatus == LFG_LOCKSTATUS_RAID_LOCKED && isContinue)
840 {
841 LFGDungeonData const* dungeon = GetLFGDungeon(dungeonId);
842 ASSERT(dungeon);
843 ASSERT(player);
844 MapDb2Entries entries{ dungeon->map, Difficulty(dungeon->difficulty) };
845 if (InstanceLock* playerBind = sInstanceLockMgr.FindActiveInstanceLock(guid, entries))
846 {
847 uint32 dungeonInstanceId = playerBind->GetInstanceId();
848 auto itLockedDungeon = lockedDungeons.find(dungeonId);
849 if (itLockedDungeon == lockedDungeons.end() || itLockedDungeon->second == dungeonInstanceId)
850 eraseDungeon = false;
851
852 lockedDungeons[dungeonId] = dungeonInstanceId;
853 }
854 }
855
856 if (eraseDungeon)
857 dungeonsToRemove.insert(dungeonId);
858
859 (*lockMap)[guid][dungeonId] = it2->second;
860 playersMissingRequirement->push_back(player->GetName());
861 }
862 }
863 }
864
865 for (uint32 dungeonIdToRemove : dungeonsToRemove)
866 dungeons->erase(dungeonIdToRemove);
867
868 if (!dungeons->empty())
869 lockMap->clear();
870}
871
879{
880 if (groles.empty())
881 return false;
882
883 uint8 damage = 0;
884 uint8 tank = 0;
885 uint8 healer = 0;
886
887 for (LfgRolesMap::iterator it = groles.begin(); it != groles.end(); ++it)
888 {
889 uint8 role = it->second & ~PLAYER_ROLE_LEADER;
890 if (role == PLAYER_ROLE_NONE)
891 return false;
892
893 if (role & PLAYER_ROLE_DAMAGE)
894 {
895 if (role != PLAYER_ROLE_DAMAGE)
896 {
897 it->second -= PLAYER_ROLE_DAMAGE;
898 if (CheckGroupRoles(groles))
899 return true;
900 it->second += PLAYER_ROLE_DAMAGE;
901 }
902 else if (damage == LFG_DPS_NEEDED)
903 return false;
904 else
905 damage++;
906 }
907
908 if (role & PLAYER_ROLE_HEALER)
909 {
910 if (role != PLAYER_ROLE_HEALER)
911 {
912 it->second -= PLAYER_ROLE_HEALER;
913 if (CheckGroupRoles(groles))
914 return true;
915 it->second += PLAYER_ROLE_HEALER;
916 }
917 else if (healer == LFG_HEALERS_NEEDED)
918 return false;
919 else
920 healer++;
921 }
922
923 if (role & PLAYER_ROLE_TANK)
924 {
925 if (role != PLAYER_ROLE_TANK)
926 {
927 it->second -= PLAYER_ROLE_TANK;
928 if (CheckGroupRoles(groles))
929 return true;
930 it->second += PLAYER_ROLE_TANK;
931 }
932 else if (tank == LFG_TANKS_NEEDED)
933 return false;
934 else
935 tank++;
936 }
937 }
938 return (tank + healer + damage) == uint8(groles.size());
939}
940
946{
947 GuidList players, tankPlayers, healPlayers, dpsPlayers;
948 GuidList playersToTeleport;
949
950 for (LfgProposalPlayerContainer::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it)
951 {
952 ObjectGuid guid = it->first;
953 if (guid == proposal.leader)
954 players.push_back(guid);
955 else
956 switch (it->second.role & ~PLAYER_ROLE_LEADER)
957 {
958 case PLAYER_ROLE_TANK:
959 tankPlayers.push_back(guid);
960 break;
962 healPlayers.push_back(guid);
963 break;
965 dpsPlayers.push_back(guid);
966 break;
967 default:
968 ABORT_MSG("Invalid LFG role %u", it->second.role);
969 break;
970 }
971
972 if (proposal.isNew || GetGroup(guid) != proposal.group)
973 playersToTeleport.push_back(guid);
974 }
975
976 players.splice(players.end(), tankPlayers);
977 players.splice(players.end(), healPlayers);
978 players.splice(players.end(), dpsPlayers);
979
980 // Set the dungeon difficulty
981 LFGDungeonData const* dungeon = GetLFGDungeon(proposal.dungeonId);
982 ASSERT(dungeon);
983
984 Group* grp = !proposal.group.IsEmpty() ? sGroupMgr->GetGroupByGUID(proposal.group) : nullptr;
985 for (GuidList::const_iterator it = players.begin(); it != players.end(); ++it)
986 {
987 ObjectGuid pguid = (*it);
989 if (!player)
990 continue;
991
992 Group* group = player->GetGroup();
993 if (group && group != grp)
994 group->RemoveMember(player->GetGUID());
995
996 if (!grp)
997 {
998 grp = new Group();
999 grp->ConvertToLFG();
1000 grp->Create(player);
1001 ObjectGuid gguid = grp->GetGUID();
1003 sGroupMgr->AddGroup(grp);
1004 }
1005 else if (group != grp)
1006 grp->AddMember(player);
1007
1008 grp->SetLfgRoles(pguid, proposal.players.find(pguid)->second.role);
1009
1010 // Add the cooldown spell if queued for a random dungeon
1011 LfgDungeonSet const& dungeons = GetSelectedDungeons(player->GetGUID());
1012 if (!dungeons.empty())
1013 {
1014 uint32 rDungeonId = (*dungeons.begin());
1015 LFGDungeonData const* dungeonEntry = GetLFGDungeon(rDungeonId);
1016 if (dungeonEntry && dungeonEntry->type == LFG_TYPE_RANDOM)
1017 player->CastSpell(player, LFG_SPELL_DUNGEON_COOLDOWN, false);
1018 }
1019 }
1020
1021 ASSERT(grp);
1023 ObjectGuid gguid = grp->GetGUID();
1024 SetDungeon(gguid, dungeon->Entry());
1026
1027 _SaveToDB(gguid, grp->GetDbStoreId());
1028
1029 // Teleport Player
1030 for (GuidList::const_iterator it = playersToTeleport.begin(); it != playersToTeleport.end(); ++it)
1031 if (Player* player = ObjectAccessor::FindPlayer(*it))
1032 TeleportPlayer(player, false);
1033
1034 // Update group info
1035 grp->SendUpdate();
1036}
1037
1039{
1040 proposal.id = ++m_lfgProposalId;
1041 ProposalsStore[m_lfgProposalId] = proposal;
1042 return m_lfgProposalId;
1043}
1044
1052void LFGMgr::UpdateProposal(uint32 proposalId, ObjectGuid guid, bool accept)
1053{
1054 // Check if the proposal exists
1055 LfgProposalContainer::iterator itProposal = ProposalsStore.find(proposalId);
1056 if (itProposal == ProposalsStore.end())
1057 return;
1058
1059 LfgProposal& proposal = itProposal->second;
1060
1061 // Check if proposal have the current player
1062 LfgProposalPlayerContainer::iterator itProposalPlayer = proposal.players.find(guid);
1063 if (itProposalPlayer == proposal.players.end())
1064 return;
1065
1066 LfgProposalPlayer& player = itProposalPlayer->second;
1067 player.accept = LfgAnswer(accept);
1068
1069 TC_LOG_DEBUG("lfg.proposal.update", "{}, Proposal {}, Selection: {}", guid.ToString(), proposalId, accept);
1070 if (!accept)
1071 {
1073 return;
1074 }
1075
1076 // check if all have answered and reorder players (leader first)
1077 bool allAnswered = true;
1078 for (LfgProposalPlayerContainer::const_iterator itPlayers = proposal.players.begin(); itPlayers != proposal.players.end(); ++itPlayers)
1079 if (itPlayers->second.accept != LFG_ANSWER_AGREE) // No answer (-1) or not accepted (0)
1080 allAnswered = false;
1081
1082 if (!allAnswered)
1083 {
1084 for (LfgProposalPlayerContainer::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it)
1085 SendLfgUpdateProposal(it->first, proposal);
1086
1087 return;
1088 }
1089
1090 bool sendUpdate = proposal.state != LFG_PROPOSAL_SUCCESS;
1091 proposal.state = LFG_PROPOSAL_SUCCESS;
1092 time_t joinTime = GameTime::GetGameTime();
1093
1094 LFGQueue& queue = GetQueue(guid);
1096 for (LfgProposalPlayerContainer::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it)
1097 {
1098 ObjectGuid pguid = it->first;
1099 ObjectGuid gguid = it->second.group;
1100 uint32 dungeonId = (*GetSelectedDungeons(pguid).begin());
1101 int32 waitTime = -1;
1102 if (sendUpdate)
1103 SendLfgUpdateProposal(pguid, proposal);
1104
1105 if (!gguid.IsEmpty())
1106 {
1107 waitTime = int32((joinTime - queue.GetJoinTime(gguid)) / IN_MILLISECONDS);
1108 SendLfgUpdateStatus(pguid, updateData, false);
1109 }
1110 else
1111 {
1112 waitTime = int32((joinTime - queue.GetJoinTime(pguid)) / IN_MILLISECONDS);
1113 SendLfgUpdateStatus(pguid, updateData, false);
1114 }
1116 SendLfgUpdateStatus(pguid, updateData, true);
1117 SendLfgUpdateStatus(pguid, updateData, false);
1118
1119 // Update timers
1120 uint8 role = GetRoles(pguid);
1121 role &= ~PLAYER_ROLE_LEADER;
1122 switch (role)
1123 {
1124 case PLAYER_ROLE_DAMAGE:
1125 queue.UpdateWaitTimeDps(waitTime, dungeonId);
1126 break;
1127 case PLAYER_ROLE_HEALER:
1128 queue.UpdateWaitTimeHealer(waitTime, dungeonId);
1129 break;
1130 case PLAYER_ROLE_TANK:
1131 queue.UpdateWaitTimeTank(waitTime, dungeonId);
1132 break;
1133 default:
1134 queue.UpdateWaitTimeAvg(waitTime, dungeonId);
1135 break;
1136 }
1137
1138 // Store the number of players that were present in group when joining RFD, used for achievement purposes
1139 if (Player* player = ObjectAccessor::FindConnectedPlayer(pguid))
1140 if (Group* group = player->GetGroup())
1141 PlayersStore[pguid].SetNumberOfPartyMembersAtJoin(group->GetMembersCount());
1142
1144 }
1145
1146 // Remove players/groups from Queue
1147 for (GuidList::const_iterator it = proposal.queues.begin(); it != proposal.queues.end(); ++it)
1148 queue.RemoveFromQueue(*it);
1149
1150 MakeNewGroup(proposal);
1151 ProposalsStore.erase(itProposal);
1152}
1153
1160void LFGMgr::RemoveProposal(LfgProposalContainer::iterator itProposal, LfgUpdateType type)
1161{
1162 LfgProposal& proposal = itProposal->second;
1163 proposal.state = LFG_PROPOSAL_FAILED;
1164
1165 TC_LOG_DEBUG("lfg.proposal.remove", "Proposal {}, state FAILED, UpdateType {}", itProposal->first, type);
1166 // Mark all people that didn't answered as no accept
1168 for (LfgProposalPlayerContainer::iterator it = proposal.players.begin(); it != proposal.players.end(); ++it)
1169 if (it->second.accept == LFG_ANSWER_PENDING)
1170 it->second.accept = LFG_ANSWER_DENY;
1171
1172 // Mark players/groups to be removed
1173 GuidSet toRemove;
1174 for (LfgProposalPlayerContainer::iterator it = proposal.players.begin(); it != proposal.players.end(); ++it)
1175 {
1176 if (it->second.accept == LFG_ANSWER_AGREE)
1177 continue;
1178
1179 ObjectGuid guid = !it->second.group.IsEmpty() ? it->second.group : it->first;
1180 // Player didn't accept or still pending when no secs left
1181 if (it->second.accept == LFG_ANSWER_DENY || type == LFG_UPDATETYPE_PROPOSAL_FAILED)
1182 {
1183 it->second.accept = LFG_ANSWER_DENY;
1184 toRemove.insert(guid);
1185 }
1186 }
1187
1188 // Notify players
1189 for (LfgProposalPlayerContainer::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it)
1190 {
1191 ObjectGuid guid = it->first;
1192 ObjectGuid gguid = !it->second.group.IsEmpty() ? it->second.group : guid;
1193
1194 SendLfgUpdateProposal(guid, proposal);
1195
1196 if (toRemove.find(gguid) != toRemove.end()) // Didn't accept or in same group that someone that didn't accept
1197 {
1198 LfgUpdateData updateData;
1199 if (it->second.accept == LFG_ANSWER_DENY)
1200 {
1201 updateData.updateType = type;
1202 TC_LOG_DEBUG("lfg.proposal.remove", "{} didn't accept. Removing from queue and compatible cache", guid.ToString());
1203 }
1204 else
1205 {
1207 TC_LOG_DEBUG("lfg.proposal.remove", "{} in same group that someone that didn't accept. Removing from queue and compatible cache", guid.ToString());
1208 }
1209
1210 RestoreState(guid, "Proposal Fail (didn't accepted or in group with someone that didn't accept");
1211 if (gguid != guid)
1212 {
1213 RestoreState(it->second.group, "Proposal Fail (someone in group didn't accepted)");
1214 SendLfgUpdateStatus(guid, updateData, true);
1215 }
1216 else
1217 SendLfgUpdateStatus(guid, updateData, false);
1218 }
1219 else
1220 {
1221 TC_LOG_DEBUG("lfg.proposal.remove", "Readding {} to queue.", guid.ToString());
1223 if (gguid != guid)
1224 {
1225 SetState(gguid, LFG_STATE_QUEUED);
1227 }
1228 else
1230 }
1231 }
1232
1233 LFGQueue& queue = GetQueue(proposal.players.begin()->first);
1234 // Remove players/groups from queue
1235 for (GuidSet::const_iterator it = toRemove.begin(); it != toRemove.end(); ++it)
1236 {
1237 ObjectGuid guid = *it;
1238 queue.RemoveFromQueue(guid);
1239 proposal.queues.remove(guid);
1240 }
1241
1242 // Readd to queue
1243 for (GuidList::const_iterator it = proposal.queues.begin(); it != proposal.queues.end(); ++it)
1244 {
1245 ObjectGuid guid = *it;
1246 queue.AddToQueue(guid, true);
1247 }
1248
1249 ProposalsStore.erase(itProposal);
1250}
1251
1260void LFGMgr::InitBoot(ObjectGuid gguid, ObjectGuid kicker, ObjectGuid victim, std::string const& reason)
1261{
1262 SetVoteKick(gguid, true);
1263
1264 LfgPlayerBoot& boot = BootsStore[gguid];
1265 boot.inProgress = true;
1267 boot.reason = reason;
1268 boot.victim = victim;
1269
1270 GuidSet const& players = GetPlayers(gguid);
1271
1272 // Set votes
1273 for (GuidSet::const_iterator itr = players.begin(); itr != players.end(); ++itr)
1274 {
1275 ObjectGuid guid = (*itr);
1276 boot.votes[guid] = LFG_ANSWER_PENDING;
1277 }
1278
1279 boot.votes[victim] = LFG_ANSWER_DENY; // Victim auto vote NO
1280 boot.votes[kicker] = LFG_ANSWER_AGREE; // Kicker auto vote YES
1281
1282 // Notify players
1283 for (GuidSet::const_iterator it = players.begin(); it != players.end(); ++it)
1284 SendLfgBootProposalUpdate(*it, boot);
1285}
1286
1293void LFGMgr::UpdateBoot(ObjectGuid guid, bool accept)
1294{
1295 ObjectGuid gguid = GetGroup(guid);
1296 if (!gguid)
1297 return;
1298
1299 LfgPlayerBootContainer::iterator itBoot = BootsStore.find(gguid);
1300 if (itBoot == BootsStore.end())
1301 return;
1302
1303 LfgPlayerBoot& boot = itBoot->second;
1304
1305 if (boot.votes[guid] != LFG_ANSWER_PENDING) // Cheat check: Player can't vote twice
1306 return;
1307
1308 boot.votes[guid] = LfgAnswer(accept);
1309
1310 uint8 agreeNum = 0;
1311 uint8 denyNum = 0;
1312 for (LfgAnswerContainer::const_iterator itVotes = boot.votes.begin(); itVotes != boot.votes.end(); ++itVotes)
1313 {
1314 switch (itVotes->second)
1315 {
1316 case LFG_ANSWER_PENDING:
1317 break;
1318 case LFG_ANSWER_AGREE:
1319 ++agreeNum;
1320 break;
1321 case LFG_ANSWER_DENY:
1322 ++denyNum;
1323 break;
1324 }
1325 }
1326
1327 // if we don't have enough votes (agree or deny) do nothing
1328 if (agreeNum < LFG_GROUP_KICK_VOTES_NEEDED && (boot.votes.size() - denyNum) >= LFG_GROUP_KICK_VOTES_NEEDED)
1329 return;
1330
1331 // Send update info to all players
1332 boot.inProgress = false;
1333 for (LfgAnswerContainer::const_iterator itVotes = boot.votes.begin(); itVotes != boot.votes.end(); ++itVotes)
1334 {
1335 ObjectGuid pguid = itVotes->first;
1336 if (pguid != boot.victim)
1337 SendLfgBootProposalUpdate(pguid, boot);
1338 }
1339
1340 SetVoteKick(gguid, false);
1341 if (agreeNum == LFG_GROUP_KICK_VOTES_NEEDED) // Vote passed - Kick player
1342 {
1343 if (Group* group = sGroupMgr->GetGroupByGUID(gguid))
1345 DecreaseKicksLeft(gguid);
1346 }
1347 BootsStore.erase(itBoot);
1348}
1349
1357void LFGMgr::TeleportPlayer(Player* player, bool out, bool fromOpcode /*= false*/)
1358{
1359 LFGDungeonData const* dungeon = nullptr;
1360 Group* group = player->GetGroup();
1361
1362 if (group && group->isLFGGroup())
1363 dungeon = GetLFGDungeon(GetDungeon(group->GetGUID()));
1364
1365 if (!dungeon)
1366 {
1367 TC_LOG_DEBUG("lfg.teleport", "Player {} not in group/lfggroup or dungeon not found!",
1368 player->GetName());
1370 return;
1371 }
1372
1373 if (out)
1374 {
1375 TC_LOG_DEBUG("lfg.teleport", "Player {} is being teleported out. Current Map {} - Expected Map {}",
1376 player->GetName(), player->GetMapId(), uint32(dungeon->map));
1377 if (player->GetMapId() == uint32(dungeon->map))
1378 player->TeleportToBGEntryPoint();
1379
1380 return;
1381 }
1382
1384
1385 if (!player->IsAlive())
1387 else if (player->IsFalling() || player->HasUnitState(UNIT_STATE_JUMPING))
1389 else if (player->IsMirrorTimerActive(FATIGUE_TIMER))
1391 else if (player->GetVehicle())
1393 else if (!player->GetCharmedGUID().IsEmpty())
1395 else if (player->HasAura(9454)) // check Freeze debuff
1397 else if (player->GetMapId() != uint32(dungeon->map)) // Do not teleport players in dungeon to the entrance
1398 {
1399 uint32 mapid = dungeon->map;
1400 float x = dungeon->x;
1401 float y = dungeon->y;
1402 float z = dungeon->z;
1403 float orientation = dungeon->o;
1404
1405 if (!fromOpcode)
1406 {
1407 // Select a player inside to be teleported to
1408 for (GroupReference const& itr : group->GetMembers())
1409 {
1410 Player* plrg = itr.GetSource();
1411 if (plrg != player && plrg->GetMapId() == uint32(dungeon->map))
1412 {
1413 mapid = plrg->GetMapId();
1414 x = plrg->GetPositionX();
1415 y = plrg->GetPositionY();
1416 z = plrg->GetPositionZ();
1417 orientation = plrg->GetOrientation();
1418 break;
1419 }
1420 }
1421 }
1422
1423 if (!player->GetMap()->IsDungeon())
1424 player->SetBattlegroundEntryPoint();
1425
1426 player->FinishTaxiFlight();
1427
1428 if (!player->TeleportTo({ .Location = WorldLocation(mapid, x, y, z, orientation), .LfgDungeonsId = dungeon->id }))
1430 }
1431 else
1433
1434 if (error != LFG_TELEPORT_RESULT_NONE)
1435 player->GetSession()->SendLfgTeleportError(error);
1436
1437 TC_LOG_DEBUG("lfg.teleport", "Player {} is being teleported in to map {} "
1438 "(x: {}, y: {}, z: {}) Result: {}", player->GetName(), dungeon->map,
1439 dungeon->x, dungeon->y, dungeon->z, error);
1440}
1441
1449void LFGMgr::OnDungeonEncounterDone(ObjectGuid gguid, std::span<uint32 const> dungeonEncounters, Map const* currMap)
1450{
1451 if (GetState(gguid) == LFG_STATE_FINISHED_DUNGEON) // Shouldn't happen. Do not reward multiple times
1452 {
1453 TC_LOG_DEBUG("lfg.dungeon.finish", "Group: {} already rewarded", gguid.ToString());
1454 return;
1455 }
1456
1457 uint32 gDungeonId = GetDungeon(gguid);
1458 LFGDungeonData const* dungeonDone = GetLFGDungeon(gDungeonId);
1459 // LFGDungeons can point to a DungeonEncounter from any difficulty so we need this kind of lenient check
1460 if (!advstd::ranges::contains(dungeonEncounters, dungeonDone->finalDungeonEncounterId))
1461 return;
1462
1463 FinishDungeon(gguid, gDungeonId, currMap);
1464}
1465
1472void LFGMgr::FinishDungeon(ObjectGuid gguid, const uint32 dungeonId, Map const* currMap)
1473{
1474 uint32 gDungeonId = GetDungeon(gguid);
1475 if (gDungeonId != dungeonId)
1476 {
1477 TC_LOG_DEBUG("lfg.dungeon.finish", "Group {} finished dungeon {} but queued for {}", gguid.ToString(), dungeonId, gDungeonId);
1478 return;
1479 }
1480
1481 if (GetState(gguid) == LFG_STATE_FINISHED_DUNGEON) // Shouldn't happen. Do not reward multiple times
1482 {
1483 TC_LOG_DEBUG("lfg.dungeon.finish", "Group: {} already rewarded", gguid.ToString());
1484 return;
1485 }
1486
1488
1489 GuidSet const& players = GetPlayers(gguid);
1490 for (GuidSet::const_iterator it = players.begin(); it != players.end(); ++it)
1491 {
1492 ObjectGuid guid = (*it);
1494 {
1495 TC_LOG_DEBUG("lfg.dungeon.finish", "Group: {}, Player: {} already rewarded", gguid.ToString(), guid.ToString());
1496 continue;
1497 }
1498
1499 uint32 rDungeonId = 0;
1500 LfgDungeonSet const& dungeons = GetSelectedDungeons(guid);
1501 if (!dungeons.empty())
1502 rDungeonId = (*dungeons.begin());
1503
1505
1506 // Give rewards only if its a random dungeon
1507 LFGDungeonData const* dungeon = GetLFGDungeon(rDungeonId);
1508
1509 if (!dungeon || (dungeon->type != LFG_TYPE_RANDOM && !dungeon->seasonal))
1510 {
1511 TC_LOG_DEBUG("lfg.dungeon.finish", "Group: {}, Player: {} dungeon {} is not random or seasonal", gguid.ToString(), guid.ToString(), rDungeonId);
1512 continue;
1513 }
1514
1515 Player* player = ObjectAccessor::FindPlayer(guid);
1516 if (!player)
1517 {
1518 TC_LOG_DEBUG("lfg.dungeon.finish", "Group: {}, Player: {} not found in world", gguid.ToString(), guid.ToString());
1519 continue;
1520 }
1521
1522 if (player->FindMap() != currMap)
1523 {
1524 TC_LOG_DEBUG("lfg.dungeon.finish", "Group: {}, Player: {} is in a different map", gguid.ToString(), guid.ToString());
1525 continue;
1526 }
1527
1529
1530 LFGDungeonData const* dungeonDone = GetLFGDungeon(dungeonId);
1531 uint32 mapId = dungeonDone ? uint32(dungeonDone->map) : 0;
1532
1533 if (player->GetMapId() != mapId)
1534 {
1535 TC_LOG_DEBUG("lfg.dungeon.finish", "Group: {}, Player: {} is in map {} and should be in {} to get reward", gguid.ToString(), guid.ToString(), player->GetMapId(), mapId);
1536 continue;
1537 }
1538
1540
1541 // Update achievements
1542 if (dungeon->difficulty == DIFFICULTY_HEROIC)
1543 {
1544 uint8 lfdRandomPlayers = 0;
1545 if (uint8 numParty = PlayersStore[guid].GetNumberOfPartyMembersAtJoin())
1546 lfdRandomPlayers = 5 - numParty;
1547 else
1548 lfdRandomPlayers = 4;
1550 }
1551
1552 LfgReward const* reward = GetRandomDungeonReward(rDungeonId, player->GetLevel());
1553 if (!reward)
1554 continue;
1555
1556 bool done = false;
1557 Quest const* quest = sObjectMgr->GetQuestTemplate(reward->firstQuest);
1558 if (!quest)
1559 continue;
1560
1561 // if we can take the quest, means that we haven't done this kind of "run", IE: First Heroic Random of Day.
1562 if (player->CanRewardQuest(quest, false))
1563 player->RewardQuest(quest, LootItemType::Item, 0, nullptr, false);
1564 else
1565 {
1566 done = true;
1567 quest = sObjectMgr->GetQuestTemplate(reward->otherQuest);
1568 if (!quest)
1569 continue;
1570 // we give reward without informing client (retail does this)
1571 player->RewardQuest(quest, LootItemType::Item, 0, nullptr, false);
1572 }
1573
1574 // Give rewards
1575 TC_LOG_DEBUG("lfg.dungeon.finish", "Group: {}, Player: {} done dungeon {}, {} previously done.", gguid.ToString(), guid.ToString(), GetDungeon(gguid), done ? " " : " not");
1576 LfgPlayerRewardData data = LfgPlayerRewardData(dungeon->Entry(), GetDungeon(gguid, false), done, quest);
1577 player->GetSession()->SendLfgPlayerReward(data);
1578 }
1579}
1580
1581// --------------------------------------------------------------------------//
1582// Auxiliar Functions
1583// --------------------------------------------------------------------------//
1584
1592{
1593 LFGDungeonData const* dungeon = GetLFGDungeon(randomdungeon);
1594 uint32 group = dungeon ? dungeon->group : 0;
1595 return CachedDungeonMapStore[group];
1596}
1597
1606{
1607 LfgReward const* rew = nullptr;
1608 LfgRewardContainerBounds bounds = RewardMapStore.equal_range(dungeon & 0x00FFFFFF);
1609 for (LfgRewardContainer::const_iterator itr = bounds.first; itr != bounds.second; ++itr)
1610 {
1611 rew = itr->second;
1612 // ordered properly at loading
1613 if (itr->second->maxLevel >= level)
1614 break;
1615 }
1616
1617 return rew;
1618}
1619
1627{
1628 LFGDungeonData const* dungeon = GetLFGDungeon(dungeonId);
1629 if (!dungeon)
1630 return LFG_TYPE_NONE;
1631
1632 return LfgType(dungeon->type);
1633}
1634
1636{
1637 LfgState state;
1638 if (guid.IsParty())
1639 {
1640 state = GroupsStore[guid].GetState();
1641 TC_LOG_TRACE("lfg.data.group.state.get", "Group: {}, State: {}", guid.ToString(), GetStateString(state));
1642 }
1643 else
1644 {
1645 state = PlayersStore[guid].GetState();
1646 TC_LOG_TRACE("lfg.data.player.state.get", "Player: {}, State: {}", guid.ToString(), GetStateString(state));
1647 }
1648
1649 return state;
1650}
1651
1653{
1654 LfgState state;
1655 if (guid.IsParty())
1656 {
1657 state = GroupsStore[guid].GetOldState();
1658 TC_LOG_TRACE("lfg.data.group.oldstate.get", "Group: {}, Old state: {}", guid.ToString(), state);
1659 }
1660 else
1661 {
1662 state = PlayersStore[guid].GetOldState();
1663 TC_LOG_TRACE("lfg.data.player.oldstate.get", "Player: {}, Old state: {}", guid.ToString(), state);
1664 }
1665
1666 return state;
1667}
1668
1670{
1671 ASSERT(gguid.IsParty());
1672
1673 bool active = GroupsStore[gguid].IsVoteKickActive();
1674 TC_LOG_TRACE("lfg.data.group.votekick.get", "Group: {}, Active: {}", gguid.ToString(), active);
1675
1676 return active;
1677}
1678
1679uint32 LFGMgr::GetDungeon(ObjectGuid guid, bool asId /*= true */)
1680{
1681 uint32 dungeon = GroupsStore[guid].GetDungeon(asId);
1682 TC_LOG_TRACE("lfg.data.group.dungeon.get", "Group: {}, asId: {}, Dungeon: {}", guid.ToString(), asId, dungeon);
1683 return dungeon;
1684}
1685
1687{
1688 uint32 dungeonId = GroupsStore[guid].GetDungeon(true);
1689 uint32 mapId = 0;
1690 if (dungeonId)
1691 if (LFGDungeonData const* dungeon = GetLFGDungeon(dungeonId))
1692 mapId = dungeon->map;
1693
1694 TC_LOG_TRACE("lfg.data.group.dungeon.map", "Group: {}, MapId: {} (DungeonId: {})", guid.ToString(), mapId, dungeonId);
1695
1696 return mapId;
1697}
1698
1700{
1701 uint8 roles = PlayersStore[guid].GetRoles();
1702 TC_LOG_TRACE("lfg.data.player.role.get", "Player: {}, Role: {}", guid.ToString(), roles);
1703 return roles;
1704}
1705
1707{
1708 TC_LOG_TRACE("lfg.data.player.dungeons.selected.get", "Player: {}, Selected Dungeons: {}", guid.ToString(), ConcatenateDungeons(PlayersStore[guid].GetSelectedDungeons()));
1709 return PlayersStore[guid].GetSelectedDungeons();
1710}
1711
1713{
1714 if (GetState(guid) != LFG_STATE_NONE)
1715 {
1716 LfgDungeonSet const& dungeons = GetSelectedDungeons(guid);
1717 if (!dungeons.empty())
1718 {
1719 LFGDungeonData const* dungeon = GetLFGDungeon(*dungeons.begin());
1720 if (dungeon && dungeon->type == LFG_TYPE_RANDOM)
1721 return *dungeons.begin();
1722 }
1723 }
1724
1725 return 0;
1726}
1727
1729{
1730 TC_LOG_TRACE("lfg.data.player.dungeons.locked.get", "Player: {}, LockedDungeons.", guid.ToString());
1731 LfgLockMap lock;
1733 if (!player)
1734 {
1735 TC_LOG_WARN("lfg.data.player.dungeons.locked.get", "Player: {} not ingame while retrieving his LockedDungeons.", guid.ToString());
1736 return lock;
1737 }
1738
1739 uint8 level = player->GetLevel();
1740 uint8 expansion = player->GetSession()->GetExpansion();
1741 LfgDungeonSet const& dungeons = GetDungeonsByRandom(0);
1743
1744 for (LfgDungeonSet::const_iterator it = dungeons.begin(); it != dungeons.end(); ++it)
1745 {
1746 LFGDungeonData const* dungeon = GetLFGDungeon(*it);
1747 if (!dungeon) // should never happen - We provide a list from sLfgDungeonsStore
1748 continue;
1749
1750 uint32 lockStatus = [&]() -> uint32
1751 {
1752 if (denyJoin)
1754 if (dungeon->expansion > expansion)
1756 if (DisableMgr::IsDisabledFor(DISABLE_TYPE_MAP, dungeon->map, player))
1758 if (DisableMgr::IsDisabledFor(DISABLE_TYPE_LFG_MAP, dungeon->map, player))
1760 if (sInstanceLockMgr.FindActiveInstanceLock(guid, { dungeon->map, Difficulty(dungeon->difficulty) }))
1762 if (Optional<ContentTuningLevels> levels = sDB2Manager.GetContentTuningData(dungeon->contentTuningId, player->m_playerData->CtrOptions->ConditionalFlags))
1763 {
1764 if (levels->MinLevel > level)
1766 if (levels->MaxLevel < level)
1768 }
1769 if (dungeon->seasonal && !IsSeasonActive(dungeon->id))
1771 if (dungeon->requiredItemLevel > player->GetAverageItemLevel())
1773 if (AccessRequirement const* ar = sObjectMgr->GetAccessRequirement(dungeon->map, Difficulty(dungeon->difficulty)))
1774 {
1775 if (ar->achievement && !player->HasAchieved(ar->achievement))
1777 if (player->GetTeam() == ALLIANCE && ar->quest_A && !player->GetQuestRewardStatus(ar->quest_A))
1779 if (player->GetTeam() == HORDE && ar->quest_H && !player->GetQuestRewardStatus(ar->quest_H))
1781
1782 if (ar->item)
1783 {
1784 if (!player->HasItemCount(ar->item) && (!ar->item2 || !player->HasItemCount(ar->item2)))
1786 }
1787 else if (ar->item2 && !player->HasItemCount(ar->item2))
1789 }
1790
1791 /* @todo VoA closed if WG is not under team control (LFG_LOCKSTATUS_RAID_LOCKED)
1792 lockData = LFG_LOCKSTATUS_TOO_HIGH_GEAR_SCORE;
1793 lockData = LFG_LOCKSTATUS_ATTUNEMENT_TOO_LOW_LEVEL;
1794 lockData = LFG_LOCKSTATUS_ATTUNEMENT_TOO_HIGH_LEVEL;
1795 */
1796 return 0;
1797 }();
1798
1799 if (lockStatus)
1800 lock[dungeon->Entry()] = LfgLockInfoData(lockStatus, dungeon->requiredItemLevel, player->GetAverageItemLevel());
1801 }
1802
1803 return lock;
1804}
1805
1807{
1808 uint8 kicks = GroupsStore[guid].GetKicksLeft();
1809 TC_LOG_TRACE("lfg.data.group.kickleft.get", "Group: {}, Kicks left: {}", guid.ToString(), kicks);
1810 return kicks;
1811}
1812
1813void LFGMgr::RestoreState(ObjectGuid guid, char const* debugMsg)
1814{
1815 if (guid.IsParty())
1816 {
1817 LfgGroupData& data = GroupsStore[guid];
1818 TC_LOG_TRACE("lfg.data.group.state.restore", "Group: {} ({}), State: {}, Old state: {}",
1819 guid.ToString(), debugMsg, GetStateString(data.GetState()),
1820 GetStateString(data.GetOldState()));
1821
1822 data.RestoreState();
1823 }
1824 else
1825 {
1826 LfgPlayerData& data = PlayersStore[guid];
1827 TC_LOG_TRACE("lfg.data.player.state.restore", "Player: {} ({}), State: {}, Old state: {}",
1828 guid.ToString(), debugMsg, GetStateString(data.GetState()),
1829 GetStateString(data.GetOldState()));
1830
1831 data.RestoreState();
1832 }
1833}
1834
1836{
1837 if (guid.IsParty())
1838 {
1839 LfgGroupData& data = GroupsStore[guid];
1840 TC_LOG_TRACE("lfg.data.group.state.set", "Group: {}, New state: {}, Previous: {}, Old state: {}",
1841 guid.ToString(), GetStateString(state), GetStateString(data.GetState()),
1842 GetStateString(data.GetOldState()));
1843
1844 data.SetState(state);
1845 }
1846 else
1847 {
1848 LfgPlayerData& data = PlayersStore[guid];
1849 TC_LOG_TRACE("lfg.data.player.state.set", "Player: {}, New state: {}, Previous: {}, OldState: {}",
1850 guid.ToString(), GetStateString(state), GetStateString(data.GetState()),
1851 GetStateString(data.GetOldState()));
1852
1853 data.SetState(state);
1854 }
1855}
1856
1857void LFGMgr::SetVoteKick(ObjectGuid gguid, bool active)
1858{
1859 ASSERT(gguid.IsParty());
1860
1861 LfgGroupData& data = GroupsStore[gguid];
1862 TC_LOG_TRACE("lfg.data.group.votekick.set", "Group: {}, New state: {}, Previous: {}",
1863 gguid.ToString(), active, data.IsVoteKickActive());
1864
1865 data.SetVoteKick(active);
1866}
1867
1869{
1870 TC_LOG_TRACE("lfg.data.group.dungeon.set", "Group: {}, Dungeon: {}", guid.ToString(), dungeon);
1871 GroupsStore[guid].SetDungeon(dungeon);
1872}
1873
1875{
1876 TC_LOG_TRACE("lfg.data.player.role.set", "Player: {}, Roles: {}", guid.ToString(), roles);
1877 PlayersStore[guid].SetRoles(roles);
1878}
1879
1881{
1882 TC_LOG_TRACE("lfg.data.player.dungeon.selected.set", "Player: {}, Dungeons: {}", guid.ToString(), ConcatenateDungeons(dungeons));
1883 PlayersStore[guid].SetSelectedDungeons(dungeons);
1884}
1885
1887{
1888 GroupsStore[guid].DecreaseKicksLeft();
1889 TC_LOG_TRACE("lfg.data.group.kicksleft.decrease", "Group: {}, Kicks: {}", guid.ToString(), GroupsStore[guid].GetKicksLeft());
1890}
1891
1893{
1894 PlayersStore[guid].SetTicket(ticket);
1895}
1896
1898{
1899 TC_LOG_TRACE("lfg.data.player.remove", "Player: {}", guid.ToString());
1900 LfgPlayerDataContainer::iterator it = PlayersStore.find(guid);
1901 if (it != PlayersStore.end())
1902 PlayersStore.erase(it);
1903}
1904
1906{
1907 TC_LOG_TRACE("lfg.data.group.remove", "Group: {}", guid.ToString());
1908 LfgGroupDataContainer::iterator it = GroupsStore.find(guid);
1909 if (it == GroupsStore.end())
1910 return;
1911
1912 LfgState state = GetState(guid);
1913 // If group is being formed after proposal success do nothing more
1914 GuidSet const& players = it->second.GetPlayers();
1915 for (ObjectGuid playerGUID : players)
1916 {
1917 SetGroup(playerGUID, ObjectGuid::Empty);
1918 if (state != LFG_STATE_PROPOSAL)
1919 {
1920 SetState(playerGUID, LFG_STATE_NONE);
1922 }
1923 }
1924 GroupsStore.erase(it);
1925}
1926
1928{
1929 uint8 team = PlayersStore[guid].GetTeam();
1930 TC_LOG_TRACE("lfg.data.player.team.get", "Player: {}, Team: {}", guid.ToString(), team);
1931 return team;
1932}
1933
1935{
1936 uint8 allowedRoles = PLAYER_ROLE_LEADER;
1937 for (uint32 i = 0; i < MAX_SPECIALIZATIONS; ++i)
1938 if (ChrSpecializationEntry const* specialization = sDB2Manager.GetChrSpecializationByIndex(player->GetClass(), i))
1939 allowedRoles |= 1 << (specialization->Role + 1);
1940
1941 return roles & allowedRoles;
1942}
1943
1945{
1946 return GroupsStore[gguid].RemovePlayer(guid);
1947}
1948
1950{
1951 GroupsStore[gguid].AddPlayer(guid);
1952}
1953
1955{
1956 GroupsStore[gguid].SetLeader(leader);
1957}
1958
1960{
1962 team = 0;
1963
1964 PlayersStore[guid].SetTeam(team);
1965}
1966
1968{
1969 return PlayersStore[guid].GetGroup();
1970}
1971
1973{
1974 PlayersStore[guid].SetGroup(group);
1975}
1976
1978{
1979 return GroupsStore[guid].GetPlayers();
1980}
1981
1983{
1984 return GroupsStore[guid].GetPlayerCount();
1985}
1986
1988{
1989 return GroupsStore[guid].GetLeader();
1990}
1991
1993{
1996 return plr1 && plr2
1997 && (plr1->GetSocial()->HasIgnore(guid2, plr2->GetSession()->GetAccountGUID())
1998 || plr2->GetSocial()->HasIgnore(guid1, plr1->GetSession()->GetAccountGUID()));
1999}
2000
2002{
2003 if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
2004 player->GetSession()->SendLfgRoleChosen(pguid, roles);
2005}
2006
2008{
2009 if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
2010 player->GetSession()->SendLfgRoleCheckUpdate(roleCheck);
2011}
2012
2013void LFGMgr::SendLfgUpdateStatus(ObjectGuid guid, LfgUpdateData const& data, bool party)
2014{
2015 if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
2016 player->GetSession()->SendLfgUpdateStatus(data, party);
2017}
2018
2020{
2021 if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
2022 player->GetSession()->SendLfgJoinResult(data);
2023}
2024
2026{
2027 if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
2028 player->GetSession()->SendLfgBootProposalUpdate(boot);
2029}
2030
2032{
2033 if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
2034 player->GetSession()->SendLfgUpdateProposal(proposal);
2035}
2036
2038{
2039 if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
2040 player->GetSession()->SendLfgQueueStatus(data);
2041}
2042
2044{
2045 return !guid.IsEmpty() && guid.IsParty() && GroupsStore[guid].IsLfgGroup();
2046}
2047
2049{
2050 if (guid.IsParty())
2051 {
2052 GuidSet const& players = GetPlayers(guid);
2053 ObjectGuid pguid = players.empty() ? ObjectGuid::Empty : (*players.begin());
2054 if (!pguid.IsEmpty())
2055 return GetTeam(pguid);
2056 }
2057
2058 return GetTeam(guid);
2059}
2060
2062{
2063 uint8 queueId = GetQueueId(guid);
2064 return QueuesStore[queueId];
2065}
2066
2067bool LFGMgr::AllQueued(GuidList const& check)
2068{
2069 if (check.empty())
2070 return false;
2071
2072 for (GuidList::const_iterator it = check.begin(); it != check.end(); ++it)
2073 {
2074 LfgState state = GetState(*it);
2075 if (state != LFG_STATE_QUEUED)
2076 {
2077 if (state != LFG_STATE_PROPOSAL)
2078 TC_LOG_DEBUG("lfg.allqueued", "Unexpected state found while trying to form new group. Guid: {}, State: {}", (*it).ToString(), GetStateString(state));
2079
2080 return false;
2081 }
2082 }
2083 return true;
2084}
2085
2087{
2088 uint8 queueId = GetQueueId(guid);
2089 LfgQueueContainer::const_iterator itr = QueuesStore.find(queueId);
2090 if (itr != QueuesStore.end())
2091 return itr->second.GetJoinTime(guid);
2092
2093 return 0;
2094}
2095
2096// Only for debugging purposes
2098{
2099 QueuesStore.clear();
2100}
2101
2103{
2104 return (m_options & option) != 0;
2105}
2106
2108{
2109 return m_options;
2110}
2111
2113{
2114 m_options = options;
2115}
2116
2118{
2119 LfgPlayerData& playerData = PlayersStore[guid];
2120 return LfgUpdateData(LFG_UPDATETYPE_UPDATE_STATUS, playerData.GetState(), playerData.GetSelectedDungeons());
2121}
2122
2124{
2125 switch (dungeonId)
2126 {
2127 case 285: // The Headless Horseman
2129 case 286: // The Frost Lord Ahune
2131 case 287: // Coren Direbrew
2133 case 288: // The Crown Chemical Co.
2135 }
2136 return false;
2137}
2138
2139std::string LFGMgr::DumpQueueInfo(bool full)
2140{
2141 uint32 size = uint32(QueuesStore.size());
2142 std::ostringstream o;
2143
2144 o << "Number of Queues: " << size << "\n";
2145 for (LfgQueueContainer::const_iterator itr = QueuesStore.begin(); itr != QueuesStore.end(); ++itr)
2146 {
2147 std::string const& queued = itr->second.DumpQueueInfo();
2148 std::string const& compatibles = itr->second.DumpCompatibleInfo(full);
2149 o << queued << compatibles;
2150 }
2151
2152 return o.str();
2153}
2154
2156{
2157 LfgDungeonSet dungeons;
2158 dungeons.insert(GetDungeon(gguid));
2159 SetSelectedDungeons(guid, dungeons);
2160 SetState(guid, GetState(gguid));
2161 SetGroup(guid, gguid);
2162 AddPlayerToGroup(gguid, guid);
2163}
2164
2166{
2167 if (GetState(guid) != LFG_STATE_NONE)
2168 {
2169 LfgDungeonSet const& dungeons = GetSelectedDungeons(guid);
2170 if (!dungeons.empty())
2171 {
2172 LFGDungeonData const* dungeon = GetLFGDungeon(*dungeons.begin());
2173 if (dungeon && (dungeon->type == LFG_TYPE_RANDOM || dungeon->seasonal))
2174 return true;
2175 }
2176 }
2177
2178 return false;
2179}
2180
2182{
2183 if (!guid.IsParty())
2184 guid = GetGroup(guid);
2185
2186 if (uint32 dungeonId = GetDungeon(guid, true))
2187 if (LFGDungeonData const* dungeon = GetLFGDungeon(dungeonId))
2188 if (uint32(dungeon->map) == map && dungeon->difficulty == difficulty)
2189 return true;
2190
2191 return false;
2192}
2193
2195{
2196 if (id)
2197 if (LFGDungeonData const* dungeon = GetLFGDungeon(id))
2198 return dungeon->Entry();
2199
2200 return 0;
2201}
2202
2203LfgDungeonSet LFGMgr::GetRandomAndSeasonalDungeons(uint8 level, uint8 expansion, std::span<uint32 const> contentTuningReplacementConditionMask)
2204{
2205 LfgDungeonSet randomDungeons;
2206 for (lfg::LFGDungeonContainer::const_iterator itr = LfgDungeonStore.begin(); itr != LfgDungeonStore.end(); ++itr)
2207 {
2208 lfg::LFGDungeonData const& dungeon = itr->second;
2209 if (!(dungeon.type == lfg::LFG_TYPE_RANDOM || (dungeon.seasonal && sLFGMgr->IsSeasonActive(dungeon.id))))
2210 continue;
2211
2212 if (dungeon.expansion > expansion)
2213 continue;
2214
2215 if (Optional<ContentTuningLevels> levels = sDB2Manager.GetContentTuningData(dungeon.contentTuningId, contentTuningReplacementConditionMask))
2216 if (levels->MinLevel > level || level > levels->MaxLevel)
2217 continue;
2218
2219 randomDungeons.insert(dungeon.Entry());
2220 }
2221 return randomDungeons;
2222}
2223
2224} // namespace lfg
@ CHAR_INS_LFG_DATA
@ CHAR_DEL_LFG_DATA
@ IN_MILLISECONDS
Definition Common.h:38
DB2Storage< LFGDungeonsEntry > sLFGDungeonsStore("LFGDungeons.db2", &LfgDungeonsLoadInfo::Instance)
DB2Storage< JournalEncounterEntry > sJournalEncounterStore("JournalEncounter.db2", &JournalEncounterLoadInfo::Instance)
#define sDB2Manager
Definition DB2Stores.h:569
Difficulty
Definition DBCEnums.h:932
@ DIFFICULTY_NONE
Definition DBCEnums.h:933
@ DIFFICULTY_HEROIC
Definition DBCEnums.h:935
@ CompletedLFGDungeonWithStrangers
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
std::shared_ptr< ResultSet > QueryResult
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
DatabaseWorkerPool< WorldDatabaseConnection > WorldDatabase
Accessor to the world database.
uint8_t uint8
Definition Define.h:156
int32_t int32
Definition Define.h:150
uint32_t uint32
Definition Define.h:154
@ DISABLE_TYPE_MAP
Definition DisableMgr.h:29
@ DISABLE_TYPE_LFG_MAP
Definition DisableMgr.h:35
#define ABORT_MSG
Definition Errors.h:88
#define ASSERT
Definition Errors.h:80
bool IsHolidayActive(HolidayIds id)
#define sGroupMgr
Definition GroupMgr.h:66
#define MAX_GROUP_SIZE
Definition Group.h:50
#define sInstanceLockMgr
#define sLFGMgr
Definition LFGMgr.h:515
#define TC_LOG_DEBUG(filterType__, message__,...)
Definition Log.h:181
#define TC_LOG_ERROR(filterType__, message__,...)
Definition Log.h:190
#define TC_LOG_INFO(filterType__, message__,...)
Definition Log.h:184
#define TC_LOG_WARN(filterType__, message__,...)
Definition Log.h:187
#define TC_LOG_TRACE(filterType__, message__,...)
Definition Log.h:178
std::list< ObjectGuid > GuidList
Definition ObjectGuid.h:433
TypeID
Definition ObjectGuid.h:37
std::set< ObjectGuid > GuidSet
Definition ObjectGuid.h:432
#define sObjectMgr
Definition ObjectMgr.h:1885
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition Optional.h:25
@ FATIGUE_TIMER
Definition Player.h:606
Role Based Access Control related classes definition.
#define MAX_SPECIALIZATIONS
@ ALLIANCE
@ HORDE
@ HOLIDAY_HALLOWS_END
@ HOLIDAY_LOVE_IS_IN_THE_AIR
@ HOLIDAY_MIDSUMMER_FIRE_FESTIVAL
@ HOLIDAY_BREWFEST
@ GROUP_REMOVEMETHOD_KICK_LFG
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
Definition Timer.h:57
uint32 getMSTime()
Definition Timer.h:33
@ UNIT_STATE_JUMPING
Definition Unit.h:279
ObjectGuid const & GetGUID() const
Definition BaseEntity.h:163
Class used to access individual fields of database query result.
Definition Field.h:94
float GetFloat() const noexcept
Definition Field.cpp:85
uint32 GetUInt32() const noexcept
Definition Field.cpp:57
uint16 GetUInt16() const noexcept
Definition Field.cpp:43
uint8 GetUInt8() const noexcept
Definition Field.cpp:29
Definition Group.h:205
bool isLFGGroup() const
Definition Group.cpp:1623
void SendUpdate() const
Definition Group.cpp:828
bool AddMember(Player *player)
Definition Group.cpp:424
void SetDungeonDifficultyID(Difficulty difficulty)
Definition Group.cpp:1285
ObjectGuid GetGUID() const
Definition Group.cpp:1653
uint32 GetMembersCount() const
Definition Group.h:335
void SetLfgRoles(ObjectGuid guid, uint8 roles)
Definition Group.cpp:1455
void ConvertToLFG()
Definition Group.cpp:281
bool RemoveMember(ObjectGuid guid, RemoveMethod method=GROUP_REMOVEMETHOD_DEFAULT, ObjectGuid kicker=ObjectGuid::Empty, const char *reason=nullptr)
Definition Group.cpp:566
GroupRefManager & GetMembers()
Definition Group.h:332
bool Create(Player *leader)
Definition Group.cpp:141
uint32 GetDbStoreId() const
Definition Group.h:312
Definition Map.h:225
bool IsDungeon() const
Definition Map.cpp:3267
static ObjectGuid const Empty
Definition ObjectGuid.h:314
bool IsEmpty() const
Definition ObjectGuid.h:362
std::string ToString() const
bool IsParty() const
Definition ObjectGuid.h:378
bool HasIgnore(ObjectGuid const &ignoreGuid, ObjectGuid const &ignoreAccountGuid)
UF::UpdateField< UF::PlayerData, int32(WowCS::EntityFragment::CGObject), TYPEID_PLAYER > m_playerData
Definition Player.h:3061
PlayerSocial * GetSocial() const
Definition Player.h:1290
bool GetQuestRewardStatus(uint32 quest_id) const
Definition Player.cpp:15945
bool HasItemCount(uint32 item, uint32 count=1, bool inBankAlso=false) const
Definition Player.cpp:9904
void SetBattlegroundEntryPoint()
Definition Player.cpp:24309
bool InBattleground() const
Definition Player.h:2584
bool CanRewardQuest(Quest const *quest, bool msg) const
Definition Player.cpp:14619
bool HasAchieved(uint32 achievementId) const
Definition Player.cpp:27572
bool InBattlegroundQueue(bool ignoreArena=false) const
Definition Player.cpp:25735
WorldSession * GetSession() const
Definition Player.h:2272
void UpdateCriteria(CriteriaType type, uint64 miscValue1=0, uint64 miscValue2=0, uint64 miscValue3=0, WorldObject *ref=nullptr)
Definition Player.cpp:27588
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, TeleportToOptions options=TELE_TO_NONE, Optional< uint32 > instanceId={}, uint32 teleportSpellId=0)
Definition Player.cpp:1226
bool TeleportToBGEntryPoint()
Definition Player.cpp:1478
void FinishTaxiFlight()
Definition Player.cpp:23356
bool IsMirrorTimerActive(MirrorTimerType type) const
Definition Player.cpp:724
float GetAverageItemLevel() const
Definition Player.cpp:30033
static void RemoveFromGroup(Group *group, ObjectGuid guid, RemoveMethod method=GROUP_REMOVEMETHOD_DEFAULT, ObjectGuid kicker=ObjectGuid::Empty, char const *reason=nullptr)
Definition Player.cpp:2178
bool InArena() const
Definition Player.cpp:25849
Group * GetGroup(Optional< uint8 > partyIndex)
Definition Player.h:2796
void RewardQuest(Quest const *quest, LootItemType rewardType, uint32 rewardId, Object *questGiver, bool announce=true)
Definition Player.cpp:15061
Team GetTeam() const
Definition Player.h:2423
void setUInt32(uint8 index, uint32 value)
Vehicle * GetVehicle() const
Definition Unit.h:1784
uint8 GetClass() const
Definition Unit.h:764
ObjectGuid GetCharmedGUID() const
Definition Unit.h:1211
bool IsAlive() const
Definition Unit.h:1185
bool HasUnitState(const uint32 f) const
Definition Unit.h:743
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition Unit.cpp:4804
bool IsFalling() const
Definition Unit.cpp:12939
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3974
uint8 GetLevel() const
Definition Unit.h:757
constexpr uint32 GetMapId() const
Definition Position.h:216
Map * GetMap() const
Definition Object.h:411
Map * FindMap() const
Definition Object.h:412
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2217
std::string const & GetName() const
Definition Object.h:342
void SendLfgJoinResult(lfg::LfgJoinResultData const &joinData)
void SendLfgTeleportError(lfg::LfgTeleportResult err)
ObjectGuid GetAccountGUID() const
void SendLfgPlayerReward(lfg::LfgPlayerRewardData const &lfgPlayerRewardData)
bool HasPermission(uint32 permissionId)
uint8 GetExpansion() const
void SendLfgRoleChosen(ObjectGuid guid, uint8 roles)
void SendLfgUpdateStatus(lfg::LfgUpdateData const &updateData, bool party)
uint8 GetKicksLeft(ObjectGuid gguid)
Get kicks left in current group.
Definition LFGMgr.cpp:1806
uint32 GetSelectedRandomDungeon(ObjectGuid guid)
Get selected random dungeon.
Definition LFGMgr.cpp:1712
void _LoadFromDB(Field *fields, ObjectGuid guid)
Load Lfg group info from DB.
Definition LFGMgr.cpp:71
void InitBoot(ObjectGuid gguid, ObjectGuid kguid, ObjectGuid vguid, std::string const &reason)
Inits new proposal to boot a player.
Definition LFGMgr.cpp:1260
uint32 GetLFGDungeonEntry(uint32 id)
Return Lfg dungeon entry for given dungeon id.
Definition LFGMgr.cpp:2194
void OnDungeonEncounterDone(ObjectGuid gguid, std::span< uint32 const > dungeonEncounters, Map const *currMap)
Check dungeon completion on encounter completion.
Definition LFGMgr.cpp:1449
time_t GetQueueJoinTime(ObjectGuid guid)
Gets queue join time.
Definition LFGMgr.cpp:2086
LfgProposalContainer ProposalsStore
Current Role checks.
Definition LFGMgr.h:502
uint8 GetPlayerCount(ObjectGuid guid)
Gets the player count of given group.
Definition LFGMgr.cpp:1982
void SetSelectedDungeons(ObjectGuid guid, LfgDungeonSet const &dungeons)
Definition LFGMgr.cpp:1880
ObjectGuid GetLeader(ObjectGuid guid)
Get leader of the group (using internal data)
Definition LFGMgr.cpp:1987
void FinishDungeon(ObjectGuid gguid, uint32 dungeonId, Map const *currMap)
Finish the dungeon for the given group. All check are performed using internal lfg data.
Definition LFGMgr.cpp:1472
void TeleportPlayer(Player *player, bool out, bool fromOpcode=false)
Teleport a player to/from selected dungeon.
Definition LFGMgr.cpp:1357
void SendLfgUpdateStatus(ObjectGuid guid, LfgUpdateData const &data, bool party)
Definition LFGMgr.cpp:2013
LfgState GetOldState(ObjectGuid guid)
Get last lfg state (NONE, DUNGEON or FINISHED_DUNGEON)
Definition LFGMgr.cpp:1652
void AddPlayerToGroup(ObjectGuid gguid, ObjectGuid guid)
Adds player to group.
Definition LFGMgr.cpp:1949
void SetGroup(ObjectGuid guid, ObjectGuid group)
Sets player group.
Definition LFGMgr.cpp:1972
LFGDungeonContainer LfgDungeonStore
Stores rewards for random dungeons.
Definition LFGMgr.h:499
void SendLfgBootProposalUpdate(ObjectGuid guid, LfgPlayerBoot const &boot)
Definition LFGMgr.cpp:2025
void SetDungeon(ObjectGuid guid, uint32 dungeon)
Definition LFGMgr.cpp:1868
LfgPlayerBootContainer BootsStore
Current Proposals.
Definition LFGMgr.h:503
uint8 GetTeam(ObjectGuid guid)
Definition LFGMgr.cpp:1927
void SetupGroupMember(ObjectGuid guid, ObjectGuid gguid)
Initializes player data after loading group data from DB.
Definition LFGMgr.cpp:2155
static LFGMgr * instance()
Definition LFGMgr.cpp:281
void SetTicket(ObjectGuid guid, WorldPackets::LFG::RideTicket const &ticket)
Definition LFGMgr.cpp:1892
void RestoreState(ObjectGuid guid, char const *debugMsg)
Definition LFGMgr.cpp:1813
void Update(uint32 diff)
Definition LFGMgr.cpp:287
std::string DumpQueueInfo(bool full=false)
Dumps the state of the queue - Only for internal testing.
Definition LFGMgr.cpp:2139
void SendLfgRoleCheckUpdate(ObjectGuid guid, LfgRoleCheck const &roleCheck)
Definition LFGMgr.cpp:2007
GuidSet const & GetPlayers(ObjectGuid guid)
Definition LFGMgr.cpp:1977
uint32 GetOptions()
Gets current lfg options.
Definition LFGMgr.cpp:2107
LfgDungeonSet const & GetDungeonsByRandom(uint32 randomdungeon)
Definition LFGMgr.cpp:1591
void LeaveLfg(ObjectGuid guid, bool disconnected=false)
Leaves lfg.
Definition LFGMgr.cpp:627
void UpdateBoot(ObjectGuid guid, bool accept)
Updates player boot proposal with new player answer.
Definition LFGMgr.cpp:1293
void LoadRewards()
Loads rewards for random dungeons.
Definition LFGMgr.cpp:121
WorldPackets::LFG::RideTicket const * GetTicket(ObjectGuid guid) const
Gets unique join queue data.
Definition LFGMgr.cpp:703
LfgLockMap GetLockedDungeons(ObjectGuid guid)
Get locked dungeons.
Definition LFGMgr.cpp:1728
void SendLfgJoinResult(ObjectGuid guid, LfgJoinResultData const &data)
Definition LFGMgr.cpp:2019
LfgCachedDungeonContainer CachedDungeonMapStore
Queues.
Definition LFGMgr.h:496
bool isOptionEnabled(uint32 option)
Checks if given lfg option is enabled.
Definition LFGMgr.cpp:2102
void UpdateRoleCheck(ObjectGuid gguid, ObjectGuid guid=ObjectGuid::Empty, uint8 roles=PLAYER_ROLE_NONE)
Updates the role check with player answer.
Definition LFGMgr.cpp:719
void Clean()
Clears queue - Only for internal testing.
Definition LFGMgr.cpp:2097
bool IsVoteKickActive(ObjectGuid gguid)
Get current vote kick state.
Definition LFGMgr.cpp:1669
LfgRoleCheckContainer RoleChecksStore
Definition LFGMgr.h:501
LfgDungeonSet GetRandomAndSeasonalDungeons(uint8 level, uint8 expansion, std::span< uint32 const > contentTuningReplacementConditionMask)
Returns all random and seasonal dungeons for given level and expansion.
Definition LFGMgr.cpp:2203
void SetOptions(uint32 options)
Sets new lfg options.
Definition LFGMgr.cpp:2112
uint32 m_lfgProposalId
used to check interval of update
Definition LFGMgr.h:492
uint8 RemovePlayerFromGroup(ObjectGuid gguid, ObjectGuid guid)
Removes a player from a group.
Definition LFGMgr.cpp:1944
LFGDungeonData const * GetLFGDungeon(uint32 id)
Definition LFGMgr.cpp:181
uint32 GetDungeonMapId(ObjectGuid guid)
Get the map id of the current dungeon.
Definition LFGMgr.cpp:1686
void RemoveProposal(LfgProposalContainer::iterator itProposal, LfgUpdateType type)
Definition LFGMgr.cpp:1160
void RemovePlayerData(ObjectGuid guid)
Definition LFGMgr.cpp:1897
LfgRewardContainer RewardMapStore
Stores all dungeons by groupType.
Definition LFGMgr.h:498
void SetState(ObjectGuid guid, LfgState state)
Definition LFGMgr.cpp:1835
void SendLfgRoleChosen(ObjectGuid guid, ObjectGuid pguid, uint8 roles)
Definition LFGMgr.cpp:2001
bool selectedRandomLfgDungeon(ObjectGuid guid)
Check if given guid applied for random dungeon.
Definition LFGMgr.cpp:2165
bool inLfgDungeonMap(ObjectGuid guid, uint32 map, Difficulty difficulty)
Check if given guid applied for given map and difficulty. Used to know.
Definition LFGMgr.cpp:2181
void SetLeader(ObjectGuid gguid, ObjectGuid leader)
Sets the leader of the group.
Definition LFGMgr.cpp:1954
LfgGroupDataContainer GroupsStore
Player data.
Definition LFGMgr.h:505
void UpdateProposal(uint32 proposalId, ObjectGuid guid, bool accept)
Updates proposal to join dungeon with player answer.
Definition LFGMgr.cpp:1052
LfgState GetState(ObjectGuid guid)
Get current lfg state.
Definition LFGMgr.cpp:1635
LFGQueue & GetQueue(ObjectGuid guid)
Definition LFGMgr.cpp:2061
bool IsLfgGroup(ObjectGuid guid)
Check if given group guid is lfg.
Definition LFGMgr.cpp:2043
void SetRoles(ObjectGuid guid, uint8 roles)
Sets player lfg roles.
Definition LFGMgr.cpp:1874
uint8 GetQueueId(ObjectGuid guid)
Returns queue id.
Definition LFGMgr.cpp:2048
uint32 m_options
used as internal counter for proposals
Definition LFGMgr.h:493
void RemoveGroupData(ObjectGuid guid)
Removes saved group data.
Definition LFGMgr.cpp:1905
void _SaveToDB(ObjectGuid guid, uint32 db_guid)
Definition LFGMgr.cpp:100
static bool CheckGroupRoles(LfgRolesMap &groles)
Checks if given roles match, modifies given roles map with new roles.
Definition LFGMgr.cpp:878
uint32 GetDungeon(ObjectGuid guid, bool asId=true)
Get current dungeon.
Definition LFGMgr.cpp:1679
uint8 FilterClassRoles(Player *player, uint8 roles)
Definition LFGMgr.cpp:1934
LfgPlayerDataContainer PlayersStore
Current player kicks.
Definition LFGMgr.h:504
LfgQueueContainer QueuesStore
Stores config options.
Definition LFGMgr.h:495
uint32 AddProposal(LfgProposal &proposal)
Add a new Proposal.
Definition LFGMgr.cpp:1038
uint8 GetRoles(ObjectGuid guid)
Get current player roles.
Definition LFGMgr.cpp:1699
void SetVoteKick(ObjectGuid gguid, bool active)
Definition LFGMgr.cpp:1857
bool IsSeasonActive(uint32 dungeonId)
Checks if Seasonal dungeon is active.
Definition LFGMgr.cpp:2123
bool AllQueued(GuidList const &check)
Checks if all players are queued.
Definition LFGMgr.cpp:2067
LfgType GetDungeonType(uint32 dungeon)
Definition LFGMgr.cpp:1626
void GetCompatibleDungeons(LfgDungeonSet *dungeons, GuidSet const &players, LfgLockPartyMap *lockMap, std::vector< std::string_view > *playersMissingRequirement, bool isContinue)
Definition LFGMgr.cpp:818
void DecreaseKicksLeft(ObjectGuid guid)
Definition LFGMgr.cpp:1886
void LoadLFGDungeons()
Loads dungeons from dbc and adds teleport coords.
Definition LFGMgr.cpp:190
LfgDungeonSet const & GetSelectedDungeons(ObjectGuid guid)
Get selected dungeons.
Definition LFGMgr.cpp:1706
static bool HasIgnore(ObjectGuid guid1, ObjectGuid guid2)
Checks if given players are ignoring each other.
Definition LFGMgr.cpp:1992
static void SendLfgQueueStatus(ObjectGuid guid, LfgQueueStatusData const &data)
Sends queue status to player.
Definition LFGMgr.cpp:2037
ObjectGuid GetGroup(ObjectGuid guid)
Gets player group.
Definition LFGMgr.cpp:1967
void SetTeam(ObjectGuid guid, uint8 team)
Sets player team.
Definition LFGMgr.cpp:1959
LfgReward const * GetRandomDungeonReward(uint32 dungeon, uint8 level)
Gets the random dungeon reward corresponding to given dungeon and player level.
Definition LFGMgr.cpp:1605
void MakeNewGroup(LfgProposal const &proposal)
Definition LFGMgr.cpp:945
void JoinLfg(Player *player, uint8 roles, LfgDungeonSet &dungeons)
Join Lfg with selected roles, dungeons and comment.
Definition LFGMgr.cpp:398
void SendLfgUpdateProposal(ObjectGuid guid, LfgProposal const &proposal)
Definition LFGMgr.cpp:2031
LfgUpdateData GetLfgStatus(ObjectGuid guid)
Returns current lfg status.
Definition LFGMgr.cpp:2117
uint32 m_QueueTimer
Definition LFGMgr.h:491
void AddQueueData(ObjectGuid guid, time_t joinTime, LfgDungeonSet const &dungeons, LfgRolesMap const &rolesMap)
Definition LFGQueue.cpp:193
time_t GetJoinTime(ObjectGuid guid) const
Definition LFGQueue.cpp:638
void AddToQueue(ObjectGuid guid, bool reAdd=false)
Definition LFGQueue.cpp:128
void UpdateWaitTimeAvg(int32 waitTime, uint32 dungeonId)
Definition LFGQueue.cpp:206
void RemoveFromQueue(ObjectGuid guid)
Definition LFGQueue.cpp:143
void UpdateWaitTimeHealer(int32 waitTime, uint32 dungeonId)
Definition LFGQueue.cpp:220
void UpdateWaitTimeTank(int32 waitTime, uint32 dungeonId)
Definition LFGQueue.cpp:213
void UpdateWaitTimeDps(int32 waitTime, uint32 dungeonId)
Definition LFGQueue.cpp:227
bool IsVoteKickActive() const
void SetVoteKick(bool active)
LfgState GetState() const
void SetState(LfgState state)
LfgState GetOldState() const
LfgState GetOldState() const
void SetState(LfgState state)
LfgState GetState() const
LfgDungeonSet const & GetSelectedDungeons() const
#define sWorld
Definition World.h:916
@ CONFIG_MAX_PLAYER_LEVEL
Definition World.h:262
@ CONFIG_LFG_OPTIONSMASK
Definition World.h:377
@ CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP
Definition World.h:112
bool IsDisabledFor(DisableType type, uint32 entry, WorldObject const *ref, uint8 flags)
time_t GetGameTime()
Definition GameTime.cpp:52
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
struct advstd::ranges::Contains contains
Definition LFG.cpp:24
@ LFG_LOCKSTATUS_INSUFFICIENT_EXPANSION
Definition LFG.h:98
@ LFG_LOCKSTATUS_TOO_LOW_LEVEL
Definition LFG.h:99
@ LFG_LOCKSTATUS_RAID_LOCKED
Definition LFG.h:103
@ LFG_LOCKSTATUS_TOO_LOW_GEAR_SCORE
Definition LFG.h:101
@ LFG_LOCKSTATUS_MISSING_ITEM
Definition LFG.h:109
@ LFG_LOCKSTATUS_TOO_HIGH_LEVEL
Definition LFG.h:100
@ LFG_LOCKSTATUS_MISSING_ACHIEVEMENT
Definition LFG.h:111
@ LFG_LOCKSTATUS_NOT_IN_SEASON
Definition LFG.h:110
@ LFG_LOCKSTATUS_QUEST_NOT_COMPLETED
Definition LFG.h:108
@ LFG_HEALERS_NEEDED
Definition LFG.h:33
@ LFG_TANKS_NEEDED
Definition LFG.h:32
@ LFG_DPS_NEEDED
Definition LFG.h:34
@ LFG_OPTION_ENABLE_DUNGEON_FINDER
Definition LFGMgr.h:50
@ LFG_OPTION_ENABLE_RAID_BROWSER
Definition LFGMgr.h:51
std::map< ObjectGuid, uint8 > LfgRolesMap
Definition LFG.h:135
LfgUpdateType
Definition LFG.h:48
@ LFG_UPDATETYPE_ROLECHECK_FAILED
Definition LFG.h:53
@ LFG_UPDATETYPE_GROUP_FOUND
Definition LFG.h:57
@ LFG_UPDATETYPE_ADDED_TO_QUEUE
Definition LFG.h:58
@ LFG_UPDATETYPE_UPDATE_STATUS
Definition LFG.h:61
@ LFG_UPDATETYPE_PROPOSAL_FAILED
Definition LFG.h:55
@ LFG_UPDATETYPE_PROPOSAL_DECLINED
Definition LFG.h:56
@ LFG_UPDATETYPE_REMOVED_FROM_QUEUE
Definition LFG.h:54
@ LFG_UPDATETYPE_PROPOSAL_BEGIN
Definition LFG.h:60
@ LFG_UPDATETYPE_JOIN_QUEUE
Definition LFG.h:52
@ LFG_UPDATETYPE_JOIN_QUEUE_INITIAL
Definition LFG.h:64
@ LFG_SPELL_DUNGEON_COOLDOWN
Definition LFGMgr.h:60
@ LFG_TIME_BOOT
Definition LFGMgr.h:57
@ LFG_GROUP_KICK_VOTES_NEEDED
Definition LFGMgr.h:63
@ LFG_TIME_ROLECHECK
Definition LFGMgr.h:56
@ LFG_QUEUEUPDATE_INTERVAL
Definition LFGMgr.h:59
@ LFG_SPELL_DUNGEON_DESERTER
Definition LFGMgr.h:61
LfgType
Determines the type of instance.
Definition LFGMgr.h:76
@ LFG_TYPE_NONE
Definition LFGMgr.h:77
@ LFG_TYPE_RANDOM
Definition LFGMgr.h:83
@ LFG_TYPE_RAID
Definition LFGMgr.h:79
@ LFG_TYPE_DUNGEON
Definition LFGMgr.h:78
@ LFG_TYPE_HEROIC
Definition LFGMgr.h:82
LfgAnswer
Answer state (Also used to check compatibilites)
Definition LFG.h:116
@ LFG_ANSWER_AGREE
Definition LFG.h:119
@ LFG_ANSWER_PENDING
Definition LFG.h:117
@ LFG_ANSWER_DENY
Definition LFG.h:118
std::string GetStateString(LfgState state)
Definition LFG.cpp:75
LfgTeleportResult
Teleport errors.
Definition LFGMgr.h:96
@ LFG_TELEPORT_RESULT_EXHAUSTION
Definition LFGMgr.h:102
@ LFG_TELEPORT_RESULT_FALLING
Definition LFGMgr.h:100
@ LFG_TELEPORT_RESULT_NO_RETURN_LOCATION
Definition LFGMgr.h:103
@ LFG_TELEPORT_RESULT_ON_TRANSPORT
Definition LFGMgr.h:101
@ LFG_TELEPORT_RESULT_IMMUNE_TO_SUMMONS
Definition LFGMgr.h:104
@ LFG_TELEPORT_RESULT_NONE
Definition LFGMgr.h:98
@ LFG_TELEPORT_RESULT_DEAD
Definition LFGMgr.h:99
std::set< uint32 > LfgDungeonSet
Definition LFG.h:132
@ LFG_ROLECHECK_WRONG_ROLES
Definition LFGMgr.h:151
@ LFG_ROLECHECK_MISSING_ROLE
Definition LFGMgr.h:150
@ LFG_ROLECHECK_ABORTED
Definition LFGMgr.h:152
@ LFG_ROLECHECK_DEFAULT
Definition LFGMgr.h:147
@ LFG_ROLECHECK_FINISHED
Definition LFGMgr.h:148
@ LFG_ROLECHECK_NO_ROLE
Definition LFGMgr.h:153
@ LFG_ROLECHECK_INITIALITING
Definition LFGMgr.h:149
@ LFG_FLAG_SEASONAL
Definition LFGMgr.h:70
std::string ConcatenateDungeons(LfgDungeonSet const &dungeons)
Definition LFG.cpp:26
std::pair< LfgRewardContainer::const_iterator, LfgRewardContainer::const_iterator > LfgRewardContainerBounds
Definition LFGMgr.h:167
@ PLAYER_ROLE_DAMAGE
Definition LFG.h:43
@ PLAYER_ROLE_ANY
Definition LFG.h:44
@ PLAYER_ROLE_TANK
Definition LFG.h:41
@ PLAYER_ROLE_NONE
Definition LFG.h:39
@ PLAYER_ROLE_LEADER
Definition LFG.h:40
@ PLAYER_ROLE_HEALER
Definition LFG.h:42
std::map< ObjectGuid, LfgLockMap > LfgLockPartyMap
Definition LFG.h:134
LfgState
Definition LFG.h:74
@ LFG_STATE_RAIDBROWSER
Definition LFG.h:82
@ LFG_STATE_ROLECHECK
Definition LFG.h:76
@ LFG_STATE_FINISHED_DUNGEON
Definition LFG.h:81
@ LFG_STATE_DUNGEON
Definition LFG.h:80
@ LFG_STATE_PROPOSAL
Definition LFG.h:78
@ LFG_STATE_NONE
Definition LFG.h:75
@ LFG_STATE_QUEUED
Definition LFG.h:77
std::map< uint32, LfgLockInfoData > LfgLockMap
Definition LFG.h:133
@ LFG_PROPOSAL_SUCCESS
Definition LFGMgr.h:91
@ LFG_PROPOSAL_FAILED
Definition LFGMgr.h:90
@ LFG_JOIN_RANDOM_COOLDOWN_PLAYER
Definition LFGMgr.h:127
@ LFG_JOIN_NO_SLOTS
Definition LFGMgr.h:119
@ LFG_JOIN_MEMBERS_NOT_PRESENT
Definition LFGMgr.h:122
@ LFG_JOIN_ROLE_CHECK_FAILED
Definition LFGMgr.h:131
@ LFG_JOIN_RANDOM_COOLDOWN_PARTY
Definition LFGMgr.h:128
@ LFG_JOIN_TOO_MANY_MEMBERS
Definition LFGMgr.h:129
@ LFG_JOIN_CANT_USE_DUNGEONS
Definition LFGMgr.h:130
@ LFG_JOIN_OK
Definition LFGMgr.h:116
@ LFG_JOIN_MISMATCHED_SLOTS
Definition LFGMgr.h:120
@ LFG_JOIN_NO_LFG_OBJECT
Definition LFGMgr.h:118
@ LFG_JOIN_DESERTER_PLAYER
Definition LFGMgr.h:125
@ LFG_JOIN_INVALID_SLOT
Definition LFGMgr.h:124
@ LFG_JOIN_DESERTER_PARTY
Definition LFGMgr.h:126
@ RBAC_PERM_JOIN_DUNGEON_FINDER
Definition RBAC.h:59
constexpr float GetPositionX() const
Definition Position.h:87
constexpr float GetPositionY() const
Definition Position.h:88
constexpr float GetOrientation() const
Definition Position.h:90
constexpr float GetPositionZ() const
Definition Position.h:89
WorldLocation Loc
Definition ObjectMgr.h:836
uint32 contentTuningId
Definition LFGMgr.h:307
Difficulty difficulty
Definition LFGMgr.h:308
uint32 finalDungeonEncounterId
Definition LFGMgr.h:312
uint16 requiredItemLevel
Definition LFGMgr.h:311
std::string name
Definition LFGMgr.h:302
uint32 Entry() const
Definition LFGMgr.h:315
std::vector< std::string_view > playersMissingRequirement
Definition LFGMgr.h:186
LfgJoinResult result
Definition LFGMgr.h:183
LfgLockPartyMap lockmap
Definition LFGMgr.h:185
Stores information of a current vote to kick someone from a group.
Definition LFGMgr.h:288
std::string reason
Player guid to be kicked (can't vote)
Definition LFGMgr.h:293
time_t cancelTime
Definition LFGMgr.h:289
LfgAnswerContainer votes
Vote in progress.
Definition LFGMgr.h:291
bool inProgress
Time left to vote.
Definition LFGMgr.h:290
ObjectGuid victim
Player votes (-1 not answer | 0 Not agree | 1 agree)
Definition LFGMgr.h:292
Stores player data related to proposal to join.
Definition LFGMgr.h:248
LfgAnswer accept
Proposed role.
Definition LFGMgr.h:251
Stores group data related to proposal to join.
Definition LFGMgr.h:257
ObjectGuid leader
Proposal group (0 if new)
Definition LFGMgr.h:266
uint32 dungeonId
Proposal Id.
Definition LFGMgr.h:263
GuidList queues
Determines if it's new group or not.
Definition LFGMgr.h:270
LfgProposalPlayerContainer players
Show order in update window.
Definition LFGMgr.h:272
bool isNew
Dungeon Encounters.
Definition LFGMgr.h:269
LfgProposalState state
Dungeon to join.
Definition LFGMgr.h:264
ObjectGuid group
State of the proposal.
Definition LFGMgr.h:265
Reward info.
Definition LFGMgr.h:237
uint32 firstQuest
Definition LFGMgr.h:242
uint32 otherQuest
Definition LFGMgr.h:243
Stores all rolecheck info of a group that wants to join.
Definition LFGMgr.h:277
LfgDungeonSet dungeons
State of the rolecheck.
Definition LFGMgr.h:281
LfgRolesMap roles
Time when the rolecheck will fail.
Definition LFGMgr.h:279
LfgRoleCheckState state
Player selected roles.
Definition LFGMgr.h:280
time_t cancelTime
Definition LFGMgr.h:278
ObjectGuid leader
Random Dungeon Id.
Definition LFGMgr.h:283
uint32 rDungeonId
Dungeons group is applying for (expanded random dungeons)
Definition LFGMgr.h:282
LfgUpdateType updateType
Definition LFGMgr.h:198