From 9815847511b131f8ae550a9594fdab37970a193a Mon Sep 17 00:00:00 2001 From: Spp Date: Mon, 13 Dec 2010 21:28:33 +0100 Subject: [PATCH] Core/Dungeon Finder: Return a copy of cached dungeons set (to avoid being cleared later in code) --HG-- branch : trunk --- src/server/game/DungeonFinding/LFGMgr.cpp | 14 ++++++-------- src/server/game/DungeonFinding/LFGMgr.h | 2 +- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/server/game/DungeonFinding/LFGMgr.cpp b/src/server/game/DungeonFinding/LFGMgr.cpp index 30cc7c5275..91926c9934 100755 --- a/src/server/game/DungeonFinding/LFGMgr.cpp +++ b/src/server/game/DungeonFinding/LFGMgr.cpp @@ -536,7 +536,7 @@ void LFGMgr::Join(Player* plr, uint8 roles, LfgDungeonSet& dungeons, std::string // Expand random dungeons and check restrictions if (rDungeonId) - GetDungeonsByRandom(rDungeonId, dungeons); + dungeons = GetDungeonsByRandom(rDungeonId); LfgLockStatusMap* lockStatusMap = CheckCompatibleDungeons(dungeons, players); if (!dungeons.size()) @@ -1831,8 +1831,7 @@ LfgLockStatusMap* LFGMgr::GetPartyLockStatusDungeons(Player* plr) players.insert(plrg); } - LfgDungeonSet allDungeons; - GetDungeonsByRandom(0, allDungeons); + LfgDungeonSet allDungeons = GetDungeonsByRandom(0); return GetGroupLockStatusDungeons(players, allDungeons, true); } @@ -1844,8 +1843,7 @@ LfgLockStatusMap* LFGMgr::GetPartyLockStatusDungeons(Player* plr) */ LfgLockStatusSet* LFGMgr::GetPlayerLockStatusDungeons(Player* plr) { - LfgDungeonSet allDungeons; - GetDungeonsByRandom(0, allDungeons); + LfgDungeonSet allDungeons = GetDungeonsByRandom(0); return GetPlayerLockStatusDungeons(plr, allDungeons, true); } @@ -1950,13 +1948,13 @@ LfgLockStatusSet* LFGMgr::GetPlayerLockStatusDungeons(Player* plr, LfgDungeonSet 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[out] dungeons Set of dungeons that can be done. + @returns Set of dungeons that can be done. */ -void LFGMgr::GetDungeonsByRandom(uint32 randomdungeon, LfgDungeonSet& dungeons) +LfgDungeonSet LFGMgr::GetDungeonsByRandom(uint32 randomdungeon) { LFGDungeonEntry const* dungeon = sLFGDungeonStore.LookupEntry(randomdungeon); uint8 groupType = dungeon ? dungeon->grouptype : 0; - dungeons = m_CachedDungeonMap[groupType]; + return m_CachedDungeonMap[groupType]; // Return a copy } /** diff --git a/src/server/game/DungeonFinding/LFGMgr.h b/src/server/game/DungeonFinding/LFGMgr.h index ddfbfc5235..75b5f0bee2 100755 --- a/src/server/game/DungeonFinding/LFGMgr.h +++ b/src/server/game/DungeonFinding/LFGMgr.h @@ -313,7 +313,7 @@ class LFGMgr LfgLockStatusSet* GetPlayerLockStatusDungeons(Player* plr, LfgDungeonSet& dungeons, bool useEntry); // Generic - void GetDungeonsByRandom(uint32 randomdungeon, LfgDungeonSet& dungeons); + LfgDungeonSet GetDungeonsByRandom(uint32 randomdungeon); LfgType GetDungeonType(uint32 dungeon); std::string ConcatenateGuids(LfgGuidList check);