mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-29 05:11:55 +01:00
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:
@@ -547,6 +547,9 @@ void LFGMgr::Join(Player* plr)
|
||||
uint64 guid = grp ? grp->GetGUID() : plr->GetGUID();
|
||||
|
||||
LfgJoinResult result = LFG_JOIN_OK;
|
||||
bool isDungeon = false;
|
||||
bool isRaid = false;
|
||||
LfgLockStatusMap* playersLockMap = NULL;
|
||||
// Previous checks before joining
|
||||
LfgQueueInfoMap::iterator itQueue = m_QueueInfoMap.find(guid);
|
||||
if (itQueue != m_QueueInfoMap.end())
|
||||
@@ -568,11 +571,12 @@ void LFGMgr::Join(Player* plr)
|
||||
{
|
||||
dungeons = plr->GetLfgDungeons();
|
||||
if (!dungeons || !dungeons->size())
|
||||
{
|
||||
result = LFG_JOIN_NOT_MEET_REQS;
|
||||
dungeons = NULL;
|
||||
}
|
||||
else // Check if all dungeons are valid
|
||||
{
|
||||
bool isDungeon = false;
|
||||
bool isRaid = false;
|
||||
LfgType type = LFG_TYPE_NONE;
|
||||
for (LfgDungeonSet::const_iterator it = dungeons->begin(); it != dungeons->end(); ++it)
|
||||
{
|
||||
@@ -598,29 +602,48 @@ void LFGMgr::Join(Player* plr)
|
||||
}
|
||||
}
|
||||
|
||||
// Group checks
|
||||
if (grp && result == LFG_JOIN_OK)
|
||||
if (result == LFG_JOIN_OK)
|
||||
{
|
||||
if (grp->GetMembersCount() > MAXGROUPSIZE)
|
||||
result = LFG_JOIN_TOO_MUCH_MEMBERS;
|
||||
if (grp)
|
||||
{
|
||||
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
|
||||
{
|
||||
Player* plrg;
|
||||
uint8 memberCount = 0;
|
||||
for (GroupReference* itr = grp->GetFirstMember(); itr != NULL && result == LFG_JOIN_OK; itr = itr->next())
|
||||
// Expand random dungeons and check restrictions
|
||||
PlayerSet players;
|
||||
players.insert(plr);
|
||||
if (plr->GetLfgDungeons()->size() == 1 && isRandomDungeon(*plr->GetLfgDungeons()->begin()))
|
||||
dungeons = GetDungeonsByRandom(*plr->GetLfgDungeons()->begin());
|
||||
else
|
||||
{
|
||||
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;
|
||||
}
|
||||
dungeons = new LfgDungeonSet();
|
||||
for (LfgDungeonSet::const_iterator it = plr->GetLfgDungeons()->begin(); it != plr->GetLfgDungeons()->end(); ++it)
|
||||
dungeons->insert(*it);
|
||||
}
|
||||
if (memberCount != grp->GetMembersCount())
|
||||
result = LFG_JOIN_DISCONNECTED;
|
||||
playersLockMap = CheckCompatibleDungeons(dungeons, &players);
|
||||
if (!dungeons || !dungeons->size())
|
||||
result = LFG_JOIN_NOT_MEET_REQS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -631,63 +654,64 @@ void LFGMgr::Join(Player* plr)
|
||||
plr->SetLfgRoles(ROLE_NONE);
|
||||
if (grp && !grp->isLFGGroup())
|
||||
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;
|
||||
}
|
||||
|
||||
if (grp)
|
||||
if (!isRaid) // At the moment do not allow to join Raid Browser
|
||||
{
|
||||
Player* plrg = NULL;
|
||||
for (GroupReference* itr = plr->GetGroup()->GetFirstMember(); itr != NULL; itr = itr->next())
|
||||
if (grp)
|
||||
{
|
||||
plrg = itr->getSource(); // Not null, checked earlier
|
||||
plrg->SetLfgState(LFG_STATE_LFG);
|
||||
if (plrg != plr)
|
||||
Player* plrg = NULL;
|
||||
for (GroupReference* itr = plr->GetGroup()->GetFirstMember(); itr != NULL; itr = itr->next())
|
||||
{
|
||||
dungeons = plrg->GetLfgDungeons();
|
||||
dungeons->clear();
|
||||
for (LfgDungeonSet::const_iterator itDungeon = plr->GetLfgDungeons()->begin(); itDungeon != plr->GetLfgDungeons()->end(); ++itDungeon)
|
||||
dungeons->insert(*itDungeon);
|
||||
plrg = itr->getSource(); // Not null, checked earlier
|
||||
plrg->SetLfgState(LFG_STATE_LFG);
|
||||
if (plrg != plr)
|
||||
{
|
||||
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
|
||||
{
|
||||
plr->GetSession()->SendLfgJoinResult(LFG_JOIN_OK, 0);
|
||||
plr->GetSession()->SendLfgUpdatePlayer(LFG_UPDATETYPE_JOIN_PROPOSAL);
|
||||
plr->SetLfgState(LFG_STATE_LFG);
|
||||
LfgRolesMap roles;
|
||||
roles[plr->GetGUIDLow()] = plr->GetLfgRoles();
|
||||
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>
|
||||
|
||||
Reference in New Issue
Block a user