TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
lfg::LFGMgr Class Reference

#include <LFGMgr.h>

Public Member Functions

void Update (uint32 diff)
 
void FinishDungeon (ObjectGuid gguid, uint32 dungeonId)
 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 constGetSelectedDungeons (ObjectGuid guid)
 Get selected dungeons. More...
 
LfgState GetState (ObjectGuid guid)
 Get current lfg state. More...
 
bool IsVoteKickActive (ObjectGuid gguid)
 Get current vote kick 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 constGetComment (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...
 
std::string DumpQueueInfo (bool full=false)
 Dumps the state of the queue - Only for internal testing. More...
 
ObjectGuid GetLeader (ObjectGuid guid)
 Get leader of the group (using internal data) More...
 
void SetTeam (ObjectGuid guid, uint8 team)
 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...
 
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 constGetRandomDungeonReward (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, bool fromOpcode=false)
 Teleport a player to/from selected dungeon. More...
 
void InitBoot (ObjectGuid gguid, ObjectGuid kguid, ObjectGuid vguid, 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, bool disconnected=false)
 Leaves lfg. More...
 
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...
 
uint8 GetQueueId (ObjectGuid guid)
 Returns queue id. More...
 
bool AllQueued (GuidList const &check)
 Checks if all players are queued. More...
 
time_t GetQueueJoinTime (ObjectGuid guid)
 Gets queue join time. More...
 

Static Public Member Functions

static LFGMgrinstance ()
 
static bool CheckGroupRoles (LfgRolesMap &groles)
 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 Member Functions

 LFGMgr ()
 
 ~LFGMgr ()
 
uint8 GetTeam (ObjectGuid guid)
 
void RestoreState (ObjectGuid guid, char const *debugMsg)
 
void ClearState (ObjectGuid guid, char const *debugMsg)
 
void SetDungeon (ObjectGuid guid, uint32 dungeon)
 
void SetSelectedDungeons (ObjectGuid guid, LfgDungeonSet const &dungeons)
 
void DecreaseKicksLeft (ObjectGuid guid)
 
void SetState (ObjectGuid guid, LfgState state)
 
void SetVoteKick (ObjectGuid gguid, bool active)
 
void RemovePlayerData (ObjectGuid guid)
 
void GetCompatibleDungeons (LfgDungeonSet &dungeons, GuidSet const &players, LfgLockPartyMap &lockMap, bool isContinue)
 
void _SaveToDB (ObjectGuid guid, uint32 db_guid)
 
LFGDungeonData constGetLFGDungeon (uint32 id)
 
void RemoveProposal (LfgProposalContainer::iterator itProposal, LfgUpdateType type)
 
void MakeNewGroup (LfgProposal const &proposal)
 
LFGQueueGetQueue (ObjectGuid guid)
 
LfgDungeonSet constGetDungeonsByRandom (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 SendLfgUpdateStatus (ObjectGuid guid, LfgUpdateData const &data, bool party)
 
void SendLfgUpdateProposal (ObjectGuid guid, LfgProposal const &proposal)
 
GuidSet constGetPlayers (ObjectGuid guid)
 

Private Attributes

uint32 m_QueueTimer
 used to check interval of update More...
 
uint32 m_lfgProposalId
 used as internal counter for proposals More...
 
uint32 m_options
 Stores config options. 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...
 

Constructor & Destructor Documentation

lfg::LFGMgr::LFGMgr ( )
private
42 {
43  new LFGPlayerScript();
44  new LFGGroupScript();
45 }
uint32 m_options
Stores config options.
Definition: LFGMgr.h:464
uint32 m_lfgProposalId
used as internal counter for proposals
Definition: LFGMgr.h:463
#define sWorld
Definition: World.h:887
Definition: World.h:342
uint32 m_QueueTimer
used to check interval of update
Definition: LFGMgr.h:462
lfg::LFGMgr::~LFGMgr ( )
private
48 {
49  for (LfgRewardContainer::iterator itr = RewardMapStore.begin(); itr != RewardMapStore.end(); ++itr)
50  delete itr->second;
51 }
LfgRewardContainer RewardMapStore
Stores rewards for random dungeons.
Definition: LFGMgr.h:469

Member Function Documentation

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

Load Lfg group info from DB.

54 {
55  if (!fields)
56  return;
57 
58  if (!guid.IsParty())
59  return;
60 
61  SetLeader(guid, ObjectGuid::Create<HighGuid::Player>(fields[0].GetUInt64()));
62 
63  uint32 dungeon = fields[18].GetUInt32();
64  uint8 state = fields[19].GetUInt8();
65 
66  if (!dungeon || !state)
67  return;
68 
69  SetDungeon(guid, dungeon);
70 
71  switch (state)
72  {
73  case LFG_STATE_DUNGEON:
75  SetState(guid, (LfgState)state);
76  break;
77  default:
78  break;
79  }
80 }
LfgState
Definition: LFG.h:65
Definition: LFG.h:72
uint8 GetUInt8() const
Definition: Field.h:70
uint32_t uint32
Definition: Define.h:150
void SetState(ObjectGuid guid, LfgState state)
Definition: LFGMgr.cpp:1682
void SetLeader(ObjectGuid gguid, ObjectGuid leader)
Sets the leader of the group.
Definition: LFGMgr.cpp:1792
void SetDungeon(ObjectGuid guid, uint32 dungeon)
Definition: LFGMgr.cpp:1715
uint32 GetUInt32() const
Definition: Field.h:146
uint8_t uint8
Definition: Define.h:152
bool IsParty() const
Definition: ObjectGuid.h:258

+ Here is the call graph for this function:

void lfg::LFGMgr::_SaveToDB ( ObjectGuid  guid,
uint32  db_guid 
)
private
83 {
84  if (!guid.IsParty())
85  return;
86 
88 
89  stmt->setUInt32(0, db_guid);
90 
92 
94  stmt->setUInt32(0, db_guid);
95 
96  stmt->setUInt32(1, GetDungeon(guid));
97  stmt->setUInt32(2, GetState(guid));
98 
100 }
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
LfgState GetState(ObjectGuid guid)
Get current lfg state.
Definition: LFGMgr.cpp:1500
Definition: CharacterDatabase.h:371
Definition: PreparedStatement.h:74
uint32 GetDungeon(ObjectGuid guid, bool asId=true)
Get current dungeon.
Definition: LFGMgr.cpp:1544
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
Definition: CharacterDatabase.h:372
bool IsParty() const
Definition: ObjectGuid.h:258

+ Here is the call graph for this function:

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

Adds player to group.

1788 {
1789  GroupsStore[gguid].AddPlayer(guid);
1790 }
LfgGroupDataContainer GroupsStore
Group data.
Definition: LFGMgr.h:476
uint32 lfg::LFGMgr::AddProposal ( LfgProposal proposal)

Add a new Proposal.

951 {
952  proposal.id = ++m_lfgProposalId;
953  ProposalsStore[m_lfgProposalId] = proposal;
954  return m_lfgProposalId;
955 }
uint32 m_lfgProposalId
used as internal counter for proposals
Definition: LFGMgr.h:463
LfgProposalContainer ProposalsStore
Current Proposals.
Definition: LFGMgr.h:473
bool lfg::LFGMgr::AllQueued ( GuidList const check)

Checks if all players are queued.

1904 {
1905  if (check.empty())
1906  return false;
1907 
1908  for (GuidList::const_iterator it = check.begin(); it != check.end(); ++it)
1909  if (GetState(*it) != LFG_STATE_QUEUED)
1910  return false;
1911  return true;
1912 }
LfgState GetState(ObjectGuid guid)
Get current lfg state.
Definition: LFGMgr.cpp:1500
Definition: LFG.h:69
T check(T value)
Definition: format.h:305
bool lfg::LFGMgr::CheckGroupRoles ( LfgRolesMap groles)
static

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

Check if a group can be formed with the given group roles

Parameters
[in]grolesMap of roles to check
Returns
True if roles are compatible
815 {
816  if (groles.empty())
817  return false;
818 
819  uint8 damage = 0;
820  uint8 tank = 0;
821  uint8 healer = 0;
822 
823  for (LfgRolesMap::iterator it = groles.begin(); it != groles.end(); ++it)
824  {
825  uint8 role = it->second & ~PLAYER_ROLE_LEADER;
826  if (role == PLAYER_ROLE_NONE)
827  return false;
828 
829  if (role & PLAYER_ROLE_DAMAGE)
830  {
831  if (role != PLAYER_ROLE_DAMAGE)
832  {
833  it->second -= PLAYER_ROLE_DAMAGE;
834  if (CheckGroupRoles(groles))
835  return true;
836  it->second += PLAYER_ROLE_DAMAGE;
837  }
838  else if (damage == LFG_DPS_NEEDED)
839  return false;
840  else
841  damage++;
842  }
843 
844  if (role & PLAYER_ROLE_HEALER)
845  {
846  if (role != PLAYER_ROLE_HEALER)
847  {
848  it->second -= PLAYER_ROLE_HEALER;
849  if (CheckGroupRoles(groles))
850  return true;
851  it->second += PLAYER_ROLE_HEALER;
852  }
853  else if (healer == LFG_HEALERS_NEEDED)
854  return false;
855  else
856  healer++;
857  }
858 
859  if (role & PLAYER_ROLE_TANK)
860  {
861  if (role != PLAYER_ROLE_TANK)
862  {
863  it->second -= PLAYER_ROLE_TANK;
864  if (CheckGroupRoles(groles))
865  return true;
866  it->second += PLAYER_ROLE_TANK;
867  }
868  else if (tank == LFG_TANKS_NEEDED)
869  return false;
870  else
871  tank++;
872  }
873  }
874  return (tank + healer + damage) == uint8(groles.size());
875 }
Definition: LFG.h:39
static bool CheckGroupRoles(LfgRolesMap &groles)
Checks if given roles match, modifies given roles map with new roles.
Definition: LFGMgr.cpp:814
Definition: LFG.h:37
Definition: LFG.h:36
Definition: LFG.h:40
Definition: LFG.h:29
Definition: LFG.h:30
uint8_t uint8
Definition: g3dmath.h:164
Definition: LFG.h:31
Definition: LFG.h:38
uint8_t uint8
Definition: Define.h:152

+ Here is the caller graph for this function:

void lfg::LFGMgr::Clean ( )

Clears queue - Only for internal testing.

1926 {
1927  QueuesStore.clear();
1928 }
LfgQueueContainer QueuesStore
Queues.
Definition: LFGMgr.h:466
void lfg::LFGMgr::ClearState ( ObjectGuid  guid,
char const debugMsg 
)
private
void lfg::LFGMgr::DecreaseKicksLeft ( ObjectGuid  guid)
private
1740 {
1741  GroupsStore[guid].DecreaseKicksLeft();
1742  TC_LOG_TRACE("lfg.data.group.kicksleft.decrease", "Group: %s, Kicks: %u", guid.ToString().c_str(), GroupsStore[guid].GetKicksLeft());
1743 }
#define TC_LOG_TRACE(filterType__,...)
Definition: Log.h:195
LfgGroupDataContainer GroupsStore
Group data.
Definition: LFGMgr.h:476
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

std::string lfg::LFGMgr::DumpQueueInfo ( bool  full = false)

Dumps the state of the queue - Only for internal testing.

1968 {
1969  uint32 size = uint32(QueuesStore.size());
1970  std::ostringstream o;
1971 
1972  o << "Number of Queues: " << size << "\n";
1973  for (LfgQueueContainer::const_iterator itr = QueuesStore.begin(); itr != QueuesStore.end(); ++itr)
1974  {
1975  std::string const& queued = itr->second.DumpQueueInfo();
1976  std::string const& compatibles = itr->second.DumpCompatibleInfo(full);
1977  o << queued << compatibles;
1978  }
1979 
1980  return o.str();
1981 }
LfgQueueContainer QueuesStore
Queues.
Definition: LFGMgr.h:466
uint32_t uint32
Definition: Define.h:150
uint32_t uint32
Definition: g3dmath.h:168
void lfg::LFGMgr::FinishDungeon ( ObjectGuid  gguid,
uint32  dungeonId 
)

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
1355 {
1356  uint32 gDungeonId = GetDungeon(gguid);
1357  if (gDungeonId != dungeonId)
1358  {
1359  TC_LOG_DEBUG("lfg.dungeon.finish", "Group %s finished dungeon %u but queued for %u", gguid.ToString().c_str(), dungeonId, gDungeonId);
1360  return;
1361  }
1362 
1363  if (GetState(gguid) == LFG_STATE_FINISHED_DUNGEON) // Shouldn't happen. Do not reward multiple times
1364  {
1365  TC_LOG_DEBUG("lfg.dungeon.finish", "Group: %s already rewarded", gguid.ToString().c_str());
1366  return;
1367  }
1368 
1370 
1371  GuidSet const& players = GetPlayers(gguid);
1372  for (GuidSet::const_iterator it = players.begin(); it != players.end(); ++it)
1373  {
1374  ObjectGuid guid = (*it);
1375  if (GetState(guid) == LFG_STATE_FINISHED_DUNGEON)
1376  {
1377  TC_LOG_DEBUG("lfg.dungeon.finish", "Group: %s, Player: %s already rewarded", gguid.ToString().c_str(), guid.ToString().c_str());
1378  continue;
1379  }
1380 
1381  uint32 rDungeonId = 0;
1382  const LfgDungeonSet& dungeons = GetSelectedDungeons(guid);
1383  if (!dungeons.empty())
1384  rDungeonId = (*dungeons.begin());
1385 
1387 
1388  // Give rewards only if its a random dungeon
1389  LFGDungeonData const* dungeon = GetLFGDungeon(rDungeonId);
1390 
1391  if (!dungeon || (dungeon->type != LFG_TYPE_RANDOM && !dungeon->seasonal))
1392  {
1393  TC_LOG_DEBUG("lfg.dungeon.finish", "Group: %s, Player: %s dungeon %u is not random or seasonal", gguid.ToString().c_str(), guid.ToString().c_str(), rDungeonId);
1394  continue;
1395  }
1396 
1397  Player* player = ObjectAccessor::FindPlayer(guid);
1398  if (!player)
1399  {
1400  TC_LOG_DEBUG("lfg.dungeon.finish", "Group: %s, Player: %s not found in world", gguid.ToString().c_str(), guid.ToString().c_str());
1401  continue;
1402  }
1403 
1404  LFGDungeonData const* dungeonDone = GetLFGDungeon(dungeonId);
1405  uint32 mapId = dungeonDone ? uint32(dungeonDone->map) : 0;
1406 
1407  if (player->GetMapId() != mapId)
1408  {
1409  TC_LOG_DEBUG("lfg.dungeon.finish", "Group: %s, Player: %s is in map %u and should be in %u to get reward", gguid.ToString().c_str(), guid.ToString().c_str(), player->GetMapId(), mapId);
1410  continue;
1411  }
1412 
1413  // Update achievements
1414  if (dungeon->difficulty == DIFFICULTY_HEROIC)
1415  player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_USE_LFD_TO_GROUP_WITH_PLAYERS, 1);
1416 
1417  LfgReward const* reward = GetRandomDungeonReward(rDungeonId, player->getLevel());
1418  if (!reward)
1419  continue;
1420 
1421  bool done = false;
1422  Quest const* quest = sObjectMgr->GetQuestTemplate(reward->firstQuest);
1423  if (!quest)
1424  continue;
1425 
1426  // if we can take the quest, means that we haven't done this kind of "run", IE: First Heroic Random of Day.
1427  if (player->CanRewardQuest(quest, false))
1428  player->RewardQuest(quest, 0, NULL, false);
1429  else
1430  {
1431  done = true;
1432  quest = sObjectMgr->GetQuestTemplate(reward->otherQuest);
1433  if (!quest)
1434  continue;
1435  // we give reward without informing client (retail does this)
1436  player->RewardQuest(quest, 0, NULL, false);
1437  }
1438 
1439  // Give rewards
1440  TC_LOG_DEBUG("lfg.dungeon.finish", "Group: %s, Player: %s done dungeon %u, %s previously done.", gguid.ToString().c_str(), guid.ToString().c_str(), GetDungeon(gguid), done ? " " : " not");
1441  LfgPlayerRewardData data = LfgPlayerRewardData(dungeon->Entry(), GetDungeon(gguid, false), done, quest);
1442  player->GetSession()->SendLfgPlayerReward(data);
1443  }
1444 }
Definition: DBCEnums.h:406
Definition: QuestDef.h:279
LfgState GetState(ObjectGuid guid)
Get current lfg state.
Definition: LFGMgr.cpp:1500
Definition: LFGMgr.h:68
LfgReward const * GetRandomDungeonReward(uint32 dungeon, uint8 level)
Gets the random dungeon reward corresponding to given dungeon and player level.
Definition: LFGMgr.cpp:1470
LfgDungeonSet const & GetSelectedDungeons(ObjectGuid guid)
Get selected dungeons.
Definition: LFGMgr.cpp:1577
arena_t NULL
Definition: jemalloc_internal.h:624
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
#define sObjectMgr
Definition: ObjectMgr.h:1567
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
LFGDungeonData const * GetLFGDungeon(uint32 id)
Definition: LFGMgr.cpp:163
std::set< uint32 > LfgDungeonSet
Definition: LFG.h:112
uint32_t uint32
Definition: Define.h:150
uint32 GetDungeon(ObjectGuid guid, bool asId=true)
Get current dungeon.
Definition: LFGMgr.cpp:1544
void SetState(ObjectGuid guid, LfgState state)
Definition: LFGMgr.cpp:1682
GuidSet const & GetPlayers(ObjectGuid guid)
Definition: LFGMgr.cpp:1815
std::set< ObjectGuid > GuidSet
Definition: ObjectGuid.h:332
Definition: ObjectGuid.h:189
uint32_t uint32
Definition: g3dmath.h:168
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

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

Get current player comment (used for LFR)

1572 {
1573  TC_LOG_TRACE("lfg.data.player.comment.get", "Player: %s, Comment: %s", guid.ToString().c_str(), PlayersStore[guid].GetComment().c_str());
1574  return PlayersStore[guid].GetComment();
1575 }
#define TC_LOG_TRACE(filterType__,...)
Definition: Log.h:195
LfgPlayerDataContainer PlayersStore
Player data.
Definition: LFGMgr.h:475

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void lfg::LFGMgr::GetCompatibleDungeons ( LfgDungeonSet dungeons,
GuidSet const players,
LfgLockPartyMap lockMap,
bool  isContinue 
)
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)
759 {
760  lockMap.clear();
761 
762  std::map<uint32, uint32> lockedDungeons;
763 
764  for (GuidSet::const_iterator it = players.begin(); it != players.end() && !dungeons.empty(); ++it)
765  {
766  ObjectGuid guid = (*it);
767  LfgLockMap const& cachedLockMap = GetLockedDungeons(guid);
769  for (LfgLockMap::const_iterator it2 = cachedLockMap.begin(); it2 != cachedLockMap.end() && !dungeons.empty(); ++it2)
770  {
771  uint32 dungeonId = (it2->first & 0x00FFFFFF); // Compare dungeon ids
772  LfgDungeonSet::iterator itDungeon = dungeons.find(dungeonId);
773  if (itDungeon != dungeons.end())
774  {
775  bool eraseDungeon = true;
776 
777  // Don't remove the dungeon if team members are trying to continue a locked instance
778  if (it2->second.lockStatus == LFG_LOCKSTATUS_RAID_LOCKED && isContinue)
779  {
780  LFGDungeonData const* dungeon = GetLFGDungeon(dungeonId);
781  ASSERT(dungeon);
782  ASSERT(player);
783  if (InstancePlayerBind* playerBind = player->GetBoundInstance(dungeon->map, Difficulty(dungeon->difficulty)))
784  {
785  if (InstanceSave* playerSave = playerBind->save)
786  {
787  uint32 dungeonInstanceId = playerSave->GetInstanceId();
788  auto itLockedDungeon = lockedDungeons.find(dungeonId);
789  if (itLockedDungeon == lockedDungeons.end() || itLockedDungeon->second == dungeonInstanceId)
790  eraseDungeon = false;
791 
792  lockedDungeons[dungeonId] = dungeonInstanceId;
793  }
794  }
795  }
796 
797  if (eraseDungeon)
798  dungeons.erase(itDungeon);
799 
800  lockMap[guid][dungeonId] = it2->second;
801  }
802  }
803  }
804  if (!dungeons.empty())
805  lockMap.clear();
806 }
Difficulty
Definition: DBCEnums.h:402
LFGDungeonData const * GetLFGDungeon(uint32 id)
Definition: LFGMgr.cpp:163
std::map< uint32, LfgLockInfoData > LfgLockMap
Definition: LFG.h:113
uint32_t uint32
Definition: Define.h:150
Definition: InstanceSaveMgr.h:44
#define ASSERT
Definition: Errors.h:55
LfgLockMap const GetLockedDungeons(ObjectGuid guid)
Get locked dungeons.
Definition: LFGMgr.cpp:1583
Definition: ObjectGuid.h:189
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:215

