Core/Dungeon Finder: Check lock status of dungeons when joining non-random dungeons (Fixes not checking if raid was closed for the selected difficulty)

Core/Dungeon Finder: Fix some memory leaks when Joining
Core/Dungeon Finder: Do not allow to join dungeon raid browser (Not supported yet)

--HG--
branch : trunk
This commit is contained in:
Spp
2010-11-22 13:16:09 +01:00
parent a7d262ce03
commit a5833f2307
+86 -62
View File
@@ -547,6 +547,9 @@ void LFGMgr::Join(Player* plr)
uint64 guid = grp ? grp->GetGUID() : plr->GetGUID(); uint64 guid = grp ? grp->GetGUID() : plr->GetGUID();
LfgJoinResult result = LFG_JOIN_OK; LfgJoinResult result = LFG_JOIN_OK;
bool isDungeon = false;
bool isRaid = false;
LfgLockStatusMap* playersLockMap = NULL;
// Previous checks before joining // Previous checks before joining
LfgQueueInfoMap::iterator itQueue = m_QueueInfoMap.find(guid); LfgQueueInfoMap::iterator itQueue = m_QueueInfoMap.find(guid);
if (itQueue != m_QueueInfoMap.end()) if (itQueue != m_QueueInfoMap.end())
@@ -568,11 +571,12 @@ void LFGMgr::Join(Player* plr)
{ {
dungeons = plr->GetLfgDungeons(); dungeons = plr->GetLfgDungeons();
if (!dungeons || !dungeons->size()) if (!dungeons || !dungeons->size())
{
result = LFG_JOIN_NOT_MEET_REQS; result = LFG_JOIN_NOT_MEET_REQS;
dungeons = NULL;
}
else // Check if all dungeons are valid else // Check if all dungeons are valid
{ {
bool isDungeon = false;
bool isRaid = false;
LfgType type = LFG_TYPE_NONE; LfgType type = LFG_TYPE_NONE;
for (LfgDungeonSet::const_iterator it = dungeons->begin(); it != dungeons->end(); ++it) for (LfgDungeonSet::const_iterator it = dungeons->begin(); it != dungeons->end(); ++it)
{ {
@@ -598,29 +602,48 @@ void LFGMgr::Join(Player* plr)
} }
} }
// Group checks if (result == LFG_JOIN_OK)
if (grp && result == LFG_JOIN_OK)
{ {
if (grp->GetMembersCount() > MAXGROUPSIZE) if (grp)
result = LFG_JOIN_TOO_MUCH_MEMBERS; {
if (grp->GetMembersCount() > MAXGROUPSIZE)
result = LFG_JOIN_TOO_MUCH_MEMBERS;
else
{
Player* plrg;
uint8 memberCount = 0;
for (GroupReference* itr = grp->GetFirstMember(); itr != NULL && result == LFG_JOIN_OK; itr = itr->next())
{
plrg = itr->getSource();
if (plrg)
{
if (plrg->HasAura(LFG_SPELL_DUNGEON_DESERTER))
result = LFG_JOIN_PARTY_DESERTER;
else if (plrg->HasAura(LFG_SPELL_DUNGEON_COOLDOWN))
result = LFG_JOIN_PARTY_RANDOM_COOLDOWN;
++memberCount;
}
}
if (memberCount != grp->GetMembersCount())
result = LFG_JOIN_DISCONNECTED;
}
}
else else
{ {
Player* plrg; // Expand random dungeons and check restrictions
uint8 memberCount = 0; PlayerSet players;
for (GroupReference* itr = grp->GetFirstMember(); itr != NULL && result == LFG_JOIN_OK; itr = itr->next()) players.insert(plr);
if (plr->GetLfgDungeons()->size() == 1 && isRandomDungeon(*plr->GetLfgDungeons()->begin()))
dungeons = GetDungeonsByRandom(*plr->GetLfgDungeons()->begin());
else
{ {
plrg = itr->getSource(); dungeons = new LfgDungeonSet();
if (plrg) for (LfgDungeonSet::const_iterator it = plr->GetLfgDungeons()->begin(); it != plr->GetLfgDungeons()->end(); ++it)
{ dungeons->insert(*it);
if (plrg->HasAura(LFG_SPELL_DUNGEON_DESERTER))
result = LFG_JOIN_PARTY_DESERTER;
else if (plrg->HasAura(LFG_SPELL_DUNGEON_COOLDOWN))
result = LFG_JOIN_PARTY_RANDOM_COOLDOWN;
++memberCount;
}
} }
if (memberCount != grp->GetMembersCount()) playersLockMap = CheckCompatibleDungeons(dungeons, &players);
result = LFG_JOIN_DISCONNECTED; if (!dungeons || !dungeons->size())
result = LFG_JOIN_NOT_MEET_REQS;
} }
} }
@@ -631,63 +654,64 @@ void LFGMgr::Join(Player* plr)
plr->SetLfgRoles(ROLE_NONE); plr->SetLfgRoles(ROLE_NONE);
if (grp && !grp->isLFGGroup()) if (grp && !grp->isLFGGroup())
plr->SetLfgState(LFG_STATE_NONE); plr->SetLfgState(LFG_STATE_NONE);
plr->GetSession()->SendLfgJoinResult(result); plr->GetSession()->SendLfgJoinResult(result, 0, playersLockMap);
if (playersLockMap)
{
for(LfgLockStatusMap::iterator it = playersLockMap->begin(); it != playersLockMap->end(); ++it)
{
it->second->clear();
delete it->second;
}
playersLockMap->clear();
delete playersLockMap;
}
if (dungeons)
{
dungeons->clear();
delete dungeons;
}
return; return;
} }
if (grp) if (!isRaid) // At the moment do not allow to join Raid Browser
{ {
Player* plrg = NULL; if (grp)
for (GroupReference* itr = plr->GetGroup()->GetFirstMember(); itr != NULL; itr = itr->next())
{ {
plrg = itr->getSource(); // Not null, checked earlier Player* plrg = NULL;
plrg->SetLfgState(LFG_STATE_LFG); for (GroupReference* itr = plr->GetGroup()->GetFirstMember(); itr != NULL; itr = itr->next())
if (plrg != plr)
{ {
dungeons = plrg->GetLfgDungeons(); plrg = itr->getSource(); // Not null, checked earlier
dungeons->clear(); plrg->SetLfgState(LFG_STATE_LFG);
for (LfgDungeonSet::const_iterator itDungeon = plr->GetLfgDungeons()->begin(); itDungeon != plr->GetLfgDungeons()->end(); ++itDungeon) if (plrg != plr)
dungeons->insert(*itDungeon); {
dungeons = plrg->GetLfgDungeons();
dungeons->clear();
for (LfgDungeonSet::const_iterator itDungeon = plr->GetLfgDungeons()->begin(); itDungeon != plr->GetLfgDungeons()->end(); ++itDungeon)
dungeons->insert(*itDungeon);
}
plrg->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_JOIN_PROPOSAL);
} }
plrg->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_JOIN_PROPOSAL); UpdateRoleCheck(grp, plr);
} }
UpdateRoleCheck(grp, plr);
}
else
{
plr->SetLfgState(LFG_STATE_LFG);
LfgRolesMap roles;
roles[plr->GetGUIDLow()] = plr->GetLfgRoles();
// Expand random dungeons
LfgLockStatusMap* playersLockMap = NULL;
if (plr->GetLfgDungeons()->size() == 1 && isRandomDungeon(*plr->GetLfgDungeons()->begin()))
{
PlayerSet players;
players.insert(plr);
dungeons = GetDungeonsByRandom(*plr->GetLfgDungeons()->begin());
playersLockMap = CheckCompatibleDungeons(dungeons, &players);
if (dungeons && !dungeons->size())
{
delete dungeons;
dungeons = NULL;
}
}
else
dungeons = plr->GetLfgDungeons();
if (!dungeons || !dungeons->size())
plr->GetSession()->SendLfgJoinResult(LFG_JOIN_NOT_MEET_REQS, 0, playersLockMap);
else else
{ {
plr->GetSession()->SendLfgJoinResult(LFG_JOIN_OK, 0); plr->GetSession()->SendLfgJoinResult(LFG_JOIN_OK, 0);
plr->GetSession()->SendLfgUpdatePlayer(LFG_UPDATETYPE_JOIN_PROPOSAL); plr->GetSession()->SendLfgUpdatePlayer(LFG_UPDATETYPE_JOIN_PROPOSAL);
plr->SetLfgState(LFG_STATE_LFG);
LfgRolesMap roles;
roles[plr->GetGUIDLow()] = plr->GetLfgRoles();
AddToQueue(plr->GetGUID(), &roles, dungeons); AddToQueue(plr->GetGUID(), &roles, dungeons);
roles.clear();
} }
roles.clear();
} }
std::string dungeonsstr = ConcatenateDungeons(dungeons);
sLog.outDebug("LFGMgr::Join: [" UI64FMTD "] joined with %u members. dungeons: %s", guid, grp ? grp->GetMembersCount() : 1, dungeonsstr.c_str()); if (dungeons)
{
std::string dungeonsstr = ConcatenateDungeons(dungeons);
sLog.outDebug("LFGMgr::Join: [" UI64FMTD "] joined with %u members. dungeons: %s", guid, grp ? grp->GetMembersCount() : 1, dungeonsstr.c_str());
dungeons->clear();
delete dungeons;
}
} }
/// <summary> /// <summary>