void DungeonPersistentState::AddToBindList(ObjectGuid const& guid) { if (guid.IsPlayer()) m_playerList.insert(guid); else if (guid.IsGroup()) m_groupList.insert(guid); }
std::string LFGQueue::DumpQueueInfo() const { uint32 players = 0; uint32 groups = 0; uint32 playersInGroup = 0; for (uint8 i = 0; i < 2; ++i) { GuidList const& queue = i ? newToQueueStore : currentQueueStore; for (GuidList::const_iterator it = queue.begin(); it != queue.end(); ++it) { ObjectGuid guid = *it; if (guid.IsGroup()) { groups++; playersInGroup += sLFGMgr->GetPlayerCount(guid); } else players++; } } std::ostringstream o; o << "Queued Players: " << players << " (in group: " << playersInGroup << ") Groups: " << groups << "\n"; return o.str(); }
void DungeonPersistentState::RemoveFromBindList(ObjectGuid const& guid) { if (guid.IsPlayer()) m_playerList.erase(guid); else if (guid.IsGroup()) m_groupList.erase(guid); UnloadIfEmpty(); }
void LFGMgr::_JoinGroup(ObjectGuid guid, LFGType type) { if (guid.IsEmpty() || !guid.IsGroup()) return; LFGQueueInfo* pqInfo = new LFGQueueInfo(); // Joining process DEBUG_LOG("LFGMgr::AddToQueue: group %u joined", guid.GetCounter()); m_groupQueueInfoMap[type][guid] = pqInfo; }
LFGQueueSet LFGMgr::GetDungeonGroupQueue(LFGDungeonEntry const* dungeon, Team team) { LFGQueueSet tmpSet; tmpSet.clear(); LFGType type = LFG_TYPE_NONE; uint32 dungeonID = 0; uint8 searchEnd = LFG_TYPE_MAX; if (dungeon) { type = LFGType(dungeon->type); dungeonID = dungeon->ID; searchEnd = type+1; } for (uint8 i = type; i < searchEnd; ++i) { for (LFGQueueInfoMap::iterator itr = m_groupQueueInfoMap[i].begin(); itr != m_groupQueueInfoMap[i].end(); ++itr) { ObjectGuid guid = itr->first; if (!guid.IsGroup()) continue; Group* group = sObjectMgr.GetGroup(guid); if (!group) continue; Player* player = sObjectMgr.GetPlayer(group->GetLeaderGuid()); if (!player) continue; if (team && player->GetTeam() != team) continue; if (player->GetLFGState()->GetState() < LFG_STATE_LFR || player->GetLFGState()->GetState() > LFG_STATE_PROPOSAL) continue; if (player->GetLFGState()->GetDungeons()->find(dungeon) == player->GetLFGState()->GetDungeons()->end()) continue; tmpSet.insert(group->GetObjectGuid()); } } return tmpSet; }
void LFGMgr::Leave(Player* player) { if (!sWorld.getConfig(CONFIG_BOOL_LFG_ENABLE) && !sWorld.getConfig(CONFIG_BOOL_LFR_ENABLE)) return; ObjectGuid guid; Group* group = player->GetGroup(); if (group) { if (player->GetObjectGuid() != group->GetLeaderGuid()) return; else guid = group->GetObjectGuid(); } else guid = player->GetObjectGuid(); if (guid.IsEmpty()) return; LFGType type = player->GetLFGState()->GetType(); guid.IsGroup() ? _LeaveGroup(guid) : _Leave(guid); player->GetLFGState()->Clear(); if (group) { group->GetLFGState()->Clear(); player->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_REMOVED_FROM_QUEUE, type); } player->GetSession()->SendLfgUpdatePlayer(LFG_UPDATETYPE_REMOVED_FROM_QUEUE, type); if(sWorld.getConfig(CONFIG_BOOL_RESTRICTED_LFG_CHANNEL) && player->GetSession()->GetSecurity() == SEC_PLAYER ) player->LeaveLFGChannel(); }
void LFGMgr::Join(Player* player) { // LfgDungeonSet* dungeons = NULL; if (!sWorld.getConfig(CONFIG_BOOL_LFG_ENABLE) && !sWorld.getConfig(CONFIG_BOOL_LFR_ENABLE)) return; ObjectGuid guid; Group* group = player->GetGroup(); if (group) { if (player->GetObjectGuid() != group->GetLeaderGuid()) { player->GetSession()->SendLfgJoinResult(ERR_LFG_NO_SLOTS_PLAYER); return; } else guid = group->GetObjectGuid(); } else guid = player->GetObjectGuid(); if (guid.IsEmpty()) return; LFGType type = player->GetLFGState()->GetType(); if (type == LFG_TYPE_NONE) { DEBUG_LOG("LFGMgr::Join: %u trying to join without dungeon type. Aborting.", guid.GetCounter()); player->GetSession()->SendLfgJoinResult(ERR_LFG_INVALID_SLOT); return; } else if (group && type == LFG_TYPE_RAID && !group->isRaidGroup()) { DEBUG_LOG("LFGMgr::Join: %u trying to join to raid finder, but group is not raid. Aborting.", guid.GetCounter()); player->GetSession()->SendLfgJoinResult(ERR_LFG_MISMATCHED_SLOTS); return; } else if (group && type != LFG_TYPE_RAID && group->isRaidGroup()) { DEBUG_LOG("LFGMgr::Join: %u trying to join to dungeon finder, but group is raid. Aborting.", guid.GetCounter()); player->GetSession()->SendLfgJoinResult(ERR_LFG_MISMATCHED_SLOTS); return; } LFGQueueInfoMap::iterator queue = (guid.IsGroup() ? m_groupQueueInfoMap[type].find(guid) : m_queueInfoMap[type].find(guid)); LFGJoinResult result = ERR_LFG_OK; if (queue != (guid.IsGroup() ? m_groupQueueInfoMap[type].end() : m_queueInfoMap[type].end())) { DEBUG_LOG("LFGMgr::Join: %u trying to join but is already in queue!", guid.GetCounter()); result = ERR_LFG_NO_LFG_OBJECT; player->GetSession()->SendLfgJoinResult(result); _Leave(guid); _LeaveGroup(guid); return; } result = guid.IsGroup() ? GetGroupJoinResult(group) : GetPlayerJoinResult(player); if (result != ERR_LFG_OK) // Someone can't join. Clear all stuf { DEBUG_LOG("LFGMgr::Join: %u joining with %u members. result: %u", guid.GetCounter(), group ? group->GetMembersCount() : 1, result); player->GetLFGState()->Clear(); player->GetSession()->SendLfgJoinResult(result); player->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_ROLECHECK_FAILED, type); return; } if (!guid.IsGroup() && player->GetLFGState()->GetRoles() == LFG_ROLE_MASK_NONE) { sLog.outError("LFGMgr::Join: %u has no roles", guid.GetCounter()); } // Joining process if (guid.IsGroup()) { for (GroupReference *itr = group->GetFirstMember(); itr != NULL; itr = itr->next()) { if (Player* player = itr->getSource()) _Leave(player->GetObjectGuid()); } _LeaveGroup(guid, type); _JoinGroup(guid, type); } else { _Leave(guid, type); _Join(guid, type); } player->GetLFGState()->SetState((type == LFG_TYPE_RAID) ? LFG_STATE_LFR : LFG_STATE_LFG); player->GetSession()->SendLfgJoinResult(ERR_LFG_OK, 0); if (group) player->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_JOIN_PROPOSAL, type); else player->GetSession()->SendLfgUpdatePlayer(LFG_UPDATETYPE_JOIN_PROPOSAL, type); if(sWorld.getConfig(CONFIG_BOOL_RESTRICTED_LFG_CHANNEL)) player->JoinLFGChannel(); }