+ Here is the call graph for this function:

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

Get current dungeon.

1545 {
1546  uint32 dungeon = GroupsStore[guid].GetDungeon(asId);
1547  TC_LOG_TRACE("lfg.data.group.dungeon.get", "Group: %s, asId: %u, Dungeon: %u", guid.ToString().c_str(), asId, dungeon);
1548  return dungeon;
1549 }
#define TC_LOG_TRACE(filterType__,...)
Definition: Log.h:195
uint32_t uint32
Definition: Define.h:150
LfgGroupDataContainer GroupsStore
Group data.
Definition: LFGMgr.h:476
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Get the map id of the current dungeon.

1552 {
1553  uint32 dungeonId = GroupsStore[guid].GetDungeon(true);
1554  uint32 mapId = 0;
1555  if (dungeonId)
1556  if (LFGDungeonData const* dungeon = GetLFGDungeon(dungeonId))
1557  mapId = dungeon->map;
1558 
1559  TC_LOG_TRACE("lfg.data.group.dungeon.map", "Group: %s, MapId: %u (DungeonId: %u)", guid.ToString().c_str(), mapId, dungeonId);
1560 
1561  return mapId;
1562 }
LFGDungeonData const * GetLFGDungeon(uint32 id)
Definition: LFGMgr.cpp:163
#define TC_LOG_TRACE(filterType__,...)
Definition: Log.h:195
uint32_t uint32
Definition: Define.h:150
LfgGroupDataContainer GroupsStore
Group data.
Definition: LFGMgr.h:476
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

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.
1457 {
1458  LFGDungeonData const* dungeon = GetLFGDungeon(randomdungeon);
1459  uint32 group = dungeon ? dungeon->group : 0;
1460  return CachedDungeonMapStore[group];
1461 }
LFGDungeonData const * GetLFGDungeon(uint32 id)
Definition: LFGMgr.cpp:163
uint32_t uint32
Definition: Define.h:150
LfgCachedDungeonContainer CachedDungeonMapStore
Stores all dungeons by groupType.
Definition: LFGMgr.h:467

+ Here is the call graph for this function:

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

Given a Dungeon id returns the dungeon Type

Parameters
[in]dungeondungeon id
Returns
Dungeon type
1492 {
1493  LFGDungeonData const* dungeon = GetLFGDungeon(dungeonId);
1494  if (!dungeon)
1495  return LFG_TYPE_NONE;
1496 
1497  return LfgType(dungeon->type);
1498 }
Definition: LFGMgr.h:64
LfgType
Determines the type of instance.
Definition: LFGMgr.h:62
LFGDungeonData const * GetLFGDungeon(uint32 id)
Definition: LFGMgr.cpp:163

+ Here is the call graph for this function:

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

Gets player group.

1806 {
1807  return PlayersStore[guid].GetGroup();
1808 }
LfgPlayerDataContainer PlayersStore
Player data.
Definition: LFGMgr.h:475

+ Here is the caller graph for this function:

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

Get kicks left in current group.

1654 {
1655  uint8 kicks = GroupsStore[guid].GetKicksLeft();
1656  TC_LOG_TRACE("lfg.data.group.kickleft.get", "Group: %s, Kicks left: %u", guid.ToString().c_str(), kicks);
1657  return kicks;
1658 }
#define TC_LOG_TRACE(filterType__,...)
Definition: Log.h:195
uint8_t uint8
Definition: Define.h:152
LfgGroupDataContainer GroupsStore
Group data.
Definition: LFGMgr.h:476

+ Here is the call graph for this function:

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

Get leader of the group (using internal data)

1826 {
1827  return GroupsStore[guid].GetLeader();
1828 }
LfgGroupDataContainer GroupsStore
Group data.
Definition: LFGMgr.h:476
LFGDungeonData const * lfg::LFGMgr::GetLFGDungeon ( uint32  id)
private
164 {
165  LFGDungeonContainer::const_iterator itr = LfgDungeonStore.find(id);
166  if (itr != LfgDungeonStore.end())
167  return &(itr->second);
168 
169  return NULL;
170 }
arena_t NULL
Definition: jemalloc_internal.h:624
LFGDungeonContainer LfgDungeonStore
Definition: LFGMgr.h:470
uint32 lfg::LFGMgr::GetLFGDungeonEntry ( uint32  id)

Return Lfg dungeon entry for given dungeon id.

2023 {
2024  if (id)
2025  if (LFGDungeonData const* dungeon = GetLFGDungeon(id))
2026  return dungeon->Entry();
2027 
2028  return 0;
2029 }
LFGDungeonData const * GetLFGDungeon(uint32 id)
Definition: LFGMgr.cpp:163

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Returns current lfg status.

1946 {
1947  LfgPlayerData& playerData = PlayersStore[guid];
1948  return LfgUpdateData(LFG_UPDATETYPE_UPDATE_STATUS, playerData.GetState(), playerData.GetSelectedDungeons());
1949 }
LfgPlayerDataContainer PlayersStore
Player data.
Definition: LFGMgr.h:475

+ Here is the call graph for this function:

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

Get locked dungeons.

1584 {
1585  TC_LOG_TRACE("lfg.data.player.dungeons.locked.get", "Player: %s, LockedDungeons.", guid.ToString().c_str());
1586  LfgLockMap lock;
1588  if (!player)
1589  {
1590  TC_LOG_WARN("lfg.data.player.dungeons.locked.get", "Player: %s not ingame while retrieving his LockedDungeons.", guid.ToString().c_str());
1591  return lock;
1592  }
1593 
1594  uint8 level = player->getLevel();
1595  uint8 expansion = player->GetSession()->GetExpansion();
1596  LfgDungeonSet const& dungeons = GetDungeonsByRandom(0);
1597  bool denyJoin = !player->GetSession()->HasPermission(rbac::RBAC_PERM_JOIN_DUNGEON_FINDER);
1598 
1599  for (LfgDungeonSet::const_iterator it = dungeons.begin(); it != dungeons.end(); ++it)
1600  {
1601  LFGDungeonData const* dungeon = GetLFGDungeon(*it);
1602  if (!dungeon) // should never happen - We provide a list from sLFGDungeonStore
1603  continue;
1604 
1605  uint32 lockStatus = 0;
1606  if (denyJoin)
1607  lockStatus = LFG_LOCKSTATUS_RAID_LOCKED;
1608  else if (dungeon->expansion > expansion)
1610  else if (DisableMgr::IsDisabledFor(DISABLE_TYPE_MAP, dungeon->map, player))
1611  lockStatus = LFG_LOCKSTATUS_RAID_LOCKED;
1612  else if (dungeon->difficulty > DIFFICULTY_NORMAL && player->GetBoundInstance(dungeon->map, Difficulty(dungeon->difficulty)))
1613  lockStatus = LFG_LOCKSTATUS_RAID_LOCKED;
1614  else if (dungeon->minlevel > level)
1615  lockStatus = LFG_LOCKSTATUS_TOO_LOW_LEVEL;
1616  else if (dungeon->maxlevel < level)
1617  lockStatus = LFG_LOCKSTATUS_TOO_HIGH_LEVEL;
1618  else if (dungeon->seasonal && !IsSeasonActive(dungeon->id))
1619  lockStatus = LFG_LOCKSTATUS_NOT_IN_SEASON;
1620  else if (dungeon->requiredItemLevel > player->GetAverageItemLevel())
1621  lockStatus = LFG_LOCKSTATUS_TOO_LOW_GEAR_SCORE;
1622  else if (AccessRequirement const* ar = sObjectMgr->GetAccessRequirement(dungeon->map, Difficulty(dungeon->difficulty)))
1623  {
1624  if (ar->achievement && !player->HasAchieved(ar->achievement))
1626  else if (player->GetTeam() == ALLIANCE && ar->quest_A && !player->GetQuestRewardStatus(ar->quest_A))
1628  else if (player->GetTeam() == HORDE && ar->quest_H && !player->GetQuestRewardStatus(ar->quest_H))
1630  else
1631  if (ar->item)
1632  {
1633  if (!player->HasItemCount(ar->item) && (!ar->item2 || !player->HasItemCount(ar->item2)))
1634  lockStatus = LFG_LOCKSTATUS_MISSING_ITEM;
1635  }
1636  else if (ar->item2 && !player->HasItemCount(ar->item2))
1637  lockStatus = LFG_LOCKSTATUS_MISSING_ITEM;
1638  }
1639 
1640  /* @todo VoA closed if WG is not under team control (LFG_LOCKSTATUS_RAID_LOCKED)
1641  lockData = LFG_LOCKSTATUS_TOO_HIGH_GEAR_SCORE;
1642  lockData = LFG_LOCKSTATUS_ATTUNEMENT_TOO_LOW_LEVEL;
1643  lockData = LFG_LOCKSTATUS_ATTUNEMENT_TOO_HIGH_LEVEL;
1644  */
1645 
1646  if (lockStatus)
1647  lock[dungeon->Entry()] = LfgLockInfoData(lockStatus, dungeon->requiredItemLevel, player->GetAverageItemLevel());
1648  }
1649 
1650  return lock;
1651 }
Difficulty
Definition: DBCEnums.h:402
bool IsDisabledFor(DisableType type, uint32 entry, Unit const *unit, uint8 flags)
Definition: DisableMgr.cpp:277
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: SharedDefines.h:1000
LFGDungeonData const * GetLFGDungeon(uint32 id)
Definition: LFGMgr.cpp:163
std::map< uint32, LfgLockInfoData > LfgLockMap
Definition: LFG.h:113
#define TC_LOG_TRACE(filterType__,...)
Definition: Log.h:195
std::set< uint32 > LfgDungeonSet
Definition: LFG.h:112
uint32_t uint32
Definition: Define.h:150
bool IsSeasonActive(uint32 dungeonId)
Checks if Seasonal dungeon is active.
Definition: LFGMgr.cpp:1951
Definition: SharedDefines.h:999
LfgDungeonSet const & GetDungeonsByRandom(uint32 randomdungeon)
Definition: LFGMgr.cpp:1456
Definition: DisableMgr.h:31
#define TC_LOG_WARN(filterType__,...)
Definition: Log.h:204
uint8_t uint8
Definition: Define.h:152
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:215
std::string ToString() const
Definition: ObjectGuid.cpp:99
Definition: DBCEnums.h:405

