Core/Dungeon Finder: Some optimizations
- Reduce core dependencies with LFGMgr - Remove reduntant calculations in RoleCheck code - Remove no longer needed functions - Fix some packet data (Missing 0 when arrays were null) - Add some debug msgs closes issue 5042 --HG-- branch : trunk
This commit is contained in:
@@ -57,7 +57,6 @@
|
|||||||
#include "Transport.h"
|
#include "Transport.h"
|
||||||
#include "WeatherMgr.h"
|
#include "WeatherMgr.h"
|
||||||
#include "ScriptMgr.h"
|
#include "ScriptMgr.h"
|
||||||
#include "LFGMgr.h"
|
|
||||||
#include "CreatureTextMgr.h"
|
#include "CreatureTextMgr.h"
|
||||||
#include "SmartAI.h"
|
#include "SmartAI.h"
|
||||||
#include "Group.h"
|
#include "Group.h"
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include "SharedDefines.h"
|
#include "SharedDefines.h"
|
||||||
|
#include "DBCStores.h"
|
||||||
|
|
||||||
#include "DisableMgr.h"
|
#include "DisableMgr.h"
|
||||||
#include "ObjectMgr.h"
|
#include "ObjectMgr.h"
|
||||||
@@ -32,47 +33,41 @@ LFGMgr::LFGMgr(): m_update(true), m_QueueTimer(0), m_lfgProposalId(1),
|
|||||||
m_WaitTimeAvg(-1), m_WaitTimeTank(-1), m_WaitTimeHealer(-1), m_WaitTimeDps(-1),
|
m_WaitTimeAvg(-1), m_WaitTimeTank(-1), m_WaitTimeHealer(-1), m_WaitTimeDps(-1),
|
||||||
m_NumWaitTimeAvg(0), m_NumWaitTimeTank(0), m_NumWaitTimeHealer(0), m_NumWaitTimeDps(0)
|
m_NumWaitTimeAvg(0), m_NumWaitTimeTank(0), m_NumWaitTimeHealer(0), m_NumWaitTimeDps(0)
|
||||||
{
|
{
|
||||||
if (sWorld.getBoolConfig(CONFIG_DUNGEON_FINDER_ENABLE))
|
m_update = sWorld.getBoolConfig(CONFIG_DUNGEON_FINDER_ENABLE);
|
||||||
|
if (m_update)
|
||||||
{
|
{
|
||||||
new LFGScripts();
|
new LFGScripts();
|
||||||
GetAllDungeons();
|
|
||||||
m_update = true;
|
// Initialize dungeon cache
|
||||||
|
for (uint32 i = 0; i < sLFGDungeonStore.GetNumRows(); ++i)
|
||||||
|
{
|
||||||
|
LFGDungeonEntry const* dungeon = sLFGDungeonStore.LookupEntry(i);
|
||||||
|
if (dungeon && dungeon->type != LFG_TYPE_ZONE)
|
||||||
|
{
|
||||||
|
if (dungeon->type != LFG_TYPE_RANDOM)
|
||||||
|
m_CachedDungeonMap[dungeon->grouptype].insert(dungeon->ID);
|
||||||
|
m_CachedDungeonMap[0].insert(dungeon->ID);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
m_update = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LFGMgr::~LFGMgr()
|
LFGMgr::~LFGMgr()
|
||||||
{
|
{
|
||||||
for (LfgRewardMap::iterator itr = m_RewardMap.begin(); itr != m_RewardMap.end(); ++itr)
|
for (LfgRewardMap::iterator itr = m_RewardMap.begin(); itr != m_RewardMap.end(); ++itr)
|
||||||
delete itr->second;
|
delete itr->second;
|
||||||
m_RewardMap.clear();
|
|
||||||
|
|
||||||
m_EncountersByAchievement.clear();
|
|
||||||
|
|
||||||
for (LfgQueueInfoMap::iterator it = m_QueueInfoMap.begin(); it != m_QueueInfoMap.end(); ++it)
|
for (LfgQueueInfoMap::iterator it = m_QueueInfoMap.begin(); it != m_QueueInfoMap.end(); ++it)
|
||||||
delete it->second;
|
delete it->second;
|
||||||
m_QueueInfoMap.clear();
|
|
||||||
|
|
||||||
for (LfgProposalMap::iterator it = m_Proposals.begin(); it != m_Proposals.end(); ++it)
|
for (LfgProposalMap::iterator it = m_Proposals.begin(); it != m_Proposals.end(); ++it)
|
||||||
delete it->second;
|
delete it->second;
|
||||||
m_Proposals.clear();
|
|
||||||
|
|
||||||
for (LfgPlayerBootMap::iterator it = m_Boots.begin(); it != m_Boots.end(); ++it)
|
for (LfgPlayerBootMap::iterator it = m_Boots.begin(); it != m_Boots.end(); ++it)
|
||||||
delete it->second;
|
delete it->second;
|
||||||
m_Boots.clear();
|
|
||||||
|
|
||||||
for (LfgRoleCheckMap::iterator it = m_RoleChecks.begin(); it != m_RoleChecks.end(); ++it)
|
for (LfgRoleCheckMap::iterator it = m_RoleChecks.begin(); it != m_RoleChecks.end(); ++it)
|
||||||
delete it->second;
|
delete it->second;
|
||||||
m_RoleChecks.clear();
|
|
||||||
|
|
||||||
for (LfgDungeonMap::iterator it = m_CachedDungeonMap.begin(); it != m_CachedDungeonMap.end(); ++it)
|
|
||||||
delete it->second;
|
|
||||||
m_CachedDungeonMap.clear();
|
|
||||||
|
|
||||||
m_CompatibleMap.clear();
|
|
||||||
m_currentQueue.clear();
|
|
||||||
m_newToQueue.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Load achievement <-> encounter associations
|
/// Load achievement <-> encounter associations
|
||||||
@@ -418,9 +413,9 @@ bool LFGMgr::RemoveFromQueue(uint64& guid)
|
|||||||
@param[in] dungeons Dungeons the player/group is applying for
|
@param[in] dungeons Dungeons the player/group is applying for
|
||||||
@param[in] comment Player selected comment
|
@param[in] comment Player selected comment
|
||||||
*/
|
*/
|
||||||
void LFGMgr::Join(Player* plr, uint8 roles, LfgDungeonSet* dungeons, std::string comment)
|
void LFGMgr::Join(Player* plr, uint8 roles, LfgDungeonSet& dungeons, std::string& comment)
|
||||||
{
|
{
|
||||||
if (!plr || !plr->GetSession() || !dungeons || !dungeons->size())
|
if (!plr || !plr->GetSession() || !dungeons.size())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Group* grp = plr->GetGroup();
|
Group* grp = plr->GetGroup();
|
||||||
@@ -434,8 +429,8 @@ void LFGMgr::Join(Player* plr, uint8 roles, LfgDungeonSet* dungeons, std::string
|
|||||||
// Do not allow to change dungeon in the middle of a current dungeon
|
// Do not allow to change dungeon in the middle of a current dungeon
|
||||||
if (isContinue)
|
if (isContinue)
|
||||||
{
|
{
|
||||||
dungeons->clear();
|
dungeons.clear();
|
||||||
dungeons->insert(grp->GetLfgDungeonEntry());
|
dungeons.insert(grp->GetLfgDungeonEntry());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Already in queue?
|
// Already in queue?
|
||||||
@@ -444,7 +439,7 @@ void LFGMgr::Join(Player* plr, uint8 roles, LfgDungeonSet* dungeons, std::string
|
|||||||
{
|
{
|
||||||
bool sameDungeons = true;
|
bool sameDungeons = true;
|
||||||
for (LfgDungeonSet::const_iterator it = plr->GetLfgDungeons()->begin(); it != plr->GetLfgDungeons()->end() && sameDungeons; ++it)
|
for (LfgDungeonSet::const_iterator it = plr->GetLfgDungeons()->begin(); it != plr->GetLfgDungeons()->end() && sameDungeons; ++it)
|
||||||
if (dungeons->find(*it) == dungeons->end())
|
if (dungeons.find(*it) == dungeons.end())
|
||||||
sameDungeons = false;
|
sameDungeons = false;
|
||||||
|
|
||||||
if (sameDungeons) // Joining the same dungeons -- Send OK
|
if (sameDungeons) // Joining the same dungeons -- Send OK
|
||||||
@@ -454,7 +449,7 @@ void LFGMgr::Join(Player* plr, uint8 roles, LfgDungeonSet* dungeons, std::string
|
|||||||
{
|
{
|
||||||
for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
|
for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
|
||||||
if (itr->getSource() && itr->getSource()->GetSession())
|
if (itr->getSource() && itr->getSource()->GetSession())
|
||||||
itr->getSource()->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_ADDED_TO_QUEUE, dungeons, comment);
|
itr->getSource()->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_ADDED_TO_QUEUE, &dungeons, comment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!isContinue) // Different dungeons and it's not an offer to continue
|
else if (!isContinue) // Different dungeons and it's not an offer to continue
|
||||||
@@ -463,8 +458,6 @@ void LFGMgr::Join(Player* plr, uint8 roles, LfgDungeonSet* dungeons, std::string
|
|||||||
Leave(plr, grp);
|
Leave(plr, grp);
|
||||||
Join(plr, roles, dungeons, comment);
|
Join(plr, roles, dungeons, comment);
|
||||||
}
|
}
|
||||||
dungeons->clear();
|
|
||||||
delete dungeons;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -475,7 +468,7 @@ void LFGMgr::Join(Player* plr, uint8 roles, LfgDungeonSet* dungeons, std::string
|
|||||||
result = LFG_JOIN_DESERTER;
|
result = LFG_JOIN_DESERTER;
|
||||||
else if (plr->HasAura(LFG_SPELL_DUNGEON_COOLDOWN))
|
else if (plr->HasAura(LFG_SPELL_DUNGEON_COOLDOWN))
|
||||||
result = LFG_JOIN_RANDOM_COOLDOWN;
|
result = LFG_JOIN_RANDOM_COOLDOWN;
|
||||||
else if (!dungeons || !dungeons->size())
|
else if (!dungeons.size())
|
||||||
result = LFG_JOIN_NOT_MEET_REQS;
|
result = LFG_JOIN_NOT_MEET_REQS;
|
||||||
else if (grp)
|
else if (grp)
|
||||||
{
|
{
|
||||||
@@ -510,15 +503,15 @@ void LFGMgr::Join(Player* plr, uint8 roles, LfgDungeonSet* dungeons, std::string
|
|||||||
if (result == LFG_JOIN_OK)
|
if (result == LFG_JOIN_OK)
|
||||||
{
|
{
|
||||||
bool isDungeon = false;
|
bool isDungeon = false;
|
||||||
for (LfgDungeonSet::const_iterator it = dungeons->begin(); it != dungeons->end() && result == LFG_JOIN_OK; ++it)
|
for (LfgDungeonSet::const_iterator it = dungeons.begin(); it != dungeons.end() && result == LFG_JOIN_OK; ++it)
|
||||||
{
|
{
|
||||||
switch(GetDungeonType(*it))
|
switch(GetDungeonType(*it))
|
||||||
{
|
{
|
||||||
case LFG_TYPE_RANDOM:
|
case LFG_TYPE_RANDOM:
|
||||||
if (dungeons->size() > 1) // Only allow 1 random dungeon
|
if (dungeons.size() > 1) // Only allow 1 random dungeon
|
||||||
result = LFG_JOIN_DUNGEON_INVALID;
|
result = LFG_JOIN_DUNGEON_INVALID;
|
||||||
else
|
else
|
||||||
rDungeonId = (*dungeons->begin());
|
rDungeonId = (*dungeons.begin());
|
||||||
// No break on purpose (Random can only be dungeon or heroic dungeon)
|
// No break on purpose (Random can only be dungeon or heroic dungeon)
|
||||||
case LFG_TYPE_HEROIC:
|
case LFG_TYPE_HEROIC:
|
||||||
case LFG_TYPE_DUNGEON:
|
case LFG_TYPE_DUNGEON:
|
||||||
@@ -539,14 +532,24 @@ void LFGMgr::Join(Player* plr, uint8 roles, LfgDungeonSet* dungeons, std::string
|
|||||||
|
|
||||||
// Expand random dungeons and check restrictions
|
// Expand random dungeons and check restrictions
|
||||||
if (rDungeonId)
|
if (rDungeonId)
|
||||||
|
GetDungeonsByRandom(rDungeonId, dungeons);
|
||||||
|
|
||||||
|
LfgLockStatusMap* lockStatusMap = CheckCompatibleDungeons(dungeons, players);
|
||||||
|
if (!dungeons.size())
|
||||||
{
|
{
|
||||||
dungeons->clear();
|
sLog.outDebug("LFGMgr::Join: [" UI64FMTD "] joining with %u members. result: LFG_JOIN_PARTY_NOT_MEET_REQS", guid, uint8(players.size()));
|
||||||
delete dungeons;
|
plr->GetSession()->SendLfgJoinResult(LFG_JOIN_PARTY_NOT_MEET_REQS, 0, lockStatusMap);
|
||||||
dungeons = GetDungeonsByRandom(rDungeonId);
|
for (LfgLockStatusMap::const_iterator it = lockStatusMap->begin(); it != lockStatusMap->end(); ++it)
|
||||||
|
delete it->second;
|
||||||
|
delete lockStatusMap;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (lockStatusMap)
|
||||||
|
{
|
||||||
|
for (LfgLockStatusMap::const_iterator it = lockStatusMap->begin(); it != lockStatusMap->end(); ++it)
|
||||||
|
delete it->second;
|
||||||
|
delete lockStatusMap;
|
||||||
}
|
}
|
||||||
CheckCompatibleDungeons(dungeons, &players, false);
|
|
||||||
if (!dungeons || !dungeons->size())
|
|
||||||
result = LFG_JOIN_NOT_MEET_REQS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Can't join. Send result
|
// Can't join. Send result
|
||||||
@@ -554,10 +557,6 @@ void LFGMgr::Join(Player* plr, uint8 roles, LfgDungeonSet* dungeons, std::string
|
|||||||
{
|
{
|
||||||
sLog.outDebug("LFGMgr::Join: [" UI64FMTD "] joining with %u members. result: %u", guid, grp ? grp->GetMembersCount() : 1, result);
|
sLog.outDebug("LFGMgr::Join: [" UI64FMTD "] joining with %u members. result: %u", guid, grp ? grp->GetMembersCount() : 1, result);
|
||||||
plr->GetSession()->SendLfgJoinResult(result);
|
plr->GetSession()->SendLfgJoinResult(result);
|
||||||
if (dungeons)
|
|
||||||
dungeons->clear();
|
|
||||||
delete dungeons;
|
|
||||||
dungeons = NULL;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -565,9 +564,6 @@ void LFGMgr::Join(Player* plr, uint8 roles, LfgDungeonSet* dungeons, std::string
|
|||||||
if (isRaid)
|
if (isRaid)
|
||||||
{
|
{
|
||||||
sLog.outDebug("LFGMgr::Join: [" UI64FMTD "] trying to join raid browser and it's disabled.", guid);
|
sLog.outDebug("LFGMgr::Join: [" UI64FMTD "] trying to join raid browser and it's disabled.", guid);
|
||||||
dungeons->clear();
|
|
||||||
delete dungeons;
|
|
||||||
dungeons = NULL;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -581,28 +577,27 @@ void LFGMgr::Join(Player* plr, uint8 roles, LfgDungeonSet* dungeons, std::string
|
|||||||
pRoleCheck->cancelTime = time_t(time(NULL)) + LFG_TIME_ROLECHECK;
|
pRoleCheck->cancelTime = time_t(time(NULL)) + LFG_TIME_ROLECHECK;
|
||||||
pRoleCheck->result = LFG_ROLECHECK_INITIALITING;
|
pRoleCheck->result = LFG_ROLECHECK_INITIALITING;
|
||||||
pRoleCheck->leader = plr->GetGUIDLow();
|
pRoleCheck->leader = plr->GetGUIDLow();
|
||||||
|
pRoleCheck->dungeons = dungeons;
|
||||||
|
pRoleCheck->rDungeonId = rDungeonId;
|
||||||
m_RoleChecks[grp->GetLowGUID()] = pRoleCheck;
|
m_RoleChecks[grp->GetLowGUID()] = pRoleCheck;
|
||||||
|
|
||||||
if (rDungeonId)
|
if (rDungeonId)
|
||||||
{
|
{
|
||||||
dungeons->clear();
|
dungeons.clear();
|
||||||
dungeons->insert(rDungeonId);
|
dungeons.insert(rDungeonId);
|
||||||
}
|
}
|
||||||
// Assign dungeons
|
|
||||||
for (LfgDungeonSet::const_iterator it = dungeons->begin(); it != dungeons->end(); ++it)
|
|
||||||
pRoleCheck->dungeons.insert(*it);
|
|
||||||
|
|
||||||
// Send update to player
|
// Send update to player
|
||||||
for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
|
for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
|
||||||
{
|
{
|
||||||
if (Player* plrg = itr->getSource())
|
if (Player* plrg = itr->getSource())
|
||||||
{
|
{
|
||||||
plrg->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_JOIN_PROPOSAL, dungeons, comment);
|
plrg->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_JOIN_PROPOSAL, &dungeons, comment);
|
||||||
plrg->SetLfgState(LFG_STATE_ROLECHECK);
|
plrg->SetLfgState(LFG_STATE_ROLECHECK);
|
||||||
if (!isContinue)
|
if (!isContinue)
|
||||||
{
|
{
|
||||||
plrg->GetLfgDungeons()->clear();
|
plrg->GetLfgDungeons()->clear();
|
||||||
for (LfgDungeonSet::const_iterator it = dungeons->begin(); it != dungeons->end(); ++it)
|
for (LfgDungeonSet::const_iterator it = dungeons.begin(); it != dungeons.end(); ++it)
|
||||||
plrg->GetLfgDungeons()->insert(*it);
|
plrg->GetLfgDungeons()->insert(*it);
|
||||||
}
|
}
|
||||||
pRoleCheck->roles[plrg->GetGUIDLow()] = 0;
|
pRoleCheck->roles[plrg->GetGUIDLow()] = 0;
|
||||||
@@ -615,7 +610,7 @@ void LFGMgr::Join(Player* plr, uint8 roles, LfgDungeonSet* dungeons, std::string
|
|||||||
{
|
{
|
||||||
// Send update to player
|
// Send update to player
|
||||||
plr->GetSession()->SendLfgJoinResult(LFG_JOIN_OK);
|
plr->GetSession()->SendLfgJoinResult(LFG_JOIN_OK);
|
||||||
plr->GetSession()->SendLfgUpdatePlayer(LFG_UPDATETYPE_JOIN_PROPOSAL, dungeons, comment);
|
plr->GetSession()->SendLfgUpdatePlayer(LFG_UPDATETYPE_JOIN_PROPOSAL, &dungeons, comment);
|
||||||
plr->SetLfgState(LFG_STATE_QUEUED);
|
plr->SetLfgState(LFG_STATE_QUEUED);
|
||||||
if (!isContinue)
|
if (!isContinue)
|
||||||
{
|
{
|
||||||
@@ -623,7 +618,7 @@ void LFGMgr::Join(Player* plr, uint8 roles, LfgDungeonSet* dungeons, std::string
|
|||||||
if (rDungeonId)
|
if (rDungeonId)
|
||||||
plr->GetLfgDungeons()->insert(rDungeonId);
|
plr->GetLfgDungeons()->insert(rDungeonId);
|
||||||
else
|
else
|
||||||
for (LfgDungeonSet::const_iterator it = dungeons->begin(); it != dungeons->end(); ++it)
|
for (LfgDungeonSet::const_iterator it = dungeons.begin(); it != dungeons.end(); ++it)
|
||||||
plr->GetLfgDungeons()->insert(*it);
|
plr->GetLfgDungeons()->insert(*it);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -631,6 +626,7 @@ void LFGMgr::Join(Player* plr, uint8 roles, LfgDungeonSet* dungeons, std::string
|
|||||||
LfgQueueInfo* pqInfo = new LfgQueueInfo();
|
LfgQueueInfo* pqInfo = new LfgQueueInfo();
|
||||||
pqInfo->joinTime = time_t(time(NULL));
|
pqInfo->joinTime = time_t(time(NULL));
|
||||||
pqInfo->roles[plr->GetGUIDLow()] = plr->GetLfgRoles();
|
pqInfo->roles[plr->GetGUIDLow()] = plr->GetLfgRoles();
|
||||||
|
pqInfo->dungeons = dungeons;
|
||||||
uint8 roles = plr->GetLfgRoles();
|
uint8 roles = plr->GetLfgRoles();
|
||||||
if (roles & ROLE_TANK)
|
if (roles & ROLE_TANK)
|
||||||
--pqInfo->tanks;
|
--pqInfo->tanks;
|
||||||
@@ -638,16 +634,11 @@ void LFGMgr::Join(Player* plr, uint8 roles, LfgDungeonSet* dungeons, std::string
|
|||||||
--pqInfo->healers;
|
--pqInfo->healers;
|
||||||
else
|
else
|
||||||
--pqInfo->dps;
|
--pqInfo->dps;
|
||||||
for (LfgDungeonSet::const_iterator it = dungeons->begin(); it != dungeons->end(); ++it)
|
|
||||||
pqInfo->dungeons.insert(*it);
|
|
||||||
m_QueueInfoMap[guid] = pqInfo;
|
m_QueueInfoMap[guid] = pqInfo;
|
||||||
AddToQueue(guid, uint8(plr->GetTeam()));
|
AddToQueue(guid, uint8(plr->GetTeam()));
|
||||||
}
|
}
|
||||||
std::string dungeonsstr = ConcatenateDungeons(dungeons);
|
sLog.outDebug("LFGMgr::Join: [" UI64FMTD "] joined with %u members. dungeons: %u", guid, grp ? grp->GetMembersCount() : 1, uint8(dungeons.size()));
|
||||||
sLog.outDebug("LFGMgr::Join: [" UI64FMTD "] joined with %u members. dungeons: %s", guid, grp ? grp->GetMembersCount() : 1, dungeonsstr.c_str());
|
|
||||||
dungeons->clear();
|
|
||||||
delete dungeons;
|
|
||||||
dungeons = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -850,7 +841,6 @@ bool LFGMgr::CheckCompatibility(LfgGuidList check, LfgProposal*& pProposal)
|
|||||||
// Do not match - groups already in a lfgDungeon or too much players
|
// Do not match - groups already in a lfgDungeon or too much players
|
||||||
if (numLfgGroups > 1 || numPlayers > MAXGROUPSIZE)
|
if (numLfgGroups > 1 || numPlayers > MAXGROUPSIZE)
|
||||||
{
|
{
|
||||||
pqInfoMap.clear();
|
|
||||||
SetCompatibles(strGuids, false);
|
SetCompatibles(strGuids, false);
|
||||||
if (numLfgGroups > 1)
|
if (numLfgGroups > 1)
|
||||||
sLog.outDebug("LFGMgr::CheckCompatibility: (%s) More than one Lfggroup (%u)", strGuids.c_str(), numLfgGroups);
|
sLog.outDebug("LFGMgr::CheckCompatibility: (%s) More than one Lfggroup (%u)", strGuids.c_str(), numLfgGroups);
|
||||||
@@ -874,12 +864,8 @@ bool LFGMgr::CheckCompatibility(LfgGuidList check, LfgProposal*& pProposal)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rolesMap.size() != numPlayers)
|
if (rolesMap.size() != numPlayers) // Player in multiples queues!
|
||||||
{
|
|
||||||
pqInfoMap.clear();
|
|
||||||
rolesMap.clear();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
PlayerSet players;
|
PlayerSet players;
|
||||||
for (LfgRolesMap::const_iterator it = rolesMap.begin(); it != rolesMap.end(); ++it)
|
for (LfgRolesMap::const_iterator it = rolesMap.begin(); it != rolesMap.end(); ++it)
|
||||||
@@ -909,27 +895,29 @@ bool LFGMgr::CheckCompatibility(LfgGuidList check, LfgProposal*& pProposal)
|
|||||||
{
|
{
|
||||||
if (players.size() == numPlayers)
|
if (players.size() == numPlayers)
|
||||||
sLog.outDebug("LFGMgr::CheckCompatibility: (%s) Roles not compatible", strGuids.c_str());
|
sLog.outDebug("LFGMgr::CheckCompatibility: (%s) Roles not compatible", strGuids.c_str());
|
||||||
pqInfoMap.clear();
|
|
||||||
rolesMap.clear();
|
|
||||||
players.clear();
|
|
||||||
SetCompatibles(strGuids, false);
|
SetCompatibles(strGuids, false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----- Selected Dungeon checks -----
|
// ----- Selected Dungeon checks -----
|
||||||
// Check if there are any compatible dungeon from the selected dungeons
|
// Check if there are any compatible dungeon from the selected dungeons
|
||||||
LfgDungeonMap dungeonMap;
|
LfgDungeonSet compatibleDungeons;
|
||||||
for (LfgQueueInfoMap::const_iterator it = pqInfoMap.begin(); it != pqInfoMap.end(); ++it)
|
|
||||||
dungeonMap[it->first] = &it->second->dungeons;
|
|
||||||
|
|
||||||
LfgDungeonSet* compatibleDungeons = CheckCompatibleDungeons(&dungeonMap, &players);
|
LfgQueueInfoMap::const_iterator itFirst = pqInfoMap.begin();
|
||||||
dungeonMap.clear();
|
for (LfgDungeonSet::const_iterator itDungeon = itFirst->second->dungeons.begin(); itDungeon != itFirst->second->dungeons.end(); ++itDungeon)
|
||||||
pqInfoMap.clear();
|
{
|
||||||
if (!compatibleDungeons || !compatibleDungeons->size())
|
LfgQueueInfoMap::const_iterator itOther = itFirst;
|
||||||
|
++itOther;
|
||||||
|
while(itOther != pqInfoMap.end() && itOther->second->dungeons.find(*itDungeon) != itOther->second->dungeons.end())
|
||||||
|
++itOther;
|
||||||
|
|
||||||
|
if (itOther == pqInfoMap.end())
|
||||||
|
compatibleDungeons.insert(*itDungeon);
|
||||||
|
}
|
||||||
|
CheckCompatibleDungeons(compatibleDungeons, players, false);
|
||||||
|
|
||||||
|
if (!compatibleDungeons.size())
|
||||||
{
|
{
|
||||||
delete compatibleDungeons;
|
|
||||||
players.clear();
|
|
||||||
rolesMap.clear();
|
|
||||||
SetCompatibles(strGuids, false);
|
SetCompatibles(strGuids, false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -938,8 +926,6 @@ bool LFGMgr::CheckCompatibility(LfgGuidList check, LfgProposal*& pProposal)
|
|||||||
// ----- Group is compatible, if we have MAXGROUPSIZE members then match is found
|
// ----- Group is compatible, if we have MAXGROUPSIZE members then match is found
|
||||||
if (numPlayers != MAXGROUPSIZE)
|
if (numPlayers != MAXGROUPSIZE)
|
||||||
{
|
{
|
||||||
players.clear();
|
|
||||||
rolesMap.clear();
|
|
||||||
sLog.outDebug("LFGMgr::CheckCompatibility: (%s) Compatibles but not match. Players(%u)", strGuids.c_str(), numPlayers);
|
sLog.outDebug("LFGMgr::CheckCompatibility: (%s) Compatibles but not match. Players(%u)", strGuids.c_str(), numPlayers);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -951,20 +937,14 @@ bool LFGMgr::CheckCompatibility(LfgGuidList check, LfgProposal*& pProposal)
|
|||||||
|
|
||||||
// Select a random dungeon from the compatible list
|
// Select a random dungeon from the compatible list
|
||||||
// TODO - Select the dungeon based on group item Level, not just random
|
// TODO - Select the dungeon based on group item Level, not just random
|
||||||
LfgDungeonSet::iterator itDungeon = compatibleDungeons->begin();
|
LfgDungeonSet::const_iterator itDungeon = compatibleDungeons.begin();
|
||||||
uint32 selectedDungeon = urand(0, compatibleDungeons->size() - 1);
|
for (uint8 i = 0; i < urand(0, compatibleDungeons.size() - 1); ++i)
|
||||||
while (selectedDungeon > 0)
|
|
||||||
{
|
|
||||||
++itDungeon;
|
++itDungeon;
|
||||||
--selectedDungeon;
|
|
||||||
}
|
|
||||||
selectedDungeon = (*itDungeon);
|
|
||||||
compatibleDungeons->clear();
|
|
||||||
delete compatibleDungeons;
|
|
||||||
|
|
||||||
// Create a new proposal
|
// Create a new proposal
|
||||||
pProposal = new LfgProposal(selectedDungeon);
|
pProposal = new LfgProposal(*itDungeon);
|
||||||
pProposal->cancelTime = time_t(time(NULL)) + LFG_TIME_PROPOSAL;
|
pProposal->cancelTime = time_t(time(NULL)) + LFG_TIME_PROPOSAL;
|
||||||
|
pProposal->state = LFG_PROPOSAL_INITIATING;
|
||||||
pProposal->queues = check;
|
pProposal->queues = check;
|
||||||
pProposal->groupLowGuid = groupLowGuid;
|
pProposal->groupLowGuid = groupLowGuid;
|
||||||
|
|
||||||
@@ -987,7 +967,7 @@ bool LFGMgr::CheckCompatibility(LfgGuidList check, LfgProposal*& pProposal)
|
|||||||
if (Group* grp = (*itPlayers)->GetGroup())
|
if (Group* grp = (*itPlayers)->GetGroup())
|
||||||
{
|
{
|
||||||
ppPlayer->groupLowGuid = grp->GetLowGUID();
|
ppPlayer->groupLowGuid = grp->GetLowGUID();
|
||||||
if (groupLowGuid && groupLowGuid == ppPlayer->groupLowGuid) // Player from existing group, autoaccept
|
if (grp->isLFGGroup()) // Player from existing group, autoaccept
|
||||||
{
|
{
|
||||||
ppPlayer->accept = LFG_ANSWER_AGREE;
|
ppPlayer->accept = LFG_ANSWER_AGREE;
|
||||||
++numAccept;
|
++numAccept;
|
||||||
@@ -999,8 +979,6 @@ bool LFGMgr::CheckCompatibility(LfgGuidList check, LfgProposal*& pProposal)
|
|||||||
if (numAccept == MAXGROUPSIZE)
|
if (numAccept == MAXGROUPSIZE)
|
||||||
pProposal->state = LFG_PROPOSAL_SUCCESS;
|
pProposal->state = LFG_PROPOSAL_SUCCESS;
|
||||||
|
|
||||||
rolesMap.clear();
|
|
||||||
players.clear();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1022,76 +1000,34 @@ void LFGMgr::UpdateRoleCheck(Group* grp, Player* plr /* = NULL*/, bool newRoleCh
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
LfgRoleCheck* pRoleCheck = itRoleCheck->second;
|
LfgRoleCheck* pRoleCheck = itRoleCheck->second;
|
||||||
LfgLockStatusMap* playersLockMap = NULL;
|
if (!plr)
|
||||||
if (plr)
|
pRoleCheck->result = LFG_ROLECHECK_ABORTED;
|
||||||
{
|
else if (plr->GetLfgRoles() < ROLE_TANK) // Player selected no role.
|
||||||
// Player selected no role.
|
|
||||||
if (plr->GetLfgRoles() < ROLE_TANK)
|
|
||||||
pRoleCheck->result = LFG_ROLECHECK_NO_ROLE;
|
pRoleCheck->result = LFG_ROLECHECK_NO_ROLE;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Check if all players have selected a role
|
|
||||||
pRoleCheck->roles[plr->GetGUIDLow()] = plr->GetLfgRoles();
|
pRoleCheck->roles[plr->GetGUIDLow()] = plr->GetLfgRoles();
|
||||||
uint8 size = 0;
|
|
||||||
for (LfgRolesMap::const_iterator itRoles = pRoleCheck->roles.begin(); itRoles != pRoleCheck->roles.end() && itRoles->second != ROLE_NONE; ++itRoles)
|
|
||||||
++size;
|
|
||||||
|
|
||||||
if (pRoleCheck->roles.size() == size)
|
// Check if all players have selected a role
|
||||||
|
LfgRolesMap::const_iterator itRoles = pRoleCheck->roles.begin();
|
||||||
|
while (itRoles != pRoleCheck->roles.end() && itRoles->second != ROLE_NONE)
|
||||||
|
++itRoles;
|
||||||
|
|
||||||
|
if (itRoles == pRoleCheck->roles.end())
|
||||||
{
|
{
|
||||||
// use temporal var to check roles, CheckGroupRoles modifies the roles
|
// use temporal var to check roles, CheckGroupRoles modifies the roles
|
||||||
check_roles = pRoleCheck->roles;
|
check_roles = pRoleCheck->roles;
|
||||||
if (!CheckGroupRoles(check_roles)) // Group is not posible
|
pRoleCheck->result = CheckGroupRoles(check_roles) ? LFG_ROLECHECK_FINISHED : LFG_ROLECHECK_WRONG_ROLES;
|
||||||
pRoleCheck->result = LFG_ROLECHECK_WRONG_ROLES;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Check if we can find a dungeon for that group
|
|
||||||
pRoleCheck->result = LFG_ROLECHECK_FINISHED;
|
|
||||||
if (pRoleCheck->dungeons.size() == 1 && isRandomDungeon(*pRoleCheck->dungeons.begin()))
|
|
||||||
{
|
|
||||||
// Random dungeon - select the compatible dungeons
|
|
||||||
LfgDungeonSet* dungeons = GetDungeonsByRandom(*pRoleCheck->dungeons.begin());
|
|
||||||
PlayerSet players;
|
|
||||||
for (LfgRolesMap::const_iterator it = pRoleCheck->roles.begin(); it != pRoleCheck->roles.end(); ++it)
|
|
||||||
if (Player* plr = sObjectMgr.GetPlayerByLowGUID(it->first))
|
|
||||||
players.insert(plr);
|
|
||||||
|
|
||||||
playersLockMap = CheckCompatibleDungeons(dungeons, &players);
|
|
||||||
std::string dungeonstr = ConcatenateDungeons(dungeons);
|
|
||||||
sLog.outDebug("LFGMgr::UpdateRoleCheck: [" UI64FMTD "] done. Dungeons: %s", plr->GetGUID(), dungeonstr.c_str());
|
|
||||||
|
|
||||||
pRoleCheck->dungeons.clear();
|
|
||||||
if (dungeons)
|
|
||||||
{
|
|
||||||
if (dungeons->empty())
|
|
||||||
delete dungeons;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (LfgDungeonSet::const_iterator it = dungeons->begin(); it != dungeons->end(); ++it)
|
|
||||||
pRoleCheck->dungeons.insert(*it);
|
|
||||||
if (playersLockMap)
|
|
||||||
{
|
|
||||||
for (LfgLockStatusMap::iterator itMap = playersLockMap->begin(); itMap != playersLockMap->end(); ++itMap)
|
|
||||||
{
|
|
||||||
itMap->second->clear();
|
|
||||||
delete itMap->second;
|
|
||||||
}
|
|
||||||
playersLockMap->clear();
|
|
||||||
delete playersLockMap;
|
|
||||||
playersLockMap = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
playersLockMap = GetPartyLockStatusDungeons(plr, &pRoleCheck->dungeons);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
pRoleCheck->result = LFG_ROLECHECK_ABORTED;
|
|
||||||
|
|
||||||
uint8 team = 0;
|
uint8 team = 0;
|
||||||
|
LfgDungeonSet dungeons;
|
||||||
|
if (pRoleCheck->rDungeonId)
|
||||||
|
dungeons.insert(pRoleCheck->rDungeonId);
|
||||||
|
else
|
||||||
|
dungeons = pRoleCheck->dungeons;
|
||||||
|
|
||||||
for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
|
for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
|
||||||
{
|
{
|
||||||
Player* plrg = itr->getSource();
|
Player* plrg = itr->getSource();
|
||||||
@@ -1109,18 +1045,8 @@ void LFGMgr::UpdateRoleCheck(Group* grp, Player* plr /* = NULL*/, bool newRoleCh
|
|||||||
case LFG_ROLECHECK_INITIALITING:
|
case LFG_ROLECHECK_INITIALITING:
|
||||||
continue;
|
continue;
|
||||||
case LFG_ROLECHECK_FINISHED:
|
case LFG_ROLECHECK_FINISHED:
|
||||||
if (!playersLockMap)
|
|
||||||
{
|
|
||||||
plrg->SetLfgState(LFG_STATE_QUEUED);
|
plrg->SetLfgState(LFG_STATE_QUEUED);
|
||||||
session->SendLfgUpdateParty(LFG_UPDATETYPE_ADDED_TO_QUEUE, &pRoleCheck->dungeons, plrg->GetLfgComment());
|
session->SendLfgUpdateParty(LFG_UPDATETYPE_ADDED_TO_QUEUE, &dungeons, plrg->GetLfgComment());
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (grp->GetLeaderGUID() == plrg->GetGUID())
|
|
||||||
session->SendLfgJoinResult(LFG_JOIN_PARTY_NOT_MEET_REQS, 0, playersLockMap);
|
|
||||||
session->SendLfgUpdateParty(LFG_UPDATETYPE_ROLECHECK_FAILED);
|
|
||||||
plrg->ClearLfgState();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (grp->GetLeaderGUID() == plrg->GetGUID())
|
if (grp->GetLeaderGUID() == plrg->GetGUID())
|
||||||
@@ -1158,24 +1084,11 @@ void LFGMgr::UpdateRoleCheck(Group* grp, Player* plr /* = NULL*/, bool newRoleCh
|
|||||||
|
|
||||||
if (pRoleCheck->result != LFG_ROLECHECK_INITIALITING)
|
if (pRoleCheck->result != LFG_ROLECHECK_INITIALITING)
|
||||||
{
|
{
|
||||||
pRoleCheck->dungeons.clear();
|
|
||||||
pRoleCheck->roles.clear();
|
|
||||||
delete pRoleCheck;
|
delete pRoleCheck;
|
||||||
m_RoleChecks.erase(itRoleCheck);
|
m_RoleChecks.erase(itRoleCheck);
|
||||||
if (pRoleCheck->result != LFG_ROLECHECK_FINISHED)
|
if (pRoleCheck->result != LFG_ROLECHECK_FINISHED)
|
||||||
grp->RestoreLfgState();
|
grp->RestoreLfgState();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playersLockMap)
|
|
||||||
{
|
|
||||||
for (LfgLockStatusMap::iterator itMap = playersLockMap->begin(); itMap != playersLockMap->end(); ++itMap)
|
|
||||||
{
|
|
||||||
itMap->second->clear();
|
|
||||||
delete itMap->second;
|
|
||||||
}
|
|
||||||
playersLockMap->clear();
|
|
||||||
delete playersLockMap;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1233,31 +1146,27 @@ LfgAnswer LFGMgr::GetCompatibles(std::string key)
|
|||||||
@param[in] returnLockMap Determines when to return a function value (Default true)
|
@param[in] returnLockMap Determines when to return a function value (Default true)
|
||||||
@return Map of players Lock status info of given dungeons
|
@return Map of players Lock status info of given dungeons
|
||||||
*/
|
*/
|
||||||
LfgLockStatusMap* LFGMgr::CheckCompatibleDungeons(LfgDungeonSet* dungeons, PlayerSet* players, bool returnLockMap /* = true */)
|
LfgLockStatusMap* LFGMgr::CheckCompatibleDungeons(LfgDungeonSet& dungeons, PlayerSet& players, bool returnLockMap /* = true */)
|
||||||
{
|
{
|
||||||
if (!dungeons)
|
if (!dungeons.size())
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
LfgLockStatusMap* pLockDungeons = GetGroupLockStatusDungeons(players, dungeons, false);
|
LfgLockStatusMap* pLockDungeons = GetGroupLockStatusDungeons(players, dungeons, false);
|
||||||
if (pLockDungeons) // Found dungeons not compatible, remove them from the set
|
if (pLockDungeons) // Found dungeons not compatible, remove them from the set
|
||||||
{
|
{
|
||||||
for (LfgLockStatusMap::const_iterator itLockMap = pLockDungeons->begin(); itLockMap != pLockDungeons->end() && dungeons->size(); ++itLockMap)
|
for (LfgLockStatusMap::const_iterator itLockMap = pLockDungeons->begin(); itLockMap != pLockDungeons->end() && dungeons.size(); ++itLockMap)
|
||||||
{
|
{
|
||||||
for(LfgLockStatusSet::const_iterator itLockSet = itLockMap->second->begin(); itLockSet != itLockMap->second->end(); ++itLockSet)
|
for(LfgLockStatusSet::const_iterator itLockSet = itLockMap->second->begin(); itLockSet != itLockMap->second->end(); ++itLockSet)
|
||||||
{
|
{
|
||||||
LfgDungeonSet::iterator itDungeon = dungeons->find((*itLockSet)->dungeon);
|
LfgDungeonSet::iterator itDungeon = dungeons.find((*itLockSet)->dungeon);
|
||||||
if (itDungeon != dungeons->end())
|
if (itDungeon != dungeons.end())
|
||||||
dungeons->erase(itDungeon);
|
dungeons.erase(itDungeon);
|
||||||
}
|
}
|
||||||
if (!returnLockMap)
|
if (!returnLockMap)
|
||||||
{
|
|
||||||
itLockMap->second->clear();
|
|
||||||
delete itLockMap->second;
|
delete itLockMap->second;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (!returnLockMap)
|
if (!returnLockMap)
|
||||||
{
|
{
|
||||||
pLockDungeons->clear();
|
|
||||||
delete pLockDungeons;
|
delete pLockDungeons;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -1265,47 +1174,6 @@ LfgLockStatusMap* LFGMgr::CheckCompatibleDungeons(LfgDungeonSet* dungeons, Playe
|
|||||||
return pLockDungeons;
|
return pLockDungeons;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
Given a list of groups checks the compatible dungeons. If players is not null also check restictions
|
|
||||||
|
|
||||||
@param[in] dungeonsMap Map of each player dungeons
|
|
||||||
@param[in] players Set of players to check their dungeon restrictions
|
|
||||||
@return Compatible dungeons of given players
|
|
||||||
*/
|
|
||||||
LfgDungeonSet* LFGMgr::CheckCompatibleDungeons(LfgDungeonMap* dungeonsMap, PlayerSet* players)
|
|
||||||
{
|
|
||||||
if (!dungeonsMap || dungeonsMap->empty())
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
LfgDungeonMap::const_iterator itMap = ++dungeonsMap->begin();
|
|
||||||
LfgDungeonSet* compatibleDungeons = new LfgDungeonSet();
|
|
||||||
|
|
||||||
bool compatibleDungeon;
|
|
||||||
|
|
||||||
// Get the first group and compare with the others to select all common dungeons
|
|
||||||
for (LfgDungeonSet::const_iterator itDungeon = dungeonsMap->begin()->second->begin(); itDungeon != dungeonsMap->begin()->second->end(); ++itDungeon)
|
|
||||||
{
|
|
||||||
compatibleDungeon = true;
|
|
||||||
for (LfgDungeonMap::const_iterator it = itMap; it != dungeonsMap->end() && compatibleDungeon; ++it)
|
|
||||||
if (it->second->find(*itDungeon) == it->second->end())
|
|
||||||
compatibleDungeon = false;
|
|
||||||
if (compatibleDungeon)
|
|
||||||
compatibleDungeons->insert(*itDungeon);
|
|
||||||
}
|
|
||||||
|
|
||||||
// if we have players remove restrictions
|
|
||||||
if (players && !players->empty())
|
|
||||||
CheckCompatibleDungeons(compatibleDungeons, players, false);
|
|
||||||
|
|
||||||
// Any compatible dungeon after checking restrictions?
|
|
||||||
if (compatibleDungeons && !compatibleDungeons->size())
|
|
||||||
{
|
|
||||||
delete compatibleDungeons;
|
|
||||||
compatibleDungeons = NULL;
|
|
||||||
}
|
|
||||||
return compatibleDungeons;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Check if a group can be formed with the given group roles
|
Check if a group can be formed with the given group roles
|
||||||
|
|
||||||
@@ -1532,15 +1400,9 @@ void LFGMgr::UpdateProposal(uint32 proposalId, uint32 lowGuid, bool accept)
|
|||||||
// Update group info
|
// Update group info
|
||||||
grp->SendUpdate();
|
grp->SendUpdate();
|
||||||
|
|
||||||
for (LfgProposalPlayerMap::const_iterator it = pProposal->players.begin(); it != pProposal->players.end(); ++it)
|
|
||||||
delete it->second;
|
|
||||||
pProposal->players.clear();
|
|
||||||
pProposal->queues.clear();
|
|
||||||
delete pProposal;
|
delete pProposal;
|
||||||
m_Proposals.erase(itProposal);
|
m_Proposals.erase(itProposal);
|
||||||
}
|
}
|
||||||
players.clear();
|
|
||||||
playersToTeleport.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1643,11 +1505,6 @@ void LFGMgr::RemoveProposal(LfgProposalMap::iterator itProposal, LfgUpdateType t
|
|||||||
AddToQueue(guid, team);
|
AddToQueue(guid, team);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete proposal
|
|
||||||
for (LfgProposalPlayerMap::const_iterator it = pProposal->players.begin(); it != pProposal->players.end(); ++it)
|
|
||||||
delete it->second;
|
|
||||||
pProposal->players.clear();
|
|
||||||
pProposal->queues.clear();
|
|
||||||
delete pProposal;
|
delete pProposal;
|
||||||
m_Proposals.erase(itProposal);
|
m_Proposals.erase(itProposal);
|
||||||
}
|
}
|
||||||
@@ -1883,11 +1740,20 @@ void LFGMgr::TeleportPlayer(Player* plr, bool out, bool fromOpcode /*= false*/)
|
|||||||
@param[in] dungeonId Dungeonid (Obsolete)
|
@param[in] dungeonId Dungeonid (Obsolete)
|
||||||
@param[in] plr Player to reward
|
@param[in] plr Player to reward
|
||||||
*/
|
*/
|
||||||
void LFGMgr::RewardDungeonDoneFor(const uint32 /*dungeonId*/, Player* player)
|
void LFGMgr::RewardDungeonDoneFor(const uint32 dungeonId, Player* player)
|
||||||
{
|
{
|
||||||
Group* group = player->GetGroup();
|
Group* group = player->GetGroup();
|
||||||
if (!group || !group->isLFGGroup())
|
if (!group || !group->isLFGGroup())
|
||||||
|
{
|
||||||
|
sLog.outDebug("LFGMgr::RewardDungeonDoneFor: [" UI64FMTD "] is not in a group or not a LFGGroup. Ignoring", player->GetGUID());
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (player->GetLfgState() == LFG_STATE_FINISHED_DUNGEON)
|
||||||
|
{
|
||||||
|
sLog.outDebug("LFGMgr::RewardDungeonDoneFor: [" UI64FMTD "] Already rewarded player. Ignoring", player->GetGUID());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Mark dungeon as finished
|
// Mark dungeon as finished
|
||||||
group->SetLfgState(LFG_STATE_FINISHED_DUNGEON);
|
group->SetLfgState(LFG_STATE_FINISHED_DUNGEON);
|
||||||
@@ -1900,7 +1766,10 @@ void LFGMgr::RewardDungeonDoneFor(const uint32 /*dungeonId*/, Player* player)
|
|||||||
// Give rewards only if its a random dungeon
|
// Give rewards only if its a random dungeon
|
||||||
LFGDungeonEntry const* dungeon = sLFGDungeonStore.LookupEntry(rDungeonId);
|
LFGDungeonEntry const* dungeon = sLFGDungeonStore.LookupEntry(rDungeonId);
|
||||||
if (!dungeon || dungeon->type != LFG_TYPE_RANDOM)
|
if (!dungeon || dungeon->type != LFG_TYPE_RANDOM)
|
||||||
|
{
|
||||||
|
sLog.outDebug("LFGMgr::RewardDungeonDoneFor: [" UI64FMTD "] dungeon %u is not random. Queued for %u dungeons", player->GetGUID(), rDungeonId, uint8(player->GetLfgDungeons()->size()));
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Update achievements
|
// Update achievements
|
||||||
if (dungeon->difficulty == DUNGEON_DIFFICULTY_HEROIC)
|
if (dungeon->difficulty == DUNGEON_DIFFICULTY_HEROIC)
|
||||||
@@ -1929,7 +1798,7 @@ void LFGMgr::RewardDungeonDoneFor(const uint32 /*dungeonId*/, Player* player)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Give rewards
|
// Give rewards
|
||||||
sLog.outDebug("LFGMgr::RewardDungeonDoneFor: [" UI64FMTD "] done dungeon %u, %s previously done.", player->GetGUID(), rDungeonId, index > 0 ? "" : "not ");
|
sLog.outDebug("LFGMgr::RewardDungeonDoneFor: [" UI64FMTD "] done dungeon %u,%s previously done.", player->GetGUID(), group->GetLfgDungeonEntry(), index > 0 ? " " : " not");
|
||||||
player->GetSession()->SendLfgPlayerReward(dungeon->Entry(), group->GetLfgDungeonEntry(false), index, reward, qReward);
|
player->GetSession()->SendLfgPlayerReward(dungeon->Entry(), group->GetLfgDungeonEntry(false), index, reward, qReward);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1937,27 +1806,59 @@ void LFGMgr::RewardDungeonDoneFor(const uint32 /*dungeonId*/, Player* player)
|
|||||||
// Auxiliar Functions
|
// Auxiliar Functions
|
||||||
// --------------------------------------------------------------------------//
|
// --------------------------------------------------------------------------//
|
||||||
|
|
||||||
|
/**
|
||||||
|
Get all Group members list of all dungeons that can't be done and reason
|
||||||
|
leader excluded as the list given is he list he can do
|
||||||
|
|
||||||
|
@param[in] plr Players to check group lock status
|
||||||
|
@returns Map of player's group dungeon Lock status
|
||||||
|
*/
|
||||||
|
LfgLockStatusMap* LFGMgr::GetPartyLockStatusDungeons(Player* plr)
|
||||||
|
{
|
||||||
|
Group* grp = plr->GetGroup();
|
||||||
|
if (!grp)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
PlayerSet players;
|
||||||
|
for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
|
||||||
|
{
|
||||||
|
Player* plrg = itr->getSource();
|
||||||
|
if (plrg && plrg != plr)
|
||||||
|
players.insert(plrg);
|
||||||
|
}
|
||||||
|
|
||||||
|
LfgDungeonSet allDungeons;
|
||||||
|
GetDungeonsByRandom(0, allDungeons);
|
||||||
|
return GetGroupLockStatusDungeons(players, allDungeons, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Get list of all dungeons player can't do and reasons
|
||||||
|
|
||||||
|
@param[in] plr Players to check dungeon lock status
|
||||||
|
@returns Set of player's dungeon Lock status
|
||||||
|
*/
|
||||||
|
LfgLockStatusSet* LFGMgr::GetPlayerLockStatusDungeons(Player* plr)
|
||||||
|
{
|
||||||
|
LfgDungeonSet allDungeons;
|
||||||
|
GetDungeonsByRandom(0, allDungeons);
|
||||||
|
return GetPlayerLockStatusDungeons(plr, allDungeons, true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Given a group get the dungeons that can't be done and reason
|
Given a group get the dungeons that can't be done and reason
|
||||||
|
|
||||||
@param[in] pPlayers Players to check lock status
|
@param[in] players Players to check lock status
|
||||||
@param[in] dungeons Dungeons to check
|
@param[in] dungeons Dungeons to check
|
||||||
@param[in] useEntry Use dungeon entry (true) or id (false)
|
@param[in] useEntry Use dungeon entry (true) or id (false)
|
||||||
@returns Map of player's dungeon Lock status
|
@returns Map of player's dungeon Lock status
|
||||||
*/
|
*/
|
||||||
LfgLockStatusMap* LFGMgr::GetGroupLockStatusDungeons(PlayerSet* pPlayers, LfgDungeonSet* dungeons, bool useEntry /* = true */)
|
LfgLockStatusMap* LFGMgr::GetGroupLockStatusDungeons(PlayerSet& players, LfgDungeonSet& dungeons, bool useEntry)
|
||||||
{
|
{
|
||||||
if (!pPlayers || !dungeons)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
LfgLockStatusSet* dungeonSet = NULL;
|
|
||||||
LfgLockStatusMap* dungeonMap = new LfgLockStatusMap();
|
LfgLockStatusMap* dungeonMap = new LfgLockStatusMap();
|
||||||
for (PlayerSet::const_iterator itr = pPlayers->begin(); itr != pPlayers->end(); ++itr)
|
for (PlayerSet::const_iterator itr = players.begin(); itr != players.end(); ++itr)
|
||||||
{
|
if (LfgLockStatusSet* dungeonSet = GetPlayerLockStatusDungeons(*itr, dungeons, useEntry))
|
||||||
dungeonSet = GetPlayerLockStatusDungeons(*itr, dungeons, useEntry);
|
|
||||||
if (dungeonSet)
|
|
||||||
(*dungeonMap)[(*itr)->GetGUIDLow()] = dungeonSet;
|
(*dungeonMap)[(*itr)->GetGUIDLow()] = dungeonSet;
|
||||||
}
|
|
||||||
|
|
||||||
if (!dungeonMap->size())
|
if (!dungeonMap->size())
|
||||||
{
|
{
|
||||||
@@ -1968,57 +1869,20 @@ LfgLockStatusMap* LFGMgr::GetGroupLockStatusDungeons(PlayerSet* pPlayers, LfgDun
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get all Group members list of dungeons that can't be done and reason
|
Given a list of dungeon return the list of dungeons player can't do and reasons
|
||||||
leader excluded as the list given is he list he can do
|
|
||||||
|
|
||||||
@param[in] plr Players to check group lock status
|
|
||||||
@param[in] dungeons Dungeons to check (Default = NULL, means check all dungeons)
|
|
||||||
@returns Map of player's group dungeon Lock status
|
|
||||||
*/
|
|
||||||
LfgLockStatusMap* LFGMgr::GetPartyLockStatusDungeons(Player* plr, LfgDungeonSet* dungeons /* = NULL */)
|
|
||||||
{
|
|
||||||
if (!plr)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
Group* grp = plr->GetGroup();
|
|
||||||
if (!grp)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (!dungeons)
|
|
||||||
dungeons = GetAllDungeons();
|
|
||||||
|
|
||||||
PlayerSet* pPlayers = new PlayerSet();
|
|
||||||
Player* plrg;
|
|
||||||
for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
|
|
||||||
{
|
|
||||||
plrg = itr->getSource();
|
|
||||||
if (plrg && plrg != plr)
|
|
||||||
pPlayers->insert(plrg);
|
|
||||||
}
|
|
||||||
LfgLockStatusMap* dungeonMap = GetGroupLockStatusDungeons(pPlayers, dungeons);
|
|
||||||
pPlayers->clear();
|
|
||||||
delete pPlayers;
|
|
||||||
return dungeonMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Get list of dungeons player can't do and reasons
|
|
||||||
|
|
||||||
@param[in] plr Players to check dungeon lock status
|
@param[in] plr Players to check dungeon lock status
|
||||||
@param[in] dungeons Dungeons to check (Default = NULL, means check all dungeons)
|
@param[in] dungeons Dungeons to check (Default = NULL, means check all dungeons)
|
||||||
@param[in] useEntry Use dungeon entry (true) or id (false)
|
@param[in] useEntry Use dungeon entry (true) or id (false)
|
||||||
@returns Set of player's dungeon Lock status
|
@returns Set of player's dungeon Lock status
|
||||||
*/
|
*/
|
||||||
LfgLockStatusSet* LFGMgr::GetPlayerLockStatusDungeons(Player* plr, LfgDungeonSet* dungeons /* = NULL */, bool useEntry /* = true */)
|
LfgLockStatusSet* LFGMgr::GetPlayerLockStatusDungeons(Player* plr, LfgDungeonSet& dungeons, bool useEntry)
|
||||||
{
|
{
|
||||||
LfgLockStatusSet* list = new LfgLockStatusSet();
|
LfgLockStatusSet* list = new LfgLockStatusSet();
|
||||||
uint8 level = plr->getLevel();
|
uint8 level = plr->getLevel();
|
||||||
uint8 expansion = plr->GetSession()->Expansion();
|
uint8 expansion = plr->GetSession()->Expansion();
|
||||||
|
|
||||||
if (!dungeons)
|
for (LfgDungeonSet::const_iterator it = dungeons.begin(); it != dungeons.end(); ++it)
|
||||||
dungeons = GetAllDungeons();
|
|
||||||
|
|
||||||
for (LfgDungeonSet::const_iterator it = dungeons->begin(); it != dungeons->end(); ++it)
|
|
||||||
{
|
{
|
||||||
LFGDungeonEntry const* dungeon = sLFGDungeonStore.LookupEntry(*it);
|
LFGDungeonEntry const* dungeon = sLFGDungeonStore.LookupEntry(*it);
|
||||||
if (!dungeon) // should never happen - We provide a list from sLFGDungeonStore
|
if (!dungeon) // should never happen - We provide a list from sLFGDungeonStore
|
||||||
@@ -2078,78 +1942,17 @@ LfgLockStatusSet* LFGMgr::GetPlayerLockStatusDungeons(Player* plr, LfgDungeonSet
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
Get the dungeon list that can be done.
|
|
||||||
|
|
||||||
@returns Set with all dungeons
|
|
||||||
*/
|
|
||||||
LfgDungeonSet* LFGMgr::GetAllDungeons()
|
|
||||||
{
|
|
||||||
if (LfgDungeonSet* alldungeons = m_CachedDungeonMap[0])
|
|
||||||
return alldungeons;
|
|
||||||
|
|
||||||
LfgDungeonSet* alldungeons = new LfgDungeonSet();
|
|
||||||
m_CachedDungeonMap[0] = alldungeons;
|
|
||||||
for (uint32 i = 0; i < sLFGDungeonStore.GetNumRows(); ++i)
|
|
||||||
{
|
|
||||||
LFGDungeonEntry const* dungeon = sLFGDungeonStore.LookupEntry(i);
|
|
||||||
if (!dungeon || dungeon->type == LFG_TYPE_ZONE)
|
|
||||||
continue;
|
|
||||||
LfgDungeonSet* dungeons = m_CachedDungeonMap[dungeon->grouptype];
|
|
||||||
if (!dungeons)
|
|
||||||
{
|
|
||||||
dungeons = new LfgDungeonSet();
|
|
||||||
m_CachedDungeonMap[dungeon->grouptype] = dungeons;
|
|
||||||
}
|
|
||||||
if (dungeon->type != LFG_TYPE_RANDOM)
|
|
||||||
dungeons->insert(dungeon->ID);
|
|
||||||
alldungeons->insert(dungeon->ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
return alldungeons;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the dungeon list that can be done given a random dungeon entry.
|
Get the dungeon list that can be done given a random dungeon entry.
|
||||||
|
|
||||||
@param[in] randomdungeon Random dungeon id (if value = 0 will return all dungeons)
|
@param[in] randomdungeon Random dungeon id (if value = 0 will return all dungeons)
|
||||||
@returns Set of dungeons
|
@param[out] dungeons Set of dungeons that can be done.
|
||||||
*/
|
*/
|
||||||
LfgDungeonSet* LFGMgr::GetDungeonsByRandom(uint32 randomdungeon)
|
void LFGMgr::GetDungeonsByRandom(uint32 randomdungeon, LfgDungeonSet& dungeons)
|
||||||
{
|
{
|
||||||
uint8 groupType = 0;
|
LFGDungeonEntry const* dungeon = sLFGDungeonStore.LookupEntry(randomdungeon);
|
||||||
if (LFGDungeonEntry const* dungeon = sLFGDungeonStore.LookupEntry(randomdungeon))
|
uint8 groupType = dungeon ? dungeon->grouptype : 0;
|
||||||
groupType = dungeon->grouptype;
|
dungeons = m_CachedDungeonMap[groupType];
|
||||||
|
|
||||||
LfgDungeonMap::const_iterator itMap = m_CachedDungeonMap.find(groupType);
|
|
||||||
if (itMap == m_CachedDungeonMap.end())
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
LfgDungeonSet* dungeons = new LfgDungeonSet();
|
|
||||||
for (LfgDungeonSet::const_iterator it = itMap->second->begin(); it != itMap->second->end(); ++it)
|
|
||||||
dungeons->insert(*it);
|
|
||||||
return dungeons;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Get the random dungeon list that can be done at a certain level and expansion.
|
|
||||||
|
|
||||||
@param[in] level Player level
|
|
||||||
@param[in] expansion Player account expansion
|
|
||||||
@returns Set of random dungeons entries
|
|
||||||
*/
|
|
||||||
LfgDungeonSet* LFGMgr::GetRandomDungeons(uint8 level, uint8 expansion)
|
|
||||||
{
|
|
||||||
LfgDungeonSet* list = new LfgDungeonSet();
|
|
||||||
LFGDungeonEntry const* dungeon;
|
|
||||||
for (uint32 i = 0; i < sLFGDungeonStore.GetNumRows(); ++i)
|
|
||||||
{
|
|
||||||
dungeon = sLFGDungeonStore.LookupEntry(i);
|
|
||||||
if (dungeon && dungeon->expansion <= expansion && dungeon->type == LFG_TYPE_RANDOM &&
|
|
||||||
dungeon->minlevel <= level && level <= dungeon->maxlevel)
|
|
||||||
list->insert(dungeon->Entry());
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2189,21 +1992,6 @@ LfgType LFGMgr::GetDungeonType(uint32 dungeonId)
|
|||||||
return LfgType(dungeon->type);
|
return LfgType(dungeon->type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
Given a Dungeon id returns if it's random
|
|
||||||
|
|
||||||
@param[in] dungeon dungeon id
|
|
||||||
@returns True if it's random dungeon
|
|
||||||
*/
|
|
||||||
bool LFGMgr::isRandomDungeon(uint32 dungeonId)
|
|
||||||
{
|
|
||||||
LFGDungeonEntry const* dungeon = sLFGDungeonStore.LookupEntry(dungeonId);
|
|
||||||
if (!dungeon)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return dungeon->type == LFG_TYPE_RANDOM;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Given a Achievement id returns the related dungeon id
|
Given a Achievement id returns the related dungeon id
|
||||||
|
|
||||||
@@ -2230,39 +2018,10 @@ std::string LFGMgr::ConcatenateGuids(LfgGuidList check)
|
|||||||
if (check.empty())
|
if (check.empty())
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
LfgGuidSet guidSet;
|
|
||||||
while (!check.empty())
|
|
||||||
{
|
|
||||||
guidSet.insert(check.front());
|
|
||||||
check.pop_front();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::ostringstream o;
|
std::ostringstream o;
|
||||||
LfgGuidSet::const_iterator it = guidSet.begin();
|
LfgGuidList::const_iterator it = check.begin();
|
||||||
o << (*it);
|
o << (*it);
|
||||||
for (++it; it != guidSet.end(); ++it)
|
for (++it; it != check.end(); ++it)
|
||||||
o << "|" << (*it);
|
o << "|" << (*it);
|
||||||
guidSet.clear();
|
|
||||||
return o.str();
|
return o.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
Given a list of dungeonIds returns the concatenation using , as delimiter
|
|
||||||
|
|
||||||
@param[in] dungeons list of dungeons
|
|
||||||
@returns Concatenated string
|
|
||||||
*/
|
|
||||||
std::string LFGMgr::ConcatenateDungeons(LfgDungeonSet* dungeons)
|
|
||||||
{
|
|
||||||
std::string dungeonstr = "";
|
|
||||||
if (dungeons && !dungeons->empty())
|
|
||||||
{
|
|
||||||
std::ostringstream o;
|
|
||||||
LfgDungeonSet::const_iterator it = dungeons->begin();
|
|
||||||
o << (*it);
|
|
||||||
for (++it; it != dungeons->end(); ++it)
|
|
||||||
o << ", " << (*it);
|
|
||||||
dungeonstr = o.str();
|
|
||||||
}
|
|
||||||
return dungeonstr;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ typedef std::list<Player*> LfgPlayerList;
|
|||||||
typedef std::multimap<uint32, LfgReward const*> LfgRewardMap;
|
typedef std::multimap<uint32, LfgReward const*> LfgRewardMap;
|
||||||
typedef std::pair<LfgRewardMap::const_iterator, LfgRewardMap::const_iterator> LfgRewardMapBounds;
|
typedef std::pair<LfgRewardMap::const_iterator, LfgRewardMap::const_iterator> LfgRewardMapBounds;
|
||||||
typedef std::map<std::string, LfgAnswer> LfgCompatibleMap;
|
typedef std::map<std::string, LfgAnswer> LfgCompatibleMap;
|
||||||
typedef std::map<uint64, LfgDungeonSet*> LfgDungeonMap;
|
typedef std::map<uint64, LfgDungeonSet> LfgDungeonMap;
|
||||||
typedef std::set<LfgLockStatus*> LfgLockStatusSet;
|
typedef std::set<LfgLockStatus*> LfgLockStatusSet;
|
||||||
typedef std::map<uint32, LfgLockStatusSet*> LfgLockStatusMap;
|
typedef std::map<uint32, LfgLockStatusSet*> LfgLockStatusMap;
|
||||||
typedef std::map<uint32, uint8> LfgRolesMap;
|
typedef std::map<uint32, uint8> LfgRolesMap;
|
||||||
@@ -238,7 +238,8 @@ struct LfgRoleCheck
|
|||||||
time_t cancelTime; ///< Time when the rolecheck will fail
|
time_t cancelTime; ///< Time when the rolecheck will fail
|
||||||
LfgRolesMap roles; ///< Player selected roles
|
LfgRolesMap roles; ///< Player selected roles
|
||||||
LfgRoleCheckState result; ///< State of the rolecheck
|
LfgRoleCheckState result; ///< State of the rolecheck
|
||||||
LfgDungeonSet dungeons; ///< Dungeons group is applying for
|
LfgDungeonSet dungeons; ///< Dungeons group is applying for (expanded random dungeons)
|
||||||
|
uint32 rDungeonId; ///< Random Dungeon Id.
|
||||||
uint32 leader; ///< Leader of the group
|
uint32 leader; ///< Leader of the group
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -269,7 +270,7 @@ class LFGMgr
|
|||||||
LfgReward const* GetRandomDungeonReward(uint32 dungeon, uint8 level);
|
LfgReward const* GetRandomDungeonReward(uint32 dungeon, uint8 level);
|
||||||
|
|
||||||
// Queue
|
// Queue
|
||||||
void Join(Player* plr, uint8 roles, LfgDungeonSet* dungeons, std::string comment);
|
void Join(Player* plr, uint8 roles, LfgDungeonSet& dungeons, std::string& comment);
|
||||||
void Leave(Player* plr, Group* grp = NULL);
|
void Leave(Player* plr, Group* grp = NULL);
|
||||||
|
|
||||||
// Role Check
|
// Role Check
|
||||||
@@ -287,12 +288,8 @@ class LFGMgr
|
|||||||
void OfferContinue(Group* grp);
|
void OfferContinue(Group* grp);
|
||||||
|
|
||||||
// Lock info
|
// Lock info
|
||||||
LfgLockStatusMap* GetPartyLockStatusDungeons(Player* plr, LfgDungeonSet* dungeons = NULL);
|
LfgLockStatusMap* GetPartyLockStatusDungeons(Player* plr);
|
||||||
LfgLockStatusSet* GetPlayerLockStatusDungeons(Player* plr, LfgDungeonSet* dungeons = NULL, bool useEntry = true);
|
LfgLockStatusSet* GetPlayerLockStatusDungeons(Player* plr);
|
||||||
|
|
||||||
// Generic
|
|
||||||
bool isRandomDungeon(uint32 dungeonId);
|
|
||||||
LfgDungeonSet* GetRandomDungeons(uint8 level, uint8 expansion);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Queue
|
// Queue
|
||||||
@@ -306,21 +303,19 @@ class LFGMgr
|
|||||||
LfgProposal* FindNewGroups(LfgGuidList& check, LfgGuidList& all);
|
LfgProposal* FindNewGroups(LfgGuidList& check, LfgGuidList& all);
|
||||||
bool CheckGroupRoles(LfgRolesMap &groles, bool removeLeaderFlag = true);
|
bool CheckGroupRoles(LfgRolesMap &groles, bool removeLeaderFlag = true);
|
||||||
bool CheckCompatibility(LfgGuidList check, LfgProposal*& pProposal);
|
bool CheckCompatibility(LfgGuidList check, LfgProposal*& pProposal);
|
||||||
LfgDungeonSet* CheckCompatibleDungeons(LfgDungeonMap* dungeonsMap, PlayerSet* players);
|
LfgLockStatusMap* CheckCompatibleDungeons(LfgDungeonSet& dungeons, PlayerSet& players, bool returnLockMap = true);
|
||||||
LfgLockStatusMap* CheckCompatibleDungeons(LfgDungeonSet* dungeons, PlayerSet* players, bool returnLockMap = true);
|
|
||||||
void SetCompatibles(std::string concatenatedGuids, bool compatibles);
|
void SetCompatibles(std::string concatenatedGuids, bool compatibles);
|
||||||
LfgAnswer GetCompatibles(std::string concatenatedGuids);
|
LfgAnswer GetCompatibles(std::string concatenatedGuids);
|
||||||
void RemoveFromCompatibles(uint64 guid);
|
void RemoveFromCompatibles(uint64 guid);
|
||||||
|
|
||||||
// Lock info
|
// Lock info
|
||||||
LfgLockStatusMap* GetGroupLockStatusDungeons(PlayerSet* pPlayers, LfgDungeonSet* dungeons, bool useEntry = true);
|
LfgLockStatusMap* GetGroupLockStatusDungeons(PlayerSet& players, LfgDungeonSet& dungeons, bool useEntry);
|
||||||
|
LfgLockStatusSet* GetPlayerLockStatusDungeons(Player* plr, LfgDungeonSet& dungeons, bool useEntry);
|
||||||
|
|
||||||
// Generic
|
// Generic
|
||||||
LfgDungeonSet* GetDungeonsByRandom(uint32 randomdungeon);
|
void GetDungeonsByRandom(uint32 randomdungeon, LfgDungeonSet& dungeons);
|
||||||
LfgDungeonSet* GetAllDungeons();
|
|
||||||
LfgType GetDungeonType(uint32 dungeon);
|
LfgType GetDungeonType(uint32 dungeon);
|
||||||
std::string ConcatenateGuids(LfgGuidList check);
|
std::string ConcatenateGuids(LfgGuidList check);
|
||||||
std::string ConcatenateDungeons(LfgDungeonSet* dungeons);
|
|
||||||
|
|
||||||
// General variables
|
// General variables
|
||||||
bool m_update; ///< Doing an update?
|
bool m_update; ///< Doing an update?
|
||||||
|
|||||||
@@ -15,20 +15,23 @@
|
|||||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "LFGMgr.h"
|
|
||||||
#include "WorldSession.h"
|
#include "WorldSession.h"
|
||||||
#include "WorldPacket.h"
|
#include "WorldPacket.h"
|
||||||
|
#include "DBCStores.h"
|
||||||
#include "Player.h"
|
#include "Player.h"
|
||||||
#include "ObjectMgr.h"
|
|
||||||
#include "Group.h"
|
#include "Group.h"
|
||||||
|
#include "LFGMgr.h"
|
||||||
|
#include "ObjectMgr.h"
|
||||||
|
|
||||||
|
|
||||||
void BuildPlayerLockDungeonBlock(WorldPacket &data, LfgLockStatusSet* lockSet)
|
void BuildPlayerLockDungeonBlock(WorldPacket &data, LfgLockStatusSet* lockSet)
|
||||||
{
|
{
|
||||||
if (!lockSet || !lockSet->size())
|
if (!lockSet)
|
||||||
{
|
{
|
||||||
data << uint8(0);
|
data << uint8(0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
data << uint32(lockSet->size()); // Size of lock dungeons
|
data << uint32(lockSet->size()); // Size of lock dungeons
|
||||||
for (LfgLockStatusSet::iterator it = lockSet->begin(); it != lockSet->end(); ++it)
|
for (LfgLockStatusSet::iterator it = lockSet->begin(); it != lockSet->end(); ++it)
|
||||||
{
|
{
|
||||||
@@ -36,13 +39,13 @@ void BuildPlayerLockDungeonBlock(WorldPacket &data, LfgLockStatusSet* lockSet)
|
|||||||
data << uint32((*it)->lockstatus); // Lock status
|
data << uint32((*it)->lockstatus); // Lock status
|
||||||
delete (*it);
|
delete (*it);
|
||||||
}
|
}
|
||||||
lockSet->clear();
|
|
||||||
delete lockSet;
|
delete lockSet;
|
||||||
|
lockSet = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BuildPartyLockDungeonBlock(WorldPacket &data, LfgLockStatusMap* lockMap)
|
void BuildPartyLockDungeonBlock(WorldPacket &data, LfgLockStatusMap* lockMap)
|
||||||
{
|
{
|
||||||
if (!lockMap || !lockMap->size())
|
if (!lockMap)
|
||||||
{
|
{
|
||||||
data << uint8(0);
|
data << uint8(0);
|
||||||
return;
|
return;
|
||||||
@@ -54,8 +57,8 @@ void BuildPartyLockDungeonBlock(WorldPacket &data, LfgLockStatusMap* lockMap)
|
|||||||
data << uint64(MAKE_NEW_GUID(it->first, 0, HIGHGUID_PLAYER)); // Player guid
|
data << uint64(MAKE_NEW_GUID(it->first, 0, HIGHGUID_PLAYER)); // Player guid
|
||||||
BuildPlayerLockDungeonBlock(data, it->second);
|
BuildPlayerLockDungeonBlock(data, it->second);
|
||||||
}
|
}
|
||||||
lockMap->clear();
|
|
||||||
delete lockMap;
|
delete lockMap;
|
||||||
|
lockMap = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldSession::HandleLfgJoinOpcode(WorldPacket &recv_data)
|
void WorldSession::HandleLfgJoinOpcode(WorldPacket &recv_data)
|
||||||
@@ -70,8 +73,6 @@ void WorldSession::HandleLfgJoinOpcode(WorldPacket &recv_data)
|
|||||||
uint8 numDungeons;
|
uint8 numDungeons;
|
||||||
uint32 dungeon;
|
uint32 dungeon;
|
||||||
uint32 roles;
|
uint32 roles;
|
||||||
std::string comment;
|
|
||||||
LfgDungeonSet* newDungeons;
|
|
||||||
|
|
||||||
recv_data >> roles;
|
recv_data >> roles;
|
||||||
recv_data.read_skip<uint16>(); // uint8 (always 0) - uint8 (always 0)
|
recv_data.read_skip<uint16>(); // uint8 (always 0) - uint8 (always 0)
|
||||||
@@ -83,17 +84,18 @@ void WorldSession::HandleLfgJoinOpcode(WorldPacket &recv_data)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
newDungeons = new LfgDungeonSet();
|
LfgDungeonSet newDungeons;
|
||||||
for (int8 i = 0 ; i < numDungeons; ++i)
|
for (int8 i = 0 ; i < numDungeons; ++i)
|
||||||
{
|
{
|
||||||
recv_data >> dungeon;
|
recv_data >> dungeon;
|
||||||
newDungeons->insert((dungeon & 0x00FFFFFF)); // remove the type from the dungeon entry
|
newDungeons.insert((dungeon & 0x00FFFFFF)); // remove the type from the dungeon entry
|
||||||
}
|
}
|
||||||
|
|
||||||
recv_data.read_skip<uint32>(); // for 0..uint8 (always 3) { uint8 (always 0) }
|
recv_data.read_skip<uint32>(); // for 0..uint8 (always 3) { uint8 (always 0) }
|
||||||
|
|
||||||
|
std::string comment;
|
||||||
recv_data >> comment;
|
recv_data >> comment;
|
||||||
sLog.outDebug("CMSG_LFG_JOIN [" UI64FMTD "] roles: %u, Dungeons: %u, Comment: %s", GetPlayer()->GetGUID(), roles, uint8(newDungeons->size()), comment.c_str());
|
sLog.outDebug("CMSG_LFG_JOIN [" UI64FMTD "] roles: %u, Dungeons: %u, Comment: %s", GetPlayer()->GetGUID(), roles, uint8(newDungeons.size()), comment.c_str());
|
||||||
sLFGMgr.Join(GetPlayer(), uint8(roles), newDungeons, comment);
|
sLFGMgr.Join(GetPlayer(), uint8(roles), newDungeons, comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,9 +132,7 @@ void WorldSession::HandleLfgSetRolesOpcode(WorldPacket &recv_data)
|
|||||||
sLog.outDebug("CMSG_LFG_SET_ROLES [" UI64FMTD "] Not in group", GetPlayer()->GetGUID());
|
sLog.outDebug("CMSG_LFG_SET_ROLES [" UI64FMTD "] Not in group", GetPlayer()->GetGUID());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
sLog.outDebug("CMSG_LFG_SET_ROLES [" UI64FMTD "] Roles: %u", GetPlayer()->GetGUID(), roles);
|
sLog.outDebug("CMSG_LFG_SET_ROLES [" UI64FMTD "] Roles: %u", GetPlayer()->GetGUID(), roles);
|
||||||
|
|
||||||
GetPlayer()->SetLfgRoles(roles);
|
GetPlayer()->SetLfgRoles(roles);
|
||||||
sLFGMgr.UpdateRoleCheck(grp, GetPlayer());
|
sLFGMgr.UpdateRoleCheck(grp, GetPlayer());
|
||||||
}
|
}
|
||||||
@@ -167,20 +167,26 @@ void WorldSession::HandleLfgTeleportOpcode(WorldPacket &recv_data)
|
|||||||
void WorldSession::HandleLfgPlayerLockInfoRequestOpcode(WorldPacket &/*recv_data*/)
|
void WorldSession::HandleLfgPlayerLockInfoRequestOpcode(WorldPacket &/*recv_data*/)
|
||||||
{
|
{
|
||||||
sLog.outDebug("CMSG_LFD_PLAYER_LOCK_INFO_REQUEST [" UI64FMTD "]", GetPlayer()->GetGUID());
|
sLog.outDebug("CMSG_LFD_PLAYER_LOCK_INFO_REQUEST [" UI64FMTD "]", GetPlayer()->GetGUID());
|
||||||
uint32 rsize = 0;
|
|
||||||
uint32 lsize = 0;
|
// FIXME - Should return seasonals (when not disabled)
|
||||||
LfgDungeonSet* randomlist = sLFGMgr.GetRandomDungeons(GetPlayer()->getLevel(), GetPlayer()->GetSession()->Expansion());
|
LfgDungeonSet randomDungeons;
|
||||||
|
uint8 level = GetPlayer()->getLevel();
|
||||||
|
uint8 expansion = GetPlayer()->GetSession()->Expansion();
|
||||||
|
for (uint32 i = 0; i < sLFGDungeonStore.GetNumRows(); ++i)
|
||||||
|
{
|
||||||
|
LFGDungeonEntry const* dungeon = sLFGDungeonStore.LookupEntry(i);
|
||||||
|
if (dungeon && dungeon->type == LFG_TYPE_RANDOM && dungeon && dungeon->expansion <= expansion &&
|
||||||
|
dungeon->minlevel <= level && level <= dungeon->maxlevel)
|
||||||
|
randomDungeons.insert(dungeon->Entry());
|
||||||
|
}
|
||||||
|
|
||||||
LfgLockStatusSet* lockSet = sLFGMgr.GetPlayerLockStatusDungeons(GetPlayer());
|
LfgLockStatusSet* lockSet = sLFGMgr.GetPlayerLockStatusDungeons(GetPlayer());
|
||||||
|
uint32 rsize = uint32(randomDungeons.size());
|
||||||
if (randomlist)
|
uint32 lsize = lockSet ? uint32(lockSet->size()) : 0;
|
||||||
rsize = randomlist->size();
|
|
||||||
|
|
||||||
if (lockSet)
|
|
||||||
lsize = lockSet->size();
|
|
||||||
|
|
||||||
sLog.outDebug("SMSG_LFG_PLAYER_INFO [" UI64FMTD "]", GetPlayer()->GetGUID());
|
sLog.outDebug("SMSG_LFG_PLAYER_INFO [" UI64FMTD "]", GetPlayer()->GetGUID());
|
||||||
WorldPacket data(SMSG_LFG_PLAYER_INFO, 1 + rsize * (4 + 1 + 4 + 4 + 4 + 4 + 1 + 4 + 4 + 4) + 4 + lsize * (1 + 4 + 4 + 4 + 4 + 1 + 4 + 4 + 4));
|
WorldPacket data(SMSG_LFG_PLAYER_INFO, 1 + rsize * (4 + 1 + 4 + 4 + 4 + 4 + 1 + 4 + 4 + 4) + 4 + lsize * (1 + 4 + 4 + 4 + 4 + 1 + 4 + 4 + 4));
|
||||||
if (!randomlist)
|
if (!randomDungeons.size())
|
||||||
data << uint8(0);
|
data << uint8(0);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -188,11 +194,11 @@ void WorldSession::HandleLfgPlayerLockInfoRequestOpcode(WorldPacket &/*recv_data
|
|||||||
Quest const* qRew = NULL;
|
Quest const* qRew = NULL;
|
||||||
uint8 done;
|
uint8 done;
|
||||||
|
|
||||||
data << uint8(randomlist->size()); // Random Dungeon count
|
data << uint8(randomDungeons.size()); // Random Dungeon count
|
||||||
for (LfgDungeonSet::iterator it = randomlist->begin(); it != randomlist->end(); ++it)
|
for (LfgDungeonSet::iterator it = randomDungeons.begin(); it != randomDungeons.end(); ++it)
|
||||||
{
|
{
|
||||||
data << uint32(*it); // Entry
|
data << uint32(*it); // Entry
|
||||||
reward = sLFGMgr.GetRandomDungeonReward(*it, GetPlayer()->getLevel());
|
reward = sLFGMgr.GetRandomDungeonReward(*it, level);
|
||||||
qRew = NULL;
|
qRew = NULL;
|
||||||
if (reward)
|
if (reward)
|
||||||
{
|
{
|
||||||
@@ -239,8 +245,6 @@ void WorldSession::HandleLfgPlayerLockInfoRequestOpcode(WorldPacket &/*recv_data
|
|||||||
data << uint8(0);
|
data << uint8(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
randomlist->clear();
|
|
||||||
delete randomlist;
|
|
||||||
}
|
}
|
||||||
BuildPlayerLockDungeonBlock(data, lockSet);
|
BuildPlayerLockDungeonBlock(data, lockSet);
|
||||||
SendPacket(&data);
|
SendPacket(&data);
|
||||||
@@ -382,30 +386,33 @@ void WorldSession::SendLfgRoleChosen(uint64 guid, uint8 roles)
|
|||||||
void WorldSession::SendLfgRoleCheckUpdate(LfgRoleCheck* pRoleCheck)
|
void WorldSession::SendLfgRoleCheckUpdate(LfgRoleCheck* pRoleCheck)
|
||||||
{
|
{
|
||||||
ASSERT(pRoleCheck);
|
ASSERT(pRoleCheck);
|
||||||
|
LfgDungeonSet dungeons;
|
||||||
|
if (pRoleCheck->rDungeonId)
|
||||||
|
dungeons.insert(pRoleCheck->rDungeonId);
|
||||||
|
else
|
||||||
|
dungeons = pRoleCheck->dungeons;
|
||||||
|
|
||||||
sLog.outDebug("SMSG_LFG_ROLE_CHECK_UPDATE [" UI64FMTD "]", GetPlayer()->GetGUID());
|
sLog.outDebug("SMSG_LFG_ROLE_CHECK_UPDATE [" UI64FMTD "]", GetPlayer()->GetGUID());
|
||||||
WorldPacket data(SMSG_LFG_ROLE_CHECK_UPDATE, 4 + 1 + 1 + pRoleCheck->dungeons.size() * 4 + 1 + pRoleCheck->roles.size() * (8 + 1 + 4 + 1));
|
WorldPacket data(SMSG_LFG_ROLE_CHECK_UPDATE, 4 + 1 + 1 + dungeons.size() * 4 + 1 + pRoleCheck->roles.size() * (8 + 1 + 4 + 1));
|
||||||
|
|
||||||
Player* plr;
|
Player* plr;
|
||||||
uint8 roles;
|
uint8 roles;
|
||||||
|
|
||||||
data << uint32(pRoleCheck->result); // Check result
|
data << uint32(pRoleCheck->result); // Check result
|
||||||
data << uint8(pRoleCheck->result == LFG_ROLECHECK_INITIALITING);
|
data << uint8(pRoleCheck->result == LFG_ROLECHECK_INITIALITING);
|
||||||
data << uint8(pRoleCheck->dungeons.size()); // Number of dungeons
|
data << uint8(dungeons.size()); // Number of dungeons
|
||||||
LFGDungeonEntry const* dungeon;
|
if (dungeons.size())
|
||||||
for (LfgDungeonSet::iterator it = pRoleCheck->dungeons.begin(); it != pRoleCheck->dungeons.end(); ++it)
|
|
||||||
{
|
{
|
||||||
dungeon = sLFGDungeonStore.LookupEntry(*it);
|
for (LfgDungeonSet::iterator it = dungeons.begin(); it != dungeons.end(); ++it)
|
||||||
if (!dungeon)
|
|
||||||
{
|
{
|
||||||
sLog.outError("BuildLfgRoleCheck: Dungeon %u does not exist in dbcs", (*it));
|
LFGDungeonEntry const* dungeon = sLFGDungeonStore.LookupEntry(*it);
|
||||||
data << uint32(0);
|
data << uint32(dungeon ? dungeon->Entry() : 0); // Dungeon
|
||||||
}
|
}
|
||||||
else
|
|
||||||
data << uint32(dungeon->Entry()); // Dungeon
|
|
||||||
}
|
}
|
||||||
|
|
||||||
data << uint8(pRoleCheck->roles.size()); // Players in group
|
data << uint8(pRoleCheck->roles.size()); // Players in group
|
||||||
|
if (pRoleCheck->roles.size())
|
||||||
|
{
|
||||||
// Leader info MUST be sent 1st :S
|
// Leader info MUST be sent 1st :S
|
||||||
roles = pRoleCheck->roles[pRoleCheck->leader];
|
roles = pRoleCheck->roles[pRoleCheck->leader];
|
||||||
uint64 guid = MAKE_NEW_GUID(pRoleCheck->leader, 0, HIGHGUID_PLAYER);
|
uint64 guid = MAKE_NEW_GUID(pRoleCheck->leader, 0, HIGHGUID_PLAYER);
|
||||||
@@ -428,6 +435,7 @@ void WorldSession::SendLfgRoleCheckUpdate(LfgRoleCheck* pRoleCheck)
|
|||||||
plr = sObjectMgr.GetPlayer(guid);
|
plr = sObjectMgr.GetPlayer(guid);
|
||||||
data << uint8(plr ? plr->getLevel() : 0); // Level
|
data << uint8(plr ? plr->getLevel() : 0); // Level
|
||||||
}
|
}
|
||||||
|
}
|
||||||
SendPacket(&data);
|
SendPacket(&data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -444,7 +452,6 @@ void WorldSession::SendLfgJoinResult(uint8 checkResult, uint8 checkValue /* = 0
|
|||||||
WorldPacket data(SMSG_LFG_JOIN_RESULT, 4 + 4 + size);
|
WorldPacket data(SMSG_LFG_JOIN_RESULT, 4 + 4 + size);
|
||||||
data << uint32(checkResult); // Check Result
|
data << uint32(checkResult); // Check Result
|
||||||
data << uint32(checkValue); // Check Value
|
data << uint32(checkValue); // Check Value
|
||||||
if (playersLockMap)
|
|
||||||
BuildPartyLockDungeonBlock(data, playersLockMap);
|
BuildPartyLockDungeonBlock(data, playersLockMap);
|
||||||
SendPacket(&data);
|
SendPacket(&data);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,6 @@
|
|||||||
#include "ScriptMgr.h"
|
#include "ScriptMgr.h"
|
||||||
#include "MapManager.h"
|
#include "MapManager.h"
|
||||||
#include "InstanceScript.h"
|
#include "InstanceScript.h"
|
||||||
#include "LFGMgr.h"
|
|
||||||
#include "GameObjectAI.h"
|
#include "GameObjectAI.h"
|
||||||
#include "Group.h"
|
#include "Group.h"
|
||||||
|
|
||||||
@@ -948,7 +947,7 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket & recv_data)
|
|||||||
|
|
||||||
// Check if we are in LfgGroup and trying to get out the dungeon
|
// Check if we are in LfgGroup and trying to get out the dungeon
|
||||||
if (GetPlayer()->GetGroup() && GetPlayer()->GetGroup()->isLFGGroup() && GetPlayer()->GetMap()->IsDungeon() && at->target_mapId != GetPlayer()->GetMapId())
|
if (GetPlayer()->GetGroup() && GetPlayer()->GetGroup()->isLFGGroup() && GetPlayer()->GetMap()->IsDungeon() && at->target_mapId != GetPlayer()->GetMapId())
|
||||||
sLFGMgr.TeleportPlayer(GetPlayer(), true);
|
GetPlayer()->TeleportToBGEntryPoint();
|
||||||
else
|
else
|
||||||
GetPlayer()->TeleportTo(at->target_mapId,at->target_X,at->target_Y,at->target_Z,at->target_Orientation,TELE_TO_NOT_LEAVE_TRANSPORT);
|
GetPlayer()->TeleportTo(at->target_mapId,at->target_X,at->target_Y,at->target_Z,at->target_Orientation,TELE_TO_NOT_LEAVE_TRANSPORT);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user