+ Here is the call graph for this function:

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

Get last lfg state (NONE, DUNGEON or FINISHED_DUNGEON)

1518 {
1519  LfgState state;
1520  if (guid.IsParty())
1521  {
1522  state = GroupsStore[guid].GetOldState();
1523  TC_LOG_TRACE("lfg.data.group.oldstate.get", "Group: %s, Old state: %u", guid.ToString().c_str(), state);
1524  }
1525  else
1526  {
1527  state = PlayersStore[guid].GetOldState();
1528  TC_LOG_TRACE("lfg.data.player.oldstate.get", "Player: %s, Old state: %u", guid.ToString().c_str(), state);
1529  }
1530 
1531  return state;
1532 }
LfgState
Definition: LFG.h:65
#define TC_LOG_TRACE(filterType__,...)
Definition: Log.h:195
LfgPlayerDataContainer PlayersStore
Player data.
Definition: LFGMgr.h:475
LfgGroupDataContainer GroupsStore
Group data.
Definition: LFGMgr.h:476
bool IsParty() const
Definition: ObjectGuid.h:258
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

uint32 lfg::LFGMgr::GetOptions ( )

Gets current lfg options.

1936 {
1937  return m_options;
1938 }
uint32 m_options
Stores config options.
Definition: LFGMgr.h:464
uint8 lfg::LFGMgr::GetPlayerCount ( ObjectGuid  guid)

Gets the player count of given group.

1821 {
1822  return GroupsStore[guid].GetPlayerCount();
1823 }
LfgGroupDataContainer GroupsStore
Group data.
Definition: LFGMgr.h:476
GuidSet const & lfg::LFGMgr::GetPlayers ( ObjectGuid  guid)
private
1816 {
1817  return GroupsStore[guid].GetPlayers();
1818 }
LfgGroupDataContainer GroupsStore
Group data.
Definition: LFGMgr.h:476
LFGQueue & lfg::LFGMgr::GetQueue ( ObjectGuid  guid)
private
1898 {
1899  uint8 queueId = GetQueueId(guid);
1900  return QueuesStore[queueId];
1901 }
LfgQueueContainer QueuesStore
Queues.
Definition: LFGMgr.h:466
uint8 GetQueueId(ObjectGuid guid)
Returns queue id.
Definition: LFGMgr.cpp:1884
uint8_t uint8
Definition: Define.h:152

+ Here is the caller graph for this function:

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

Returns queue id.

1885 {
1886  if (guid.IsParty())
1887  {
1888  GuidSet const& players = GetPlayers(guid);
1889  ObjectGuid pguid = players.empty() ? ObjectGuid::Empty : (*players.begin());
1890  if (!pguid.IsEmpty())
1891  return GetTeam(pguid);
1892  }
1893 
1894  return GetTeam(guid);
1895 }
uint8 GetTeam(ObjectGuid guid)
Definition: LFGMgr.cpp:1775
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
GuidSet const & GetPlayers(ObjectGuid guid)
Definition: LFGMgr.cpp:1815
std::set< ObjectGuid > GuidSet
Definition: ObjectGuid.h:332
Definition: ObjectGuid.h:189
bool IsParty() const
Definition: ObjectGuid.h:258
bool IsEmpty() const
Definition: ObjectGuid.h:242

+ Here is the call graph for this function:

time_t lfg::LFGMgr::GetQueueJoinTime ( ObjectGuid  guid)

Gets queue join time.

1915 {
1916  uint8 queueId = GetQueueId(guid);
1917  LfgQueueContainer::const_iterator itr = QueuesStore.find(queueId);
1918  if (itr != QueuesStore.end())
1919  return itr->second.GetJoinTime(guid);
1920 
1921  return 0;
1922 }
LfgQueueContainer QueuesStore
Queues.
Definition: LFGMgr.h:466
uint8 GetQueueId(ObjectGuid guid)
Returns queue id.
Definition: LFGMgr.cpp:1884
uint8_t uint8
Definition: Define.h:152
LfgDungeonSet lfg::LFGMgr::GetRandomAndSeasonalDungeons ( uint8  level,
uint8  expansion 
)

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

2032 {
2033  LfgDungeonSet randomDungeons;
2034  for (lfg::LFGDungeonContainer::const_iterator itr = LfgDungeonStore.begin(); itr != LfgDungeonStore.end(); ++itr)
2035  {
2036  lfg::LFGDungeonData const& dungeon = itr->second;
2037  if ((dungeon.type == lfg::LFG_TYPE_RANDOM || (dungeon.seasonal && sLFGMgr->IsSeasonActive(dungeon.id)))
2038  && dungeon.expansion <= expansion && dungeon.minlevel <= level && level <= dungeon.maxlevel)
2039  randomDungeons.insert(dungeon.Entry());
2040  }
2041  return randomDungeons;
2042 }
uint8 maxlevel
Definition: LFGMgr.h:288
uint8 minlevel
Definition: LFGMgr.h:287
Definition: LFGMgr.h:68
LFGDungeonContainer LfgDungeonStore
Definition: LFGMgr.h:470
bool seasonal
Definition: LFGMgr.h:290
#define sLFGMgr
Definition: LFGMgr.h:481
std::set< uint32 > LfgDungeonSet
Definition: LFG.h:112
Definition: LFGMgr.h:268
uint8 expansion
Definition: LFGMgr.h:285
uint32 Entry() const
Definition: LFGMgr.h:295
uint8 type
Definition: LFGMgr.h:284
uint32 id
Definition: LFGMgr.h:281

+ Here is the call graph for this function:

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
1471 {
1472  LfgReward const* rew = NULL;
1473  LfgRewardContainerBounds bounds = RewardMapStore.equal_range(dungeon & 0x00FFFFFF);
1474  for (LfgRewardContainer::const_iterator itr = bounds.first; itr != bounds.second; ++itr)
1475  {
1476  rew = itr->second;
1477  // ordered properly at loading
1478  if (itr->second->maxLevel >= level)
1479  break;
1480  }
1481 
1482  return rew;
1483 }
arena_t NULL
Definition: jemalloc_internal.h:624
LfgRewardContainer RewardMapStore
Stores rewards for random dungeons.
Definition: LFGMgr.h:469
std::pair< LfgRewardContainer::const_iterator, LfgRewardContainer::const_iterator > LfgRewardContainerBounds
Definition: LFGMgr.h:139
uint8 lfg::LFGMgr::GetRoles ( ObjectGuid  guid)

Get current player roles.

1565 {
1566  uint8 roles = PlayersStore[guid].GetRoles();
1567  TC_LOG_TRACE("lfg.data.player.role.get", "Player: %s, Role: %u", guid.ToString().c_str(), roles);
1568  return roles;
1569 }
#define TC_LOG_TRACE(filterType__,...)
Definition: Log.h:195
LfgPlayerDataContainer PlayersStore
Player data.
Definition: LFGMgr.h:475
uint8_t uint8
Definition: Define.h:152
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

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

Get selected dungeons.

1578 {
1579  TC_LOG_TRACE("lfg.data.player.dungeons.selected.get", "Player: %s, Selected Dungeons: %s", guid.ToString().c_str(), ConcatenateDungeons(PlayersStore[guid].GetSelectedDungeons()).c_str());
1580  return PlayersStore[guid].GetSelectedDungeons();
1581 }
std::string ConcatenateDungeons(LfgDungeonSet const &dungeons)
Definition: LFG.cpp:25
LfgDungeonSet const & GetSelectedDungeons(ObjectGuid guid)
Get selected dungeons.
Definition: LFGMgr.cpp:1577
#define TC_LOG_TRACE(filterType__,...)
Definition: Log.h:195
LfgPlayerDataContainer PlayersStore
Player data.
Definition: LFGMgr.h:475
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Get current lfg state.

1501 {
1502  LfgState state;
1503  if (guid.IsParty())
1504  {
1505  state = GroupsStore[guid].GetState();
1506  TC_LOG_TRACE("lfg.data.group.state.get", "Group: %s, State: %s", guid.ToString().c_str(), GetStateString(state).c_str());
1507  }
1508  else
1509  {
1510  state = PlayersStore[guid].GetState();
1511  TC_LOG_TRACE("lfg.data.player.state.get", "Player: %s, State: %s", guid.ToString().c_str(), GetStateString(state).c_str());
1512  }
1513 
1514  return state;
1515 }
LfgState
Definition: LFG.h:65
std::string GetStateString(LfgState state)
Definition: LFG.cpp:74
#define TC_LOG_TRACE(filterType__,...)
Definition: Log.h:195
LfgPlayerDataContainer PlayersStore
Player data.
Definition: LFGMgr.h:475
LfgGroupDataContainer GroupsStore
Group data.
Definition: LFGMgr.h:476
bool IsParty() const
Definition: ObjectGuid.h:258
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint8 lfg::LFGMgr::GetTeam ( ObjectGuid  guid)
private
1776 {
1777  uint8 team = PlayersStore[guid].GetTeam();
1778  TC_LOG_TRACE("lfg.data.player.team.get", "Player: %s, Team: %u", guid.ToString().c_str(), team);
1779  return team;
1780 }
#define TC_LOG_TRACE(filterType__,...)
Definition: Log.h:195
LfgPlayerDataContainer PlayersStore
Player data.
Definition: LFGMgr.h:475
uint8_t uint8
Definition: Define.h:152
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

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

Checks if given players are ignoring each other.

1831 {
1834  return plr1 && plr2 && (plr1->GetSocial()->HasIgnore(guid2) || plr2->GetSocial()->HasIgnore(guid1));
1835 }
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:215

+ Here is the call graph for this function:

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
1168 {
1169  SetVoteKick(gguid, true);
1170 
1171  LfgPlayerBoot& boot = BootsStore[gguid];
1172  boot.inProgress = true;
1173  boot.cancelTime = time_t(time(NULL)) + LFG_TIME_BOOT;
1174  boot.reason = reason;
1175  boot.victim = victim;
1176 
1177  GuidSet const& players = GetPlayers(gguid);
1178 
1179  // Set votes
1180  for (GuidSet::const_iterator itr = players.begin(); itr != players.end(); ++itr)
1181  {
1182  ObjectGuid guid = (*itr);
1183  boot.votes[guid] = LFG_ANSWER_PENDING;
1184  }
1185 
1186  boot.votes[victim] = LFG_ANSWER_DENY; // Victim auto vote NO
1187  boot.votes[kicker] = LFG_ANSWER_AGREE; // Kicker auto vote YES
1188 
1189  // Notify players
1190  for (GuidSet::const_iterator it = players.begin(); it != players.end(); ++it)
1191  SendLfgBootProposalUpdate(*it, boot);
1192 }
void SendLfgBootProposalUpdate(ObjectGuid guid, LfgPlayerBoot const &boot)
Definition: LFGMgr.cpp:1861
Definition: LFG.h:97
LfgPlayerBootContainer BootsStore
Current player kicks.
Definition: LFGMgr.h:474
Definition: LFGMgr.h:44
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: LFG.h:98
Definition: LFG.h:99
GuidSet const & GetPlayers(ObjectGuid guid)
Definition: LFGMgr.cpp:1815
std::set< ObjectGuid > GuidSet
Definition: ObjectGuid.h:332
Definition: ObjectGuid.h:189
void SetVoteKick(ObjectGuid gguid, bool active)
Definition: LFGMgr.cpp:1704

+ Here is the call graph for this function:

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

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

2010 {
2011  if (!guid.IsParty())
2012  guid = GetGroup(guid);
2013 
2014  if (uint32 dungeonId = GetDungeon(guid, true))
2015  if (LFGDungeonData const* dungeon = GetLFGDungeon(dungeonId))
2016  if (uint32(dungeon->map) == map && dungeon->difficulty == difficulty)
2017  return true;
2018 
2019  return false;
2020 }
LFGDungeonData const * GetLFGDungeon(uint32 id)
Definition: LFGMgr.cpp:163
uint32_t uint32
Definition: Define.h:150
uint32 GetDungeon(ObjectGuid guid, bool asId=true)
Get current dungeon.
Definition: LFGMgr.cpp:1544
ObjectGuid GetGroup(ObjectGuid guid)
Gets player group.
Definition: LFGMgr.cpp:1805
uint32_t uint32
Definition: g3dmath.h:168
bool IsParty() const
Definition: ObjectGuid.h:258

+ Here is the call graph for this function:

LFGMgr * lfg::LFGMgr::instance ( )
static
262 {
263  static LFGMgr instance;
264  return &instance;
265 }
static LFGMgr * instance()
Definition: LFGMgr.cpp:261
LFGMgr()
Definition: LFGMgr.cpp:40
bool lfg::LFGMgr::IsLfgGroup ( ObjectGuid  guid)

Check if given group guid is lfg.

1880 {
1881  return !guid.IsEmpty() && guid.IsParty() && GroupsStore[guid].IsLfgGroup();
1882 }
LfgGroupDataContainer GroupsStore
Group data.
Definition: LFGMgr.h:476
bool IsParty() const
Definition: ObjectGuid.h:258
bool IsEmpty() const
Definition: ObjectGuid.h:242

+ Here is the call graph for this function:

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

Checks if given lfg option is enabled.

1931 {
1932  return (m_options & option) != 0;
1933 }
uint32 m_options
Stores config options.
Definition: LFGMgr.h:464

+ Here is the caller graph for this function:

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

Checks if Seasonal dungeon is active.

1952 {
1953  switch (dungeonId)
1954  {
1955  case 285: // The Headless Horseman
1957  case 286: // The Frost Lord Ahune
1959  case 287: // Coren Direbrew
1961  case 288: // The Crown Chemical Co.
1963  }
1964  return false;
1965 }
Definition: SharedDefines.h:3732
Definition: SharedDefines.h:3742
Definition: SharedDefines.h:3730
Definition: SharedDefines.h:3727
bool IsHolidayActive(HolidayIds id)
Definition: GameEventMgr.cpp:1673

+ Here is the call graph for this function:

bool lfg::LFGMgr::IsVoteKickActive ( ObjectGuid  gguid)

Get current vote kick state.

1535 {
1536  ASSERT(gguid.IsParty());
1537 
1538  bool active = GroupsStore[gguid].IsVoteKickActive();
1539  TC_LOG_TRACE("lfg.data.group.votekick.get", "Group: %s, Active: %d", gguid.ToString().c_str(), active);
1540 
1541  return active;
1542 }
#define TC_LOG_TRACE(filterType__,...)
Definition: Log.h:195
#define ASSERT
Definition: Errors.h:55
LfgGroupDataContainer GroupsStore
Group data.
Definition: LFGMgr.h:476
bool IsParty() const
Definition: ObjectGuid.h:258
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

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
380 {
381  if (!player || !player->GetSession() || dungeons.empty())
382  return;
383 
384  Group* grp = player->GetGroup();
385  ObjectGuid guid = player->GetGUID();
386  ObjectGuid gguid = grp ? grp->GetGUID() : guid;
387  LfgJoinResultData joinData;
388  GuidSet players;
389  uint32 rDungeonId = 0;
390  bool isContinue = grp && grp->isLFGGroup() && GetState(gguid) != LFG_STATE_FINISHED_DUNGEON;
391 
392  // Do not allow to change dungeon in the middle of a current dungeon
393  if (isContinue)
394  {
395  dungeons.clear();
396  dungeons.insert(GetDungeon(gguid));
397  }
398 
399  // Already in queue?
400  LfgState state = GetState(gguid);
401  if (state == LFG_STATE_QUEUED)
402  {
403  LFGQueue& queue = GetQueue(gguid);
404  queue.RemoveFromQueue(gguid);
405  }
406 
407  // Check player or group member restrictions
408  if (!player->GetSession()->HasPermission(rbac::RBAC_PERM_JOIN_DUNGEON_FINDER))
409  joinData.result = LFG_JOIN_NOT_MEET_REQS;
410  else if (player->InBattleground() || player->InArena() || player->InBattlegroundQueue())
411  joinData.result = LFG_JOIN_USING_BG_SYSTEM;
412  else if (player->HasAura(LFG_SPELL_DUNGEON_DESERTER))
413  joinData.result = LFG_JOIN_DESERTER;
414  else if (player->HasAura(LFG_SPELL_DUNGEON_COOLDOWN))
415  joinData.result = LFG_JOIN_RANDOM_COOLDOWN;
416  else if (dungeons.empty())
417  joinData.result = LFG_JOIN_NOT_MEET_REQS;
418  else if (player->HasAura(9454)) // check Freeze debuff
419  joinData.result = LFG_JOIN_NOT_MEET_REQS;
420  else if (grp)
421  {
422  if (grp->GetMembersCount() > MAX_GROUP_SIZE)
423  joinData.result = LFG_JOIN_TOO_MUCH_MEMBERS;
424  else
425  {
426  uint8 memberCount = 0;
427  for (GroupReference* itr = grp->GetFirstMember(); itr != NULL && joinData.result == LFG_JOIN_OK; itr = itr->next())
428  {
429  if (Player* plrg = itr->GetSource())
430  {
431  if (!plrg->GetSession()->HasPermission(rbac::RBAC_PERM_JOIN_DUNGEON_FINDER))
432  joinData.result = LFG_JOIN_INTERNAL_ERROR;
433  if (plrg->HasAura(LFG_SPELL_DUNGEON_DESERTER))
434  joinData.result = LFG_JOIN_PARTY_DESERTER;
435  else if (plrg->HasAura(LFG_SPELL_DUNGEON_COOLDOWN))
436  joinData.result = LFG_JOIN_PARTY_RANDOM_COOLDOWN;
437  else if (plrg->InBattleground() || plrg->InArena() || plrg->InBattlegroundQueue())
438  joinData.result = LFG_JOIN_USING_BG_SYSTEM;
439  else if (plrg->HasAura(9454)) // check Freeze debuff
440  joinData.result = LFG_JOIN_PARTY_NOT_MEET_REQS;
441  ++memberCount;
442  players.insert(plrg->GetGUID());
443  }
444  }
445 
446  if (joinData.result == LFG_JOIN_OK && memberCount != grp->GetMembersCount())
447  joinData.result = LFG_JOIN_DISCONNECTED;
448  }
449  }
450  else
451  players.insert(player->GetGUID());
452 
453  // Check if all dungeons are valid
454  bool isRaid = false;
455  if (joinData.result == LFG_JOIN_OK)
456  {
457  bool isDungeon = false;
458  for (LfgDungeonSet::const_iterator it = dungeons.begin(); it != dungeons.end() && joinData.result == LFG_JOIN_OK; ++it)
459  {
460  LfgType type = GetDungeonType(*it);
461  switch (type)
462  {
463  case LFG_TYPE_RANDOM:
464  if (dungeons.size() > 1) // Only allow 1 random dungeon
465  joinData.result = LFG_JOIN_DUNGEON_INVALID;
466  else
467  rDungeonId = (*dungeons.begin());
468  // No break on purpose (Random can only be dungeon or heroic dungeon)
469  case LFG_TYPE_HEROIC:
470  case LFG_TYPE_DUNGEON:
471  if (isRaid)
472  joinData.result = LFG_JOIN_MIXED_RAID_DUNGEON;
473  isDungeon = true;
474  break;
475  case LFG_TYPE_RAID:
476  if (isDungeon)
477  joinData.result = LFG_JOIN_MIXED_RAID_DUNGEON;
478  isRaid = true;
479  break;
480  default:
481  joinData.result = LFG_JOIN_DUNGEON_INVALID;
482  break;
483  }
484  }
485 
486  // it could be changed
487  if (joinData.result == LFG_JOIN_OK)
488  {
489  // Expand random dungeons and check restrictions
490  if (rDungeonId)
491  dungeons = GetDungeonsByRandom(rDungeonId);
492 
493  // if we have lockmap then there are no compatible dungeons
494  GetCompatibleDungeons(dungeons, players, joinData.lockmap, isContinue);
495  if (dungeons.empty())
496  joinData.result = grp ? LFG_JOIN_INTERNAL_ERROR : LFG_JOIN_NOT_MEET_REQS;
497  }
498  }
499 
500  // Can't join. Send result
501  if (joinData.result != LFG_JOIN_OK)
502  {
503  TC_LOG_DEBUG("lfg.join", "%s joining with %u members. Result: %u, Dungeons: %s",
504  guid.ToString().c_str(), grp ? grp->GetMembersCount() : 1, joinData.result, ConcatenateDungeons(dungeons).c_str());
505 
506  if (!dungeons.empty()) // Only should show lockmap when have no dungeons available
507  joinData.lockmap.clear();
508  player->GetSession()->SendLfgJoinResult(joinData);
509  return;
510  }
511 
512  SetComment(guid, comment);
513 
514  if (isRaid)
515  {
516  TC_LOG_DEBUG("lfg.join", "%s trying to join raid browser and it's disabled.", guid.ToString().c_str());
517  return;
518  }
519 
520  std::string debugNames = "";
521  if (grp) // Begin rolecheck
522  {
523  // Create new rolecheck
524  LfgRoleCheck& roleCheck = RoleChecksStore[gguid];
525  roleCheck.cancelTime = time_t(time(NULL)) + LFG_TIME_ROLECHECK;
526  roleCheck.state = LFG_ROLECHECK_INITIALITING;
527  roleCheck.leader = guid;
528  roleCheck.dungeons = dungeons;
529  roleCheck.rDungeonId = rDungeonId;
530 
531  if (rDungeonId)
532  {
533  dungeons.clear();
534  dungeons.insert(rDungeonId);
535  }
536 
538  // Send update to player
539  LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_JOIN_QUEUE, dungeons, comment);
540  for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
541  {
542  if (Player* plrg = itr->GetSource())
543  {
544  ObjectGuid pguid = plrg->GetGUID();
545  plrg->GetSession()->SendLfgUpdateStatus(updateData, true);
547  if (!isContinue)
548  SetSelectedDungeons(pguid, dungeons);
549  roleCheck.roles[pguid] = 0;
550  if (!debugNames.empty())
551  debugNames.append(", ");
552  debugNames.append(plrg->GetName());
553  }
554  }
555  // Update leader role
556  UpdateRoleCheck(gguid, guid, roles);
557  }
558  else // Add player to queue
559  {
560  LfgRolesMap rolesMap;
561  rolesMap[guid] = roles;
562  LFGQueue& queue = GetQueue(guid);
563  queue.AddQueueData(guid, time(NULL), dungeons, rolesMap);
564 
565  if (!isContinue)
566  {
567  if (rDungeonId)
568  {
569  dungeons.clear();
570  dungeons.insert(rDungeonId);
571  }
572  SetSelectedDungeons(guid, dungeons);
573  }
574  // Send update to player
575  player->GetSession()->SendLfgJoinResult(joinData);
576  player->GetSession()->SendLfgUpdateStatus(LfgUpdateData(LFG_UPDATETYPE_JOIN_QUEUE, dungeons, comment), false);
577  SetState(gguid, LFG_STATE_QUEUED);
578  SetRoles(guid, roles);
579  debugNames.append(player->GetName());
580  }
581 
582  TC_LOG_DEBUG("lfg.join", "%s joined (%s), Members: %s. Dungeons (%u): %s", guid.ToString().c_str(),
583  grp ? "group" : "player", debugNames.c_str(), uint32(dungeons.size()), ConcatenateDungeons(dungeons).c_str());
584 }
void UpdateRoleCheck(ObjectGuid gguid, ObjectGuid guid=ObjectGuid::Empty, uint8 roles=PLAYER_ROLE_NONE)
Updates the role check with player answer.
Definition: LFGMgr.cpp:666
Definition: LFG.h:68
ObjectGuid GetGUID() const
Definition: Group.cpp:2534
Definition: LFGMgr.h:99
std::string ConcatenateDungeons(LfgDungeonSet const &dungeons)
Definition: LFG.cpp:25
Definition: LFGMgr.h:102
void SetRoles(ObjectGuid guid, uint8 roles)
Sets player lfg roles.
Definition: LFGMgr.cpp:1721
LfgState GetState(ObjectGuid guid)
Get current lfg state.
Definition: LFGMgr.cpp:1500
Definition: LFG.h:48
Definition: LFGMgr.h:68
LfgRoleCheckContainer RoleChecksStore
Current Role checks.
Definition: LFGMgr.h:472
Definition: LFGMgr.h:106
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: LFGMgr.h:65
LfgState
Definition: LFG.h:65
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: LFG.h:69
Definition: LFGMgr.h:48
LfgType
Determines the type of instance.
Definition: LFGMgr.h:62
Definition: LFGMgr.h:101
Definition: LFGMgr.h:66
Definition: LFGMgr.h:43
#define MAX_GROUP_SIZE
Definition: Group.h:42
void GetCompatibleDungeons(LfgDungeonSet &dungeons, GuidSet const &players, LfgLockPartyMap &lockMap, bool isContinue)
Definition: LFGMgr.cpp:758
Definition: LFGMgr.h:111
Definition: LFGMgr.h:108
std::map< ObjectGuid, uint8 > LfgRolesMap
Definition: LFG.h:115
LfgType GetDungeonType(uint32 dungeon)
Definition: LFGMgr.cpp:1491
uint32_t uint32
Definition: Define.h:150
uint32 GetDungeon(ObjectGuid guid, bool asId=true)
Get current dungeon.
Definition: LFGMgr.cpp:1544
Definition: LFGMgr.h:100
GroupReference * GetFirstMember()
Definition: Group.h:295
Definition: LFGMgr.h:47
bool isLFGGroup() const
Definition: Group.cpp:2504
Definition: LFGMgr.h:110
void SetState(ObjectGuid guid, LfgState state)
Definition: LFGMgr.cpp:1682
LfgDungeonSet const & GetDungeonsByRandom(uint32 randomdungeon)
Definition: LFGMgr.cpp:1456
Definition: LFGMgr.h:107
std::set< ObjectGuid > GuidSet
Definition: ObjectGuid.h:332
uint32 GetMembersCount() const
Definition: Group.h:297
LFGQueue & GetQueue(ObjectGuid guid)
Definition: LFGMgr.cpp:1897
Definition: LFGMgr.h:96
uint8_t uint8
Definition: Define.h:152
Definition: LFGMgr.h:104
Definition: ObjectGuid.h:189
uint32_t uint32
Definition: g3dmath.h:168
std::string ToString() const
Definition: ObjectGuid.cpp:99
Definition: LFGMgr.h:112
Definition: LFGMgr.h:121
void SetComment(ObjectGuid guid, std::string const &comment)
Sets player lfr comment.
Definition: LFGMgr.cpp:1727
Definition: LFGMgr.h:109
Definition: Group.h:191
void SetSelectedDungeons(ObjectGuid guid, LfgDungeonSet const &dungeons)
Definition: LFGMgr.cpp:1733
Definition: GroupReference.h:27
Definition: LFGMgr.h:67

+ Here is the call graph for this function:

void lfg::LFGMgr::LeaveLfg ( ObjectGuid  guid,
bool  disconnected = false 
)

Leaves lfg.

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

Parameters
[in]guidPlayer or group guid
593 {
594  ObjectGuid gguid = guid.IsParty() ? guid : GetGroup(guid);
595 
596  TC_LOG_DEBUG("lfg.leave", "%s left (%s)", guid.ToString().c_str(), guid == gguid ? "group" : "player");
597 
598  LfgState state = GetState(guid);
599  switch (state)
600  {
601  case LFG_STATE_QUEUED:
602  if (!gguid.IsEmpty())
603  {
604  LFGQueue& queue = GetQueue(gguid);
605  queue.RemoveFromQueue(gguid);
606  SetState(gguid, LFG_STATE_NONE);
607  GuidSet const& players = GetPlayers(gguid);
608  for (GuidSet::const_iterator it = players.begin(); it != players.end(); ++it)
609  {
610  SetState(*it, LFG_STATE_NONE);
611  SendLfgUpdateStatus(*it, LfgUpdateData(LFG_UPDATETYPE_REMOVED_FROM_QUEUE), true);
612  }
613  }
614  else
615  {
616  LFGQueue& queue = GetQueue(guid);
617  queue.RemoveFromQueue(guid);
618  SendLfgUpdateStatus(guid, LfgUpdateData(LFG_UPDATETYPE_REMOVED_FROM_QUEUE), false);
619  SetState(guid, LFG_STATE_NONE);
620  }
621  break;
622  case LFG_STATE_ROLECHECK:
623  if (!gguid.IsEmpty())
624  UpdateRoleCheck(gguid); // No player to update role = LFG_ROLECHECK_ABORTED
625  break;
626  case LFG_STATE_PROPOSAL:
627  {
628  // Remove from Proposals
629  LfgProposalContainer::iterator it = ProposalsStore.begin();
630  ObjectGuid pguid = gguid == guid ? GetLeader(gguid) : guid;
631  while (it != ProposalsStore.end())
632  {
633  LfgProposalPlayerContainer::iterator itPlayer = it->second.players.find(pguid);
634  if (itPlayer != it->second.players.end())
635  {
636  // Mark the player/leader of group who left as didn't accept the proposal
637  itPlayer->second.accept = LFG_ANSWER_DENY;
638  break;
639  }
640  ++it;
641  }
642 
643  // Remove from queue - if proposal is found, RemoveProposal will call RemoveFromQueue
644  if (it != ProposalsStore.end())
646  break;
647  }
648  case LFG_STATE_NONE:
650  break;
651  case LFG_STATE_DUNGEON:
653  if (guid != gguid && !disconnected) // Player
654  SetState(guid, LFG_STATE_NONE);
655  break;
656  }
657 }
void RemoveProposal(LfgProposalContainer::iterator itProposal, LfgUpdateType type)
Definition: LFGMgr.cpp:1067
void UpdateRoleCheck(ObjectGuid gguid, ObjectGuid guid=ObjectGuid::Empty, uint8 roles=PLAYER_ROLE_NONE)
Updates the role check with player answer.
Definition: LFGMgr.cpp:666
Definition: LFG.h:68
ObjectGuid GetLeader(ObjectGuid guid)
Get leader of the group (using internal data)
Definition: LFGMgr.cpp:1825
LfgState GetState(ObjectGuid guid)
Get current lfg state.
Definition: LFGMgr.cpp:1500
Definition: LFG.h:67
LfgProposalContainer ProposalsStore
Current Proposals.
Definition: LFGMgr.h:473
LfgState
Definition: LFG.h:65
Definition: LFG.h:98
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: LFG.h:72
Definition: LFG.h:69
Definition: LFG.h:70
Definition: LFG.h:74
void SetState(ObjectGuid guid, LfgState state)
Definition: LFGMgr.cpp:1682
GuidSet const & GetPlayers(ObjectGuid guid)
Definition: LFGMgr.cpp:1815
std::set< ObjectGuid > GuidSet
Definition: ObjectGuid.h:332
ObjectGuid GetGroup(ObjectGuid guid)
Gets player group.
Definition: LFGMgr.cpp:1805
LFGQueue & GetQueue(ObjectGuid guid)
Definition: LFGMgr.cpp:1897
void SendLfgUpdateStatus(ObjectGuid guid, LfgUpdateData const &data, bool party)
Definition: LFGMgr.cpp:1849
Definition: ObjectGuid.h:189
bool IsParty() const
Definition: ObjectGuid.h:258
std::string ToString() const
Definition: ObjectGuid.cpp:99
bool IsEmpty() const
Definition: ObjectGuid.h:242

+ Here is the call graph for this function:

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

Loads dungeons from dbc and adds teleport coords.

173 {
174  uint32 oldMSTime = getMSTime();
175 
176  LfgDungeonStore.clear();
177 
178  // Initialize Dungeon map with data from dbcs
179  for (uint32 i = 0; i < sLFGDungeonStore.GetNumRows(); ++i)
180  {
181  LFGDungeonEntry const* dungeon = sLFGDungeonStore.LookupEntry(i);
182  if (!dungeon)
183  continue;
184 
185  switch (dungeon->Type)
186  {
187  case LFG_TYPE_DUNGEON:
188  case LFG_TYPE_HEROIC:
189  case LFG_TYPE_RAID:
190  case LFG_TYPE_RANDOM:
191  LfgDungeonStore[dungeon->ID] = LFGDungeonData(dungeon);
192  break;
193  }
194  }
195 
196  // Fill teleport locations from DB
197  QueryResult result = WorldDatabase.Query("SELECT dungeonId, position_x, position_y, position_z, orientation, requiredItemLevel FROM lfg_dungeon_template");
198  if (!result)
199  {
200  TC_LOG_ERROR("server.loading", ">> Loaded 0 lfg dungeon templates. DB table `lfg_dungeon_template` is empty!");
201  return;
202  }
203 
204  uint32 count = 0;
205 
206  do
207  {
208  Field* fields = result->Fetch();
209  uint32 dungeonId = fields[0].GetUInt32();
210  LFGDungeonContainer::iterator dungeonItr = LfgDungeonStore.find(dungeonId);
211  if (dungeonItr == LfgDungeonStore.end())
212  {
213  TC_LOG_ERROR("sql.sql", "table `lfg_entrances` contains coordinates for wrong dungeon %u", dungeonId);
214  continue;
215  }
216 
217  LFGDungeonData& data = dungeonItr->second;
218  data.x = fields[1].GetFloat();
219  data.y = fields[2].GetFloat();
220  data.z = fields[3].GetFloat();
221  data.o = fields[4].GetFloat();
222  data.requiredItemLevel = fields[5].GetUInt16();
223 
224  ++count;
225  }
226  while (result->NextRow());
227 
228  TC_LOG_INFO("server.loading", ">> Loaded %u lfg dungeon templates in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
229 
230  // Fill all other teleport coords from areatriggers
231  for (LFGDungeonContainer::iterator itr = LfgDungeonStore.begin(); itr != LfgDungeonStore.end(); ++itr)
232  {
233  LFGDungeonData& dungeon = itr->second;
234 
235  // No teleport coords in database, load from areatriggers
236  if (dungeon.type != LFG_TYPE_RANDOM && dungeon.x == 0.0f && dungeon.y == 0.0f && dungeon.z == 0.0f)
237  {
238  AreaTriggerStruct const* at = sObjectMgr->GetMapEntranceTrigger(dungeon.map);
239  if (!at)
240  {
241  TC_LOG_ERROR("sql.sql", "Failed to load dungeon %s (Id: %u), cant find areatrigger for map %u", dungeon.name.c_str(), dungeon.id, dungeon.map);
242  continue;
243  }
244 
245  dungeon.map = at->target_mapId;
246  dungeon.x = at->target_X;
247  dungeon.y = at->target_Y;
248  dungeon.z = at->target_Z;
249  dungeon.o = at->target_Orientation;
250  }
251 
252  if (dungeon.type != LFG_TYPE_RANDOM)
253  CachedDungeonMapStore[dungeon.group].insert(dungeon.id);
254  CachedDungeonMapStore[0].insert(dungeon.id);
255  }
256 
257  if (reload)
258  CachedDungeonMapStore.clear();
259 }
Definition: ObjectMgr.h:400
float GetFloat() const
Definition: Field.h:222
Class used to access individual fields of database query result.
Definition: Field.h:56
Definition: LFGMgr.h:68
float target_Orientation
Definition: ObjectMgr.h:406
uint32 getMSTime()
Definition: Timer.h:24
DBCStorage< LFGDungeonEntry > sLFGDungeonStore(LFGDungeonfmt)
Definition: LFGMgr.h:65
WorldDatabaseWorkerPool WorldDatabase
Accessor to the world database.
Definition: DatabaseEnv.cpp:20
LFGDungeonContainer LfgDungeonStore
Definition: LFGMgr.h:470
#define sObjectMgr
Definition: ObjectMgr.h:1567
uint32 Type
Definition: DBCStructure.h:754
Definition: DBCStructure.h:742
Definition: LFGMgr.h:66
float target_Y
Definition: ObjectMgr.h:404
uint32_t uint32
Definition: Define.h:150
std::shared_ptr< ResultSet > QueryResult
Definition: QueryResult.h:61
uint16 GetUInt16() const
Definition: Field.h:108
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
Definition: Timer.h:42
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
uint32 ID
Definition: DBCStructure.h:744
float target_Z
Definition: ObjectMgr.h:405
uint32 GetUInt32() const
Definition: Field.h:146
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:201
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
float target_X
Definition: ObjectMgr.h:403
uint32 target_mapId
Definition: ObjectMgr.h:402
LfgCachedDungeonContainer CachedDungeonMapStore
Stores all dungeons by groupType.
Definition: LFGMgr.h:467
Definition: LFGMgr.h:67

+ Here is the call graph for this function:

void lfg::LFGMgr::LoadRewards ( )

Loads rewards for random dungeons.

Load rewards for completing dungeons.

104 {
105  uint32 oldMSTime = getMSTime();
106 
107  for (LfgRewardContainer::iterator itr = RewardMapStore.begin(); itr != RewardMapStore.end(); ++itr)
108  delete itr->second;
109  RewardMapStore.clear();
110 
111  // ORDER BY is very important for GetRandomDungeonReward!
112  QueryResult result = WorldDatabase.Query("SELECT dungeonId, maxLevel, firstQuestId, otherQuestId FROM lfg_dungeon_rewards ORDER BY dungeonId, maxLevel ASC");
113 
114  if (!result)
115  {
116  TC_LOG_ERROR("server.loading", ">> Loaded 0 lfg dungeon rewards. DB table `lfg_dungeon_rewards` is empty!");
117  return;
118  }
119 
120  uint32 count = 0;
121 
122  Field* fields = NULL;
123  do
124  {
125  fields = result->Fetch();
126  uint32 dungeonId = fields[0].GetUInt32();
127  uint32 maxLevel = fields[1].GetUInt8();
128  uint32 firstQuestId = fields[2].GetUInt32();
129  uint32 otherQuestId = fields[3].GetUInt32();
130 
131  if (!GetLFGDungeonEntry(dungeonId))
132  {
133  TC_LOG_ERROR("sql.sql", "Dungeon %u specified in table `lfg_dungeon_rewards` does not exist!", dungeonId);
134  continue;
135  }
136 
137  if (!maxLevel || maxLevel > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
138  {
139  TC_LOG_ERROR("sql.sql", "Level %u specified for dungeon %u in table `lfg_dungeon_rewards` can never be reached!", maxLevel, dungeonId);
140  maxLevel = sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL);
141  }
142 
143  if (!firstQuestId || !sObjectMgr->GetQuestTemplate(firstQuestId))
144  {
145  TC_LOG_ERROR("sql.sql", "First quest %u specified for dungeon %u in table `lfg_dungeon_rewards` does not exist!", firstQuestId, dungeonId);
146  continue;
147  }
148 
149  if (otherQuestId && !sObjectMgr->GetQuestTemplate(otherQuestId))
150  {
151  TC_LOG_ERROR("sql.sql", "Other quest %u specified for dungeon %u in table `lfg_dungeon_rewards` does not exist!", otherQuestId, dungeonId);
152  otherQuestId = 0;
153  }
154 
155  RewardMapStore.insert(LfgRewardContainer::value_type(dungeonId, new LfgReward(maxLevel, firstQuestId, otherQuestId)));
156  ++count;
157  }
158  while (result->NextRow());
159 
160  TC_LOG_INFO("server.loading", ">> Loaded %u lfg dungeon rewards in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
161 }
Class used to access individual fields of database query result.
Definition: Field.h:56
uint32 getMSTime()
Definition: Timer.h:24
arena_t NULL
Definition: jemalloc_internal.h:624
WorldDatabaseWorkerPool WorldDatabase
Accessor to the world database.
Definition: DatabaseEnv.cpp:20
uint32 GetLFGDungeonEntry(uint32 id)
Return Lfg dungeon entry for given dungeon id.
Definition: LFGMgr.cpp:2022
#define sWorld
Definition: World.h:887
#define sObjectMgr
Definition: ObjectMgr.h:1567
uint8 GetUInt8() const
Definition: Field.h:70
uint32_t uint32
Definition: Define.h:150
std::shared_ptr< ResultSet > QueryResult
Definition: QueryResult.h:61
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
Definition: Timer.h:42
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
uint32 GetUInt32() const
Definition: Field.h:146
LfgRewardContainer RewardMapStore
Stores rewards for random dungeons.
Definition: LFGMgr.h:469
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:201
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: World.h:235

+ Here is the call graph for this function:

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

Makes a new group given a proposal

Parameters
[in]proposalProposal to get info from
882 {
883  GuidList players;
884  GuidList playersToTeleport;
885 
886  for (LfgProposalPlayerContainer::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it)
887  {
888  ObjectGuid guid = it->first;
889  if (guid == proposal.leader)
890  players.push_front(guid);
891  else
892  players.push_back(guid);
893 
894  if (proposal.isNew || GetGroup(guid) != proposal.group)
895  playersToTeleport.push_back(guid);
896  }
897 
898  // Set the dungeon difficulty
899  LFGDungeonData const* dungeon = GetLFGDungeon(proposal.dungeonId);
900  ASSERT(dungeon);
901 
902  Group* grp = !proposal.group.IsEmpty() ? sGroupMgr->GetGroupByGUID(proposal.group) : NULL;
903  for (GuidList::const_iterator it = players.begin(); it != players.end(); ++it)
904  {
905  ObjectGuid pguid = (*it);
907  if (!player)
908  continue;
909 
910  Group* group = player->GetGroup();
911  if (group && group != grp)
912  group->RemoveMember(player->GetGUID());
913 
914  if (!grp)
915  {
916  grp = new Group();
917  grp->ConvertToLFG();
918  grp->Create(player);
919  ObjectGuid gguid = grp->GetGUID();
921  sGroupMgr->AddGroup(grp);
922  }
923  else if (group != grp)
924  grp->AddMember(player);
925 
926  grp->SetLfgRoles(pguid, proposal.players.find(pguid)->second.role);
927 
928  // Add the cooldown spell if queued for a random dungeon
929  if (dungeon->type == LFG_TYPE_RANDOM)
930  player->CastSpell(player, LFG_SPELL_DUNGEON_COOLDOWN, false);
931  }
932 
933  ASSERT(grp);
934  grp->SetDungeonDifficultyID(Difficulty(dungeon->difficulty));
935  ObjectGuid gguid = grp->GetGUID();
936  SetDungeon(gguid, dungeon->Entry());
937  SetState(gguid, LFG_STATE_DUNGEON);
938 
939  _SaveToDB(gguid, grp->GetDbStoreId());
940 
941  // Teleport Player
942  for (GuidList::const_iterator it = playersToTeleport.begin(); it != playersToTeleport.end(); ++it)
943  if (Player* player = ObjectAccessor::FindPlayer(*it))
944  TeleportPlayer(player, false);
945 
946  // Update group info
947  grp->SendUpdate();
948 }
Difficulty
Definition: DBCEnums.h:402
void SetLfgRoles(ObjectGuid guid, uint8 roles)
Definition: Group.cpp:2331
ObjectGuid GetGUID() const
Definition: Group.cpp:2534
Definition: LFGMgr.h:68
arena_t NULL
Definition: jemalloc_internal.h:624
void _SaveToDB(ObjectGuid guid, uint32 db_guid)
Definition: LFGMgr.cpp:82
Definition: LFG.h:72
Definition: LFG.h:70
std::list< ObjectGuid > GuidList
Definition: ObjectGuid.h:333
bool Create(Player *leader)
Definition: Group.cpp:98
bool AddMember(Player *player)
Definition: Group.cpp:368
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
LFGDungeonData const * GetLFGDungeon(uint32 id)
Definition: LFGMgr.cpp:163
#define sGroupMgr
Definition: GroupMgr.h:59
static Summons Group[]
Definition: boss_urom.cpp:77
bool RemoveMember(ObjectGuid guid, const RemoveMethod &method=GROUP_REMOVEMETHOD_DEFAULT, ObjectGuid kicker=ObjectGuid::Empty, const char *reason=NULL)
Definition: Group.cpp:526
uint32 GetDbStoreId() const
Definition: Group.h:278
void TeleportPlayer(Player *player, bool out, bool fromOpcode=false)
Teleport a player to/from selected dungeon.
Definition: LFGMgr.cpp:1259
Definition: LFGMgr.h:47
void SetState(ObjectGuid guid, LfgState state)
Definition: LFGMgr.cpp:1682
void SetDungeon(ObjectGuid guid, uint32 dungeon)
Definition: LFGMgr.cpp:1715
ObjectGuid GetGroup(ObjectGuid guid)
Gets player group.
Definition: LFGMgr.cpp:1805
#define ASSERT
Definition: Errors.h:55
void SetDungeonDifficultyID(Difficulty difficulty)
Definition: Group.cpp:2008
Definition: ObjectGuid.h:189
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:215
void SendUpdate()
Definition: Group.cpp:1567
Definition: Group.h:191
void ConvertToLFG()
Definition: Group.cpp:227

+ Here is the call graph for this function:

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

Removes saved group data.

1754 {
1755  TC_LOG_TRACE("lfg.data.group.remove", "Group: %s", guid.ToString().c_str());
1756  LfgGroupDataContainer::iterator it = GroupsStore.find(guid);
1757  if (it == GroupsStore.end())
1758  return;
1759 
1760  LfgState state = GetState(guid);
1761  // If group is being formed after proposal success do nothing more
1762  GuidSet const& players = it->second.GetPlayers();
1763  for (ObjectGuid playerGUID : players)
1764  {
1765  SetGroup(playerGUID, ObjectGuid::Empty);
1766  if (state != LFG_STATE_PROPOSAL)
1767  {
1768  SetState(playerGUID, LFG_STATE_NONE);
1769  SendLfgUpdateStatus(playerGUID, LfgUpdateData(LFG_UPDATETYPE_REMOVED_FROM_QUEUE), true);
1770  }
1771  }
1772  GroupsStore.erase(it);
1773 }
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
LfgState GetState(ObjectGuid guid)
Get current lfg state.
Definition: LFGMgr.cpp:1500
void SetGroup(ObjectGuid guid, ObjectGuid group)
Sets player group.
Definition: LFGMgr.cpp:1810
Definition: LFG.h:67
LfgState
Definition: LFG.h:65
Definition: LFG.h:70
#define TC_LOG_TRACE(filterType__,...)
Definition: Log.h:195
void SetState(ObjectGuid guid, LfgState state)
Definition: LFGMgr.cpp:1682
std::set< ObjectGuid > GuidSet
Definition: ObjectGuid.h:332
void SendLfgUpdateStatus(ObjectGuid guid, LfgUpdateData const &data, bool party)
Definition: LFGMgr.cpp:1849
Definition: ObjectGuid.h:189
LfgGroupDataContainer GroupsStore
Group data.
Definition: LFGMgr.h:476
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

void lfg::LFGMgr::RemovePlayerData ( ObjectGuid  guid)
private
1746 {
1747  TC_LOG_TRACE("lfg.data.player.remove", "Player: %s", guid.ToString().c_str());
1748  LfgPlayerDataContainer::iterator it = PlayersStore.find(guid);
1749  if (it != PlayersStore.end())
1750  PlayersStore.erase(it);
1751 }
#define TC_LOG_TRACE(filterType__,...)
Definition: Log.h:195
LfgPlayerDataContainer PlayersStore
Player data.
Definition: LFGMgr.h:475
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

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

Removes a player from a group.

1783 {
1784  return GroupsStore[gguid].RemovePlayer(guid);
1785 }
LfgGroupDataContainer GroupsStore
Group data.
Definition: LFGMgr.h:476
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)
1068 {
1069  LfgProposal& proposal = itProposal->second;
1070  proposal.state = LFG_PROPOSAL_FAILED;
1071 
1072  TC_LOG_DEBUG("lfg.proposal.remove", "Proposal %u, state FAILED, UpdateType %u", itProposal->first, type);
1073  // Mark all people that didn't answered as no accept
1074  if (type == LFG_UPDATETYPE_PROPOSAL_FAILED)
1075  for (LfgProposalPlayerContainer::iterator it = proposal.players.begin(); it != proposal.players.end(); ++it)
1076  if (it->second.accept == LFG_ANSWER_PENDING)
1077  it->second.accept = LFG_ANSWER_DENY;
1078 
1079  // Mark players/groups to be removed
1080  GuidSet toRemove;
1081  for (LfgProposalPlayerContainer::iterator it = proposal.players.begin(); it != proposal.players.end(); ++it)
1082  {
1083  if (it->second.accept == LFG_ANSWER_AGREE)
1084  continue;
1085 
1086  ObjectGuid guid = !it->second.group.IsEmpty() ? it->second.group : it->first;
1087  // Player didn't accept or still pending when no secs left
1088  if (it->second.accept == LFG_ANSWER_DENY || type == LFG_UPDATETYPE_PROPOSAL_FAILED)
1089  {
1090  it->second.accept = LFG_ANSWER_DENY;
1091  toRemove.insert(guid);
1092  }
1093  }
1094 
1095  // Notify players
1096  for (LfgProposalPlayerContainer::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it)
1097  {
1098  ObjectGuid guid = it->first;
1099  ObjectGuid gguid = !it->second.group.IsEmpty() ? it->second.group : guid;
1100 
1101  SendLfgUpdateProposal(guid, proposal);
1102 
1103  if (toRemove.find(gguid) != toRemove.end()) // Didn't accept or in same group that someone that didn't accept
1104  {
1105  LfgUpdateData updateData;
1106  if (it->second.accept == LFG_ANSWER_DENY)
1107  {
1108  updateData.updateType = type;
1109  TC_LOG_DEBUG("lfg.proposal.remove", "%s didn't accept. Removing from queue and compatible cache", guid.ToString().c_str());
1110  }
1111  else
1112  {
1113  updateData.updateType = LFG_UPDATETYPE_REMOVED_FROM_QUEUE;
1114  TC_LOG_DEBUG("lfg.proposal.remove", "%s in same group that someone that didn't accept. Removing from queue and compatible cache", guid.ToString().c_str());
1115  }
1116 
1117  RestoreState(guid, "Proposal Fail (didn't accepted or in group with someone that didn't accept");
1118  if (gguid != guid)
1119  {
1120  RestoreState(it->second.group, "Proposal Fail (someone in group didn't accepted)");
1121  SendLfgUpdateStatus(guid, updateData, true);
1122  }
1123  else
1124  SendLfgUpdateStatus(guid, updateData, false);
1125  }
1126  else
1127  {
1128  TC_LOG_DEBUG("lfg.proposal.remove", "Readding %s to queue.", guid.ToString().c_str());
1129  SetState(guid, LFG_STATE_QUEUED);
1130  if (gguid != guid)
1131  {
1132  SetState(gguid, LFG_STATE_QUEUED);
1133  SendLfgUpdateStatus(guid, LfgUpdateData(LFG_UPDATETYPE_ADDED_TO_QUEUE, GetSelectedDungeons(guid), GetComment(guid)), true);
1134  }
1135  else
1136  SendLfgUpdateStatus(guid, LfgUpdateData(LFG_UPDATETYPE_ADDED_TO_QUEUE, GetSelectedDungeons(guid), GetComment(guid)), false);
1137  }
1138  }
1139 
1140  LFGQueue& queue = GetQueue(proposal.players.begin()->first);
1141  // Remove players/groups from queue
1142  for (GuidSet::const_iterator it = toRemove.begin(); it != toRemove.end(); ++it)
1143  {
1144  ObjectGuid guid = *it;
1145  queue.RemoveFromQueue(guid);
1146  proposal.queues.remove(guid);
1147  }
1148 
1149  // Readd to queue
1150  for (GuidList::const_iterator it = proposal.queues.begin(); it != proposal.queues.end(); ++it)
1151  {
1152  ObjectGuid guid = *it;
1153  queue.AddToQueue(guid);
1154  }
1155 
1156  ProposalsStore.erase(itProposal);
1157 }
Definition: LFG.h:97
void RestoreState(ObjectGuid guid, char const *debugMsg)
Definition: LFGMgr.cpp:1660
LfgDungeonSet const & GetSelectedDungeons(ObjectGuid guid)
Get selected dungeons.
Definition: LFGMgr.cpp:1577
LfgProposalContainer ProposalsStore
Current Proposals.
Definition: LFGMgr.h:473
Definition: LFG.h:98
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: LFG.h:69
void SendLfgUpdateProposal(ObjectGuid guid, LfgProposal const &proposal)
Definition: LFGMgr.cpp:1867
Definition: LFGMgr.h:75
Definition: LFG.h:99
std::string const & GetComment(ObjectGuid gguid)
Get current player comment (used for LFR)
Definition: LFGMgr.cpp:1571
void SetState(ObjectGuid guid, LfgState state)
Definition: LFGMgr.cpp:1682
std::set< ObjectGuid > GuidSet
Definition: ObjectGuid.h:332
LFGQueue & GetQueue(ObjectGuid guid)
Definition: LFGMgr.cpp:1897
void SendLfgUpdateStatus(ObjectGuid guid, LfgUpdateData const &data, bool party)
Definition: LFGMgr.cpp:1849
Definition: ObjectGuid.h:189
std::string ToString() const
Definition: ObjectGuid.cpp:99
bool IsEmpty() const
Definition: ObjectGuid.h:242

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void lfg::LFGMgr::RestoreState ( ObjectGuid  guid,
char const debugMsg 
)
private
1661 {
1662  if (guid.IsParty())
1663  {
1664  LfgGroupData& data = GroupsStore[guid];
1665  TC_LOG_TRACE("lfg.data.group.state.restore", "Group: %s (%s), State: %s, Old state: %s",
1666  guid.ToString().c_str(), debugMsg, GetStateString(data.GetState()).c_str(),
1667  GetStateString(data.GetOldState()).c_str());
1668 
1669  data.RestoreState();
1670  }
1671  else
1672  {
1673  LfgPlayerData& data = PlayersStore[guid];
1674  TC_LOG_TRACE("lfg.data.player.state.restore", "Player: %s (%s), State: %s, Old state: %s",
1675  guid.ToString().c_str(), debugMsg, GetStateString(data.GetState()).c_str(),
1676  GetStateString(data.GetOldState()).c_str());
1677 
1678  data.RestoreState();
1679  }
1680 }
std::string GetStateString(LfgState state)
Definition: LFG.cpp:74
#define TC_LOG_TRACE(filterType__,...)
Definition: Log.h:195
LfgPlayerDataContainer PlayersStore
Player data.
Definition: LFGMgr.h:475
LfgGroupDataContainer GroupsStore
Group data.
Definition: LFGMgr.h:476
bool IsParty() const
Definition: ObjectGuid.h:258
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Check if given guid applied for random dungeon.

1994 {
1995  if (GetState(guid) != LFG_STATE_NONE)
1996  {
1997  LfgDungeonSet const& dungeons = GetSelectedDungeons(guid);
1998  if (!dungeons.empty())
1999  {
2000  LFGDungeonData const* dungeon = GetLFGDungeon(*dungeons.begin());
2001  if (dungeon && (dungeon->type == LFG_TYPE_RANDOM || dungeon->seasonal))
2002  return true;
2003  }
2004  }
2005 
2006  return false;
2007 }
LfgState GetState(ObjectGuid guid)
Get current lfg state.
Definition: LFGMgr.cpp:1500
Definition: LFGMgr.h:68
Definition: LFG.h:67
LfgDungeonSet const & GetSelectedDungeons(ObjectGuid guid)
Get selected dungeons.
Definition: LFGMgr.cpp:1577
LFGDungeonData const * GetLFGDungeon(uint32 id)
Definition: LFGMgr.cpp:163
std::set< uint32 > LfgDungeonSet
Definition: LFG.h:112

+ Here is the call graph for this function:

void lfg::LFGMgr::SendLfgBootProposalUpdate ( ObjectGuid  guid,
LfgPlayerBoot const boot 
)
private
1862 {
1863  if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
1864  player->GetSession()->SendLfgBootProposalUpdate(boot);
1865 }
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:215

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void lfg::LFGMgr::SendLfgJoinResult ( ObjectGuid  guid,
LfgJoinResultData const data 
)
private
1856 {
1857  if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
1858  player->GetSession()->SendLfgJoinResult(data);
1859 }
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:215

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Sends queue status to player.

1874 {
1875  if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
1876  player->GetSession()->SendLfgQueueStatus(data);
1877 }
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:215

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void lfg::LFGMgr::SendLfgRoleCheckUpdate ( ObjectGuid  guid,
LfgRoleCheck const roleCheck 
)
private
1844 {
1845  if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
1846  player->GetSession()->SendLfgRoleCheckUpdate(roleCheck);
1847 }
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:215

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void lfg::LFGMgr::SendLfgRoleChosen ( ObjectGuid  guid,
ObjectGuid  pguid,
uint8  roles 
)
private
1838 {
1839  if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
1840  player->GetSession()->SendLfgRoleChosen(pguid, roles);
1841 }
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:215

+ Here is the call graph for this function:

void lfg::LFGMgr::SendLfgUpdateProposal ( ObjectGuid  guid,
LfgProposal const proposal 
)
private
1868 {
1869  if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
1870  player->GetSession()->SendLfgUpdateProposal(proposal);
1871 }
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:215

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void lfg::LFGMgr::SendLfgUpdateStatus ( ObjectGuid  guid,
LfgUpdateData const data,
bool  party 
)
private
1850 {
1851  if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
1852  player->GetSession()->SendLfgUpdateStatus(data, party);
1853 }
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:215

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Sets player lfr comment.

1728 {
1729  TC_LOG_TRACE("lfg.data.player.comment.set", "Player: %s, Comment: %s", guid.ToString().c_str(), comment.c_str());
1730  PlayersStore[guid].SetComment(comment);
1731 }
#define TC_LOG_TRACE(filterType__,...)
Definition: Log.h:195
LfgPlayerDataContainer PlayersStore
Player data.
Definition: LFGMgr.h:475
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

void lfg::LFGMgr::SetDungeon ( ObjectGuid  guid,
uint32  dungeon 
)
private
1716 {
1717  TC_LOG_TRACE("lfg.data.group.dungeon.set", "Group: %s, Dungeon: %u", guid.ToString().c_str(), dungeon);
1718  GroupsStore[guid].SetDungeon(dungeon);
1719 }
#define TC_LOG_TRACE(filterType__,...)
Definition: Log.h:195
LfgGroupDataContainer GroupsStore
Group data.
Definition: LFGMgr.h:476
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Sets player group.

1811 {
1812  PlayersStore[guid].SetGroup(group);
1813 }
LfgPlayerDataContainer PlayersStore
Player data.
Definition: LFGMgr.h:475
void lfg::LFGMgr::SetLeader ( ObjectGuid  gguid,
ObjectGuid  leader 
)

Sets the leader of the group.

1793 {
1794  GroupsStore[gguid].SetLeader(leader);
1795 }
LfgGroupDataContainer GroupsStore
Group data.
Definition: LFGMgr.h:476

+ Here is the caller graph for this function:

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

Sets new lfg options.

1941 {
1942  m_options = options;
1943 }
uint32 m_options
Stores config options.
Definition: LFGMgr.h:464
void lfg::LFGMgr::SetRoles ( ObjectGuid  guid,
uint8  roles 
)

Sets player lfg roles.

1722 {
1723  TC_LOG_TRACE("lfg.data.player.role.set", "Player: %s, Roles: %u", guid.ToString().c_str(), roles);
1724  PlayersStore[guid].SetRoles(roles);
1725 }
#define TC_LOG_TRACE(filterType__,...)
Definition: Log.h:195
LfgPlayerDataContainer PlayersStore
Player data.
Definition: LFGMgr.h:475
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

void lfg::LFGMgr::SetSelectedDungeons ( ObjectGuid  guid,
LfgDungeonSet const dungeons 
)
private
1734 {
1735  TC_LOG_TRACE("lfg.data.player.dungeon.selected.set", "Player: %s, Dungeons: %s", guid.ToString().c_str(), ConcatenateDungeons(dungeons).c_str());
1736  PlayersStore[guid].SetSelectedDungeons(dungeons);
1737 }
std::string ConcatenateDungeons(LfgDungeonSet const &dungeons)
Definition: LFG.cpp:25
#define TC_LOG_TRACE(filterType__,...)
Definition: Log.h:195
LfgPlayerDataContainer PlayersStore
Player data.
Definition: LFGMgr.h:475
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

void lfg::LFGMgr::SetState ( ObjectGuid  guid,
LfgState  state 
)
private
1683 {
1684  if (guid.IsParty())
1685  {
1686  LfgGroupData& data = GroupsStore[guid];
1687  TC_LOG_TRACE("lfg.data.group.state.set", "Group: %s, New state: %s, Previous: %s, Old state: %s",
1688  guid.ToString().c_str(), GetStateString(state).c_str(), GetStateString(data.GetState()).c_str(),
1689  GetStateString(data.GetOldState()).c_str());
1690 
1691  data.SetState(state);
1692  }
1693  else
1694  {
1695  LfgPlayerData& data = PlayersStore[guid];
1696  TC_LOG_TRACE("lfg.data.player.state.set", "Player: %s, New state: %s, Previous: %s, OldState: %s",
1697  guid.ToString().c_str(), GetStateString(state).c_str(), GetStateString(data.GetState()).c_str(),
1698  GetStateString(data.GetOldState()).c_str());
1699 
1700  data.SetState(state);
1701  }
1702 }
std::string GetStateString(LfgState state)
Definition: LFG.cpp:74
#define TC_LOG_TRACE(filterType__,...)
Definition: Log.h:195
LfgPlayerDataContainer PlayersStore
Player data.
Definition: LFGMgr.h:475
LfgGroupDataContainer GroupsStore
Group data.
Definition: LFGMgr.h:476
bool IsParty() const
Definition: ObjectGuid.h:258
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void lfg::LFGMgr::SetTeam ( ObjectGuid  guid,
uint8  team 
)

Sets player team.

1798 {
1799  if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP))
1800  team = 0;
1801 
1802  PlayersStore[guid].SetTeam(team);
1803 }
#define sWorld
Definition: World.h:887
LfgPlayerDataContainer PlayersStore
Player data.
Definition: LFGMgr.h:475
void lfg::LFGMgr::SetupGroupMember ( ObjectGuid  guid,
ObjectGuid  gguid 
)

Initializes player data after loading group data from DB.

1984 {
1985  LfgDungeonSet dungeons;
1986  dungeons.insert(GetDungeon(gguid));
1987  SetSelectedDungeons(guid, dungeons);
1988  SetState(guid, GetState(gguid));
1989  SetGroup(guid, gguid);
1990  AddPlayerToGroup(gguid, guid);
1991 }
LfgState GetState(ObjectGuid guid)
Get current lfg state.
Definition: LFGMgr.cpp:1500
void SetGroup(ObjectGuid guid, ObjectGuid group)
Sets player group.
Definition: LFGMgr.cpp:1810
void AddPlayerToGroup(ObjectGuid gguid, ObjectGuid guid)
Adds player to group.
Definition: LFGMgr.cpp:1787
std::set< uint32 > LfgDungeonSet
Definition: LFG.h:112
uint32 GetDungeon(ObjectGuid guid, bool asId=true)
Get current dungeon.
Definition: LFGMgr.cpp:1544
void SetState(ObjectGuid guid, LfgState state)
Definition: LFGMgr.cpp:1682
void SetSelectedDungeons(ObjectGuid guid, LfgDungeonSet const &dungeons)
Definition: LFGMgr.cpp:1733
void lfg::LFGMgr::SetVoteKick ( ObjectGuid  gguid,
bool  active 
)
private
1705 {
1706  ASSERT(gguid.IsParty());
1707 
1708  LfgGroupData& data = GroupsStore[gguid];
1709  TC_LOG_TRACE("lfg.data.group.votekick.set", "Group: %s, New state: %d, Previous: %d",
1710  gguid.ToString().c_str(), active, data.IsVoteKickActive());
1711 
1712  data.SetVoteKick(active);
1713 }
#define TC_LOG_TRACE(filterType__,...)
Definition: Log.h:195
#define ASSERT
Definition: Errors.h:55
LfgGroupDataContainer GroupsStore
Group data.
Definition: LFGMgr.h:476
bool IsParty() const
Definition: ObjectGuid.h:258
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void lfg::LFGMgr::TeleportPlayer ( Player *  player,
bool  out,
bool  fromOpcode = false 
)

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)
1260 {
1261  LFGDungeonData const* dungeon = NULL;
1262  Group* group = player->GetGroup();
1263 
1264  if (group && group->isLFGGroup())
1265  dungeon = GetLFGDungeon(GetDungeon(group->GetGUID()));
1266 
1267  if (!dungeon)
1268  {
1269  TC_LOG_DEBUG("lfg.teleport", "Player %s not in group/lfggroup or dungeon not found!",
1270  player->GetName().c_str());
1271  player->GetSession()->SendLfgTeleportError(uint8(LFG_TELEPORTERROR_INVALID_LOCATION));
1272  return;
1273  }
1274 
1275  if (out)
1276  {
1277  TC_LOG_DEBUG("lfg.teleport", "Player %s is being teleported out. Current Map %u - Expected Map %u",
1278  player->GetName().c_str(), player->GetMapId(), uint32(dungeon->map));
1279  if (player->GetMapId() == uint32(dungeon->map))
1280  player->TeleportToBGEntryPoint();
1281 
1282  return;
1283  }
1284 
1286 
1287  if (!player->IsAlive())
1289  else if (player->IsFalling() || player->HasUnitState(UNIT_STATE_JUMPING))
1290  error = LFG_TELEPORTERROR_FALLING;
1291  else if (player->IsMirrorTimerActive(FATIGUE_TIMER))
1292  error = LFG_TELEPORTERROR_FATIGUE;
1293  else if (player->GetVehicle())
1295  else if (!player->GetCharmGUID().IsEmpty())
1297  else if (player->HasAura(9454)) // check Freeze debuff
1299  else if (player->GetMapId() != uint32(dungeon->map)) // Do not teleport players in dungeon to the entrance
1300  {
1301  uint32 mapid = dungeon->map;
1302  float x = dungeon->x;
1303  float y = dungeon->y;
1304  float z = dungeon->z;
1305  float orientation = dungeon->o;
1306 
1307  if (!fromOpcode)
1308  {
1309  // Select a player inside to be teleported to
1310  for (GroupReference* itr = group->GetFirstMember(); itr != NULL && !mapid; itr = itr->next())
1311  {
1312  Player* plrg = itr->GetSource();
1313  if (plrg && plrg != player && plrg->GetMapId() == uint32(dungeon->map))
1314  {
1315  mapid = plrg->GetMapId();
1316  x = plrg->GetPositionX();
1317  y = plrg->GetPositionY();
1318  z = plrg->GetPositionZ();
1319  orientation = plrg->GetOrientation();
1320  break;
1321  }
1322  }
1323  }
1324 
1325  if (!player->GetMap()->IsDungeon())
1326  player->SetBattlegroundEntryPoint();
1327 
1328  if (player->IsInFlight())
1329  {
1330  player->GetMotionMaster()->MovementExpired();
1331  player->CleanupAfterTaxiFlight();
1332  }
1333 
1334  if (!player->TeleportTo(mapid, x, y, z, orientation))
1336  }
1337  else
1339 
1340  if (error != LFG_TELEPORTERROR_OK)
1341  player->GetSession()->SendLfgTeleportError(uint8(error));
1342 
1343  TC_LOG_DEBUG("lfg.teleport", "Player %s is being teleported in to map %u "
1344  "(x: %f, y: %f, z: %f) Result: %u", player->GetName().c_str(), dungeon->map,
1345  dungeon->x, dungeon->y, dungeon->z, error);
1346 }
ObjectGuid GetGUID() const
Definition: Group.cpp:2534
LfgTeleportError
Teleport errors.
Definition: LFGMgr.h:80
Definition: LFGMgr.h:84
arena_t NULL
Definition: jemalloc_internal.h:624
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Unit.h:568
LFGDungeonData const * GetLFGDungeon(uint32 id)
Definition: LFGMgr.cpp:163
G3D::int16 z
Definition: Vector3int16.h:46
Definition: LFGMgr.h:85
uint32_t uint32
Definition: Define.h:150
uint32 GetDungeon(ObjectGuid guid, bool asId=true)
Get current dungeon.
Definition: LFGMgr.cpp:1544
G3D::int16 y
Definition: Vector2int16.h:38
Definition: LFGMgr.h:89
GroupReference * GetFirstMember()
Definition: Group.h:295
Definition: LFGMgr.h:83
bool isLFGGroup() const
Definition: Group.cpp:2504
uint8_t uint8
Definition: g3dmath.h:164
Definition: LFGMgr.h:86
Definition: LFGMgr.h:87
uint32_t uint32
Definition: g3dmath.h:168
G3D::int16 x
Definition: Vector2int16.h:37
Definition: Group.h:191
Definition: GroupReference.h:27

+ Here is the call graph for this function:

void lfg::LFGMgr::Update ( uint32  diff)
268 {
270  return;
271 
272  time_t currTime = time(NULL);
273 
274  // Remove obsolete role checks
275  for (LfgRoleCheckContainer::iterator it = RoleChecksStore.begin(); it != RoleChecksStore.end();)
276  {
277  LfgRoleCheckContainer::iterator itRoleCheck = it++;
278  LfgRoleCheck& roleCheck = itRoleCheck->second;
279  if (currTime < roleCheck.cancelTime)
280  continue;
281  roleCheck.state = LFG_ROLECHECK_MISSING_ROLE;
282 
283  for (LfgRolesMap::const_iterator itRoles = roleCheck.roles.begin(); itRoles != roleCheck.roles.end(); ++itRoles)
284  {
285  ObjectGuid guid = itRoles->first;
286  RestoreState(guid, "Remove Obsolete RoleCheck");
287  SendLfgRoleCheckUpdate(guid, roleCheck);
288  if (guid == roleCheck.leader)
290  }
291 
292  RestoreState(itRoleCheck->first, "Remove Obsolete RoleCheck");
293  RoleChecksStore.erase(itRoleCheck);
294  }
295 
296  // Remove obsolete proposals
297  for (LfgProposalContainer::iterator it = ProposalsStore.begin(); it != ProposalsStore.end();)
298  {
299  LfgProposalContainer::iterator itRemove = it++;
300  if (itRemove->second.cancelTime < currTime)
302  }
303 
304  // Remove obsolete kicks
305  for (LfgPlayerBootContainer::iterator it = BootsStore.begin(); it != BootsStore.end();)
306  {
307  LfgPlayerBootContainer::iterator itBoot = it++;
308  LfgPlayerBoot& boot = itBoot->second;
309  if (boot.cancelTime < currTime)
310  {
311  boot.inProgress = false;
312  for (LfgAnswerContainer::const_iterator itVotes = boot.votes.begin(); itVotes != boot.votes.end(); ++itVotes)
313  {
314  ObjectGuid pguid = itVotes->first;
315  if (pguid != boot.victim)
316  SendLfgBootProposalUpdate(pguid, boot);
317  }
318  SetVoteKick(itBoot->first, false);
319  BootsStore.erase(itBoot);
320  }
321  }
322 
323  uint32 lastProposalId = m_lfgProposalId;
324  // Check if a proposal can be formed with the new groups being added
325  for (LfgQueueContainer::iterator it = QueuesStore.begin(); it != QueuesStore.end(); ++it)
326  if (uint8 newProposals = it->second.FindGroups())
327  TC_LOG_DEBUG("lfg.update", "Found %u new groups in queue %u", newProposals, it->first);
328 
329  if (lastProposalId != m_lfgProposalId)
330  {
331  // FIXME lastProposalId ? lastProposalId +1 ?
332  for (LfgProposalContainer::const_iterator itProposal = ProposalsStore.find(m_lfgProposalId); itProposal != ProposalsStore.end(); ++itProposal)
333  {
334  uint32 proposalId = itProposal->first;
335  LfgProposal& proposal = ProposalsStore[proposalId];
336 
337  ObjectGuid guid;
338  for (LfgProposalPlayerContainer::const_iterator itPlayers = proposal.players.begin(); itPlayers != proposal.players.end(); ++itPlayers)
339  {
340  guid = itPlayers->first;
342  ObjectGuid gguid = GetGroup(guid);
343  if (!gguid.IsEmpty())
344  {
346  SendLfgUpdateStatus(guid, LfgUpdateData(LFG_UPDATETYPE_PROPOSAL_BEGIN, GetSelectedDungeons(guid), GetComment(guid)), true);
347  }
348  else
349  SendLfgUpdateStatus(guid, LfgUpdateData(LFG_UPDATETYPE_PROPOSAL_BEGIN, GetSelectedDungeons(guid), GetComment(guid)), false);
350  SendLfgUpdateProposal(guid, proposal);
351  }
352 
353  if (proposal.state == LFG_PROPOSAL_SUCCESS)
354  UpdateProposal(proposalId, guid, true);
355  }
356  }
357 
358  // Update all players status queue info
360  {
361  m_QueueTimer = 0;
362  for (LfgQueueContainer::iterator it = QueuesStore.begin(); it != QueuesStore.end(); ++it)
363  it->second.UpdateQueueTimers(it->first, currTime);
364  }
365  else
366  m_QueueTimer += diff;
367 }
void RemoveProposal(LfgProposalContainer::iterator itProposal, LfgUpdateType type)
Definition: LFGMgr.cpp:1067
bool isOptionEnabled(uint32 option)
Checks if given lfg option is enabled.
Definition: LFGMgr.cpp:1930
void SendLfgBootProposalUpdate(ObjectGuid guid, LfgPlayerBoot const &boot)
Definition: LFGMgr.cpp:1861
LfgPlayerBootContainer BootsStore
Current player kicks.
Definition: LFGMgr.h:474
uint32 m_lfgProposalId
used as internal counter for proposals
Definition: LFGMgr.h:463
Definition: LFGMgr.h:76
LfgQueueContainer QueuesStore
Queues.
Definition: LFGMgr.h:466
LfgRoleCheckContainer RoleChecksStore
Current Role checks.
Definition: LFGMgr.h:472
void RestoreState(ObjectGuid guid, char const *debugMsg)
Definition: LFGMgr.cpp:1660
LfgDungeonSet const & GetSelectedDungeons(ObjectGuid guid)
Get selected dungeons.
Definition: LFGMgr.cpp:1577
arena_t NULL
Definition: jemalloc_internal.h:624
LfgProposalContainer ProposalsStore
Current Proposals.
Definition: LFGMgr.h:473
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: LFG.h:70
void SendLfgJoinResult(ObjectGuid guid, LfgJoinResultData const &data)
Definition: LFGMgr.cpp:1855
Definition: LFGMgr.h:113
void SendLfgUpdateProposal(ObjectGuid guid, LfgProposal const &proposal)
Definition: LFGMgr.cpp:1867
void UpdateProposal(uint32 proposalId, ObjectGuid guid, bool accept)
Updates proposal to join dungeon with player answer.
Definition: LFGMgr.cpp:964
Definition: LFGMgr.h:46
Definition: LFGMgr.h:122
uint32_t uint32
Definition: Define.h:150
uint32 m_QueueTimer
used to check interval of update
Definition: LFGMgr.h:462
std::string const & GetComment(ObjectGuid gguid)
Get current player comment (used for LFR)
Definition: LFGMgr.cpp:1571
void SetState(ObjectGuid guid, LfgState state)
Definition: LFGMgr.cpp:1682
void SendLfgRoleCheckUpdate(ObjectGuid guid, LfgRoleCheck const &roleCheck)
Definition: LFGMgr.cpp:1843
ObjectGuid GetGroup(ObjectGuid guid)
Gets player group.
Definition: LFGMgr.cpp:1805
uint8_t uint8
Definition: Define.h:152
void SendLfgUpdateStatus(ObjectGuid guid, LfgUpdateData const &data, bool party)
Definition: LFGMgr.cpp:1849
Definition: ObjectGuid.h:189
bool IsEmpty() const
Definition: ObjectGuid.h:242
void SetVoteKick(ObjectGuid gguid, bool active)
Definition: LFGMgr.cpp:1704

+ Here is the call graph for this function:

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
1201 {
1202  ObjectGuid gguid = GetGroup(guid);
1203  if (!gguid)
1204  return;
1205 
1206  LfgPlayerBootContainer::iterator itBoot = BootsStore.find(gguid);
1207  if (itBoot == BootsStore.end())
1208  return;
1209 
1210  LfgPlayerBoot& boot = itBoot->second;
1211 
1212  if (boot.votes[guid] != LFG_ANSWER_PENDING) // Cheat check: Player can't vote twice
1213  return;
1214 
1215  boot.votes[guid] = LfgAnswer(accept);
1216 
1217  uint8 votesNum = 0;
1218  uint8 agreeNum = 0;
1219  for (LfgAnswerContainer::const_iterator itVotes = boot.votes.begin(); itVotes != boot.votes.end(); ++itVotes)
1220  {
1221  if (itVotes->second != LFG_ANSWER_PENDING)
1222  {
1223  ++votesNum;
1224  if (itVotes->second == LFG_ANSWER_AGREE)
1225  ++agreeNum;
1226  }
1227  }
1228 
1229  // if we don't have enough votes (agree or deny) do nothing
1230  if (agreeNum < LFG_GROUP_KICK_VOTES_NEEDED && (votesNum - agreeNum) < LFG_GROUP_KICK_VOTES_NEEDED)
1231  return;
1232 
1233  // Send update info to all players
1234  boot.inProgress = false;
1235  for (LfgAnswerContainer::const_iterator itVotes = boot.votes.begin(); itVotes != boot.votes.end(); ++itVotes)
1236  {
1237  ObjectGuid pguid = itVotes->first;
1238  if (pguid != boot.victim)
1239  SendLfgBootProposalUpdate(pguid, boot);
1240  }
1241 
1242  SetVoteKick(gguid, false);
1243  if (agreeNum == LFG_GROUP_KICK_VOTES_NEEDED) // Vote passed - Kick player
1244  {
1245  if (Group* group = sGroupMgr->GetGroupByGUID(gguid))
1246  Player::RemoveFromGroup(group, boot.victim, GROUP_REMOVEMETHOD_KICK_LFG);
1247  DecreaseKicksLeft(gguid);
1248  }
1249  BootsStore.erase(itBoot);
1250 }
void SendLfgBootProposalUpdate(ObjectGuid guid, LfgPlayerBoot const &boot)
Definition: LFGMgr.cpp:1861
Definition: LFG.h:97
LfgPlayerBootContainer BootsStore
Current player kicks.
Definition: LFGMgr.h:474
Definition: LFGMgr.h:50
LfgAnswer
Answer state (Also used to check compatibilites)
Definition: LFG.h:95
void DecreaseKicksLeft(ObjectGuid guid)
Definition: LFGMgr.cpp:1739
#define sGroupMgr
Definition: GroupMgr.h:59
Definition: LFG.h:99
ObjectGuid GetGroup(ObjectGuid guid)
Gets player group.
Definition: LFGMgr.cpp:1805
uint8_t uint8
Definition: Define.h:152
Definition: SharedDefines.h:4690
Definition: ObjectGuid.h:189
Definition: Group.h:191
void SetVoteKick(ObjectGuid gguid, bool active)
Definition: LFGMgr.cpp:1704
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
965 {
966  // Check if the proposal exists
967  LfgProposalContainer::iterator itProposal = ProposalsStore.find(proposalId);
968  if (itProposal == ProposalsStore.end())
969  return;
970 
971  LfgProposal& proposal = itProposal->second;
972 
973  // Check if proposal have the current player
974  LfgProposalPlayerContainer::iterator itProposalPlayer = proposal.players.find(guid);
975  if (itProposalPlayer == proposal.players.end())
976  return;
977 
978  LfgProposalPlayer& player = itProposalPlayer->second;
979  player.accept = LfgAnswer(accept);
980 
981  TC_LOG_DEBUG("lfg.proposal.update", "%s, Proposal %u, Selection: %u", guid.ToString().c_str(), proposalId, accept);
982  if (!accept)
983  {
985  return;
986  }
987 
988  // check if all have answered and reorder players (leader first)
989  bool allAnswered = true;
990  for (LfgProposalPlayerContainer::const_iterator itPlayers = proposal.players.begin(); itPlayers != proposal.players.end(); ++itPlayers)
991  if (itPlayers->second.accept != LFG_ANSWER_AGREE) // No answer (-1) or not accepted (0)
992  allAnswered = false;
993 
994  if (!allAnswered)
995  {
996  for (LfgProposalPlayerContainer::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it)
997  SendLfgUpdateProposal(it->first, proposal);
998 
999  return;
1000  }
1001 
1002  bool sendUpdate = proposal.state != LFG_PROPOSAL_SUCCESS;
1003  proposal.state = LFG_PROPOSAL_SUCCESS;
1004  time_t joinTime = time(NULL);
1005 
1006  LFGQueue& queue = GetQueue(guid);
1007  LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_GROUP_FOUND);
1008  for (LfgProposalPlayerContainer::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it)
1009  {
1010  ObjectGuid pguid = it->first;
1011  ObjectGuid gguid = it->second.group;
1012  uint32 dungeonId = (*GetSelectedDungeons(pguid).begin());
1013  int32 waitTime = -1;
1014  if (sendUpdate)
1015  SendLfgUpdateProposal(pguid, proposal);
1016 
1017  if (!gguid.IsEmpty())
1018  {
1019  waitTime = int32((joinTime - queue.GetJoinTime(gguid)) / IN_MILLISECONDS);
1020  SendLfgUpdateStatus(pguid, updateData, false);
1021  }
1022  else
1023  {
1024  waitTime = int32((joinTime - queue.GetJoinTime(pguid)) / IN_MILLISECONDS);
1025  SendLfgUpdateStatus(pguid, updateData, false);
1026  }
1027  updateData.updateType = LFG_UPDATETYPE_REMOVED_FROM_QUEUE;
1028  SendLfgUpdateStatus(pguid, updateData, true);
1029  SendLfgUpdateStatus(pguid, updateData, false);
1030 
1031  // Update timers
1032  uint8 role = GetRoles(pguid);
1033  role &= ~PLAYER_ROLE_LEADER;
1034  switch (role)
1035  {
1036  case PLAYER_ROLE_DAMAGE:
1037  queue.UpdateWaitTimeDps(waitTime, dungeonId);
1038  break;
1039  case PLAYER_ROLE_HEALER:
1040  queue.UpdateWaitTimeHealer(waitTime, dungeonId);
1041  break;
1042  case PLAYER_ROLE_TANK:
1043  queue.UpdateWaitTimeTank(waitTime, dungeonId);
1044  break;
1045  default:
1046  queue.UpdateWaitTimeAvg(waitTime, dungeonId);
1047  break;
1048  }
1049 
1050  SetState(pguid, LFG_STATE_DUNGEON);
1051  }
1052 
1053  // Remove players/groups from Queue
1054  for (GuidList::const_iterator it = proposal.queues.begin(); it != proposal.queues.end(); ++it)
1055  queue.RemoveFromQueue(*it);
1056 
1057  MakeNewGroup(proposal);
1058  ProposalsStore.erase(itProposal);
1059 }
void RemoveProposal(LfgProposalContainer::iterator itProposal, LfgUpdateType type)
Definition: LFGMgr.cpp:1067
Definition: LFG.h:39
Definition: LFG.h:37
Definition: LFGMgr.h:76
Definition: LFG.h:40
LfgDungeonSet const & GetSelectedDungeons(ObjectGuid guid)
Get selected dungeons.
Definition: LFGMgr.cpp:1577
arena_t NULL
Definition: jemalloc_internal.h:624
LfgProposalContainer ProposalsStore
Current Proposals.
Definition: LFGMgr.h:473
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: LFG.h:72
void MakeNewGroup(LfgProposal const &proposal)
Definition: LFGMgr.cpp:881
void SendLfgUpdateProposal(ObjectGuid guid, LfgProposal const &proposal)
Definition: LFGMgr.cpp:1867
LfgAnswer
Answer state (Also used to check compatibilites)
Definition: LFG.h:95
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
Definition: LFG.h:99
void SetState(ObjectGuid guid, LfgState state)
Definition: LFGMgr.cpp:1682
Definition: Common.h:103
Definition: LFG.h:38
int32_t int32
Definition: g3dmath.h:167
LFGQueue & GetQueue(ObjectGuid guid)
Definition: LFGMgr.cpp:1897
uint8_t uint8
Definition: Define.h:152
void SendLfgUpdateStatus(ObjectGuid guid, LfgUpdateData const &data, bool party)
Definition: LFGMgr.cpp:1849
uint8 GetRoles(ObjectGuid guid)
Get current player roles.
Definition: LFGMgr.cpp:1564
Definition: ObjectGuid.h:189
std::string ToString() const
Definition: ObjectGuid.cpp:99
bool IsEmpty() const
Definition: ObjectGuid.h:242

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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
667 {
668  if (!gguid)
669  return;
670 
671  LfgRolesMap check_roles;
672  LfgRoleCheckContainer::iterator itRoleCheck = RoleChecksStore.find(gguid);
673  if (itRoleCheck == RoleChecksStore.end())
674  return;
675 
676  LfgRoleCheck& roleCheck = itRoleCheck->second;
677  bool sendRoleChosen = roleCheck.state != LFG_ROLECHECK_DEFAULT && !guid.IsEmpty();
678 
679  if (!guid)
680  roleCheck.state = LFG_ROLECHECK_ABORTED;
681  else if (roles < PLAYER_ROLE_TANK) // Player selected no role.
682  roleCheck.state = LFG_ROLECHECK_NO_ROLE;
683  else
684  {
685  roleCheck.roles[guid] = roles;
686 
687  // Check if all players have selected a role
688  LfgRolesMap::const_iterator itRoles = roleCheck.roles.begin();
689  while (itRoles != roleCheck.roles.end() && itRoles->second != PLAYER_ROLE_NONE)
690  ++itRoles;
691 
692  if (itRoles == roleCheck.roles.end())
693  {
694  // use temporal var to check roles, CheckGroupRoles modifies the roles
695  check_roles = roleCheck.roles;
696  roleCheck.state = CheckGroupRoles(check_roles) ? LFG_ROLECHECK_FINISHED : LFG_ROLECHECK_WRONG_ROLES;
697  }
698  }
699 
700  LfgDungeonSet dungeons;
701  if (roleCheck.rDungeonId)
702  dungeons.insert(roleCheck.rDungeonId);
703  else
704  dungeons = roleCheck.dungeons;
705 
706  LfgJoinResult joinResult = LFG_JOIN_FAILED;
707  if (roleCheck.state == LFG_ROLECHECK_MISSING_ROLE || roleCheck.state == LFG_ROLECHECK_WRONG_ROLES)
708  joinResult = LFG_JOIN_ROLE_CHECK_FAILED;
709 
710  LfgJoinResultData joinData = LfgJoinResultData(joinResult, roleCheck.state);
711  for (LfgRolesMap::const_iterator it = roleCheck.roles.begin(); it != roleCheck.roles.end(); ++it)
712  {
713  ObjectGuid pguid = it->first;
714 
715  if (sendRoleChosen)
716  SendLfgRoleChosen(pguid, guid, roles);
717 
718  SendLfgRoleCheckUpdate(pguid, roleCheck);
719  switch (roleCheck.state)
720  {
722  continue;
724  SetState(pguid, LFG_STATE_QUEUED);
725  SetRoles(pguid, it->second);
726  SendLfgUpdateStatus(pguid, LfgUpdateData(LFG_UPDATETYPE_ADDED_TO_QUEUE, dungeons, GetComment(pguid)), true);
727  break;
728  default:
729  if (roleCheck.leader == pguid)
730  SendLfgJoinResult(pguid, joinData);
731  SendLfgUpdateStatus(pguid, LfgUpdateData(LFG_UPDATETYPE_ROLECHECK_FAILED), true);
732  RestoreState(pguid, "Rolecheck Failed");
733  break;
734  }
735  }
736 
737  if (roleCheck.state == LFG_ROLECHECK_FINISHED)
738  {
739  SetState(gguid, LFG_STATE_QUEUED);
740  LFGQueue& queue = GetQueue(gguid);
741  queue.AddQueueData(gguid, time_t(time(NULL)), roleCheck.dungeons, roleCheck.roles);
742  RoleChecksStore.erase(itRoleCheck);
743  }
744  else if (roleCheck.state != LFG_ROLECHECK_INITIALITING)
745  {
746  RestoreState(gguid, "Rolecheck Failed");
747  RoleChecksStore.erase(itRoleCheck);
748  }
749 }
static bool CheckGroupRoles(LfgRolesMap &groles)
Checks if given roles match, modifies given roles map with new roles.
Definition: LFGMgr.cpp:814
Definition: LFG.h:36
LfgJoinResult
Queue join results.
Definition: LFGMgr.h:93
void SetRoles(ObjectGuid guid, uint8 roles)
Sets player lfg roles.
Definition: LFGMgr.cpp:1721
LfgRoleCheckContainer RoleChecksStore
Current Role checks.
Definition: LFGMgr.h:472
void RestoreState(ObjectGuid guid, char const *debugMsg)
Definition: LFGMgr.cpp:1660
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: LFG.h:69
void SendLfgJoinResult(ObjectGuid guid, LfgJoinResultData const &data)
Definition: LFGMgr.cpp:1855
void SendLfgRoleChosen(ObjectGuid guid, ObjectGuid pguid, uint8 roles)
Definition: LFGMgr.cpp:1837
Definition: LFGMgr.h:113
Definition: LFGMgr.h:119
Definition: LFGMgr.h:122
std::set< uint32 > LfgDungeonSet
Definition: LFG.h:112
std::map< ObjectGuid, uint8 > LfgRolesMap
Definition: LFG.h:115
Definition: LFGMgr.h:124
std::string const & GetComment(ObjectGuid gguid)
Get current player comment (used for LFR)
Definition: LFGMgr.cpp:1571
void SetState(ObjectGuid guid, LfgState state)
Definition: LFGMgr.cpp:1682
void SendLfgRoleCheckUpdate(ObjectGuid guid, LfgRoleCheck const &roleCheck)
Definition: LFGMgr.cpp:1843
Definition: LFGMgr.h:97
Definition: LFGMgr.h:120
Definition: LFGMgr.h:125
Definition: LFG.h:38
LFGQueue & GetQueue(ObjectGuid guid)
Definition: LFGMgr.cpp:1897
void SendLfgUpdateStatus(ObjectGuid guid, LfgUpdateData const &data, bool party)
Definition: LFGMgr.cpp:1849
Definition: ObjectGuid.h:189
Definition: LFGMgr.h:123
bool IsEmpty() const
Definition: ObjectGuid.h:242
Definition: LFGMgr.h:121

+ Here is the call graph for this function:

Member Data Documentation

LfgPlayerBootContainer lfg::LFGMgr::BootsStore
private

Current player kicks.

LfgCachedDungeonContainer lfg::LFGMgr::CachedDungeonMapStore
private

Stores all dungeons by groupType.

LfgGroupDataContainer lfg::LFGMgr::GroupsStore
private

Group data.

LFGDungeonContainer lfg::LFGMgr::LfgDungeonStore
private
uint32 lfg::LFGMgr::m_lfgProposalId
private

used as internal counter for proposals

uint32 lfg::LFGMgr::m_options
private

Stores config options.

uint32 lfg::LFGMgr::m_QueueTimer
private

used to check interval of update

LfgPlayerDataContainer lfg::LFGMgr::PlayersStore
private

Player data.

LfgProposalContainer lfg::LFGMgr::ProposalsStore
private

Current Proposals.

LfgQueueContainer lfg::LFGMgr::QueuesStore
private

Queues.

LfgRewardContainer lfg::LFGMgr::RewardMapStore
private

Stores rewards for random dungeons.

LfgRoleCheckContainer lfg::LFGMgr::RoleChecksStore
private

Current Role checks.


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