diff options
author | jackpoz <giacomopoz@gmail.com> | 2014-11-09 20:41:22 +0100 |
---|---|---|
committer | jackpoz <giacomopoz@gmail.com> | 2014-11-09 20:55:51 +0100 |
commit | 3881c5c3db81d94a2e02463540c45e3c4b63f7cb (patch) | |
tree | 1b448474da339a835132d4c4a429bd9bb66b5fe7 /src | |
parent | 31730d52b6ba30d70ff14f8799e0d494e750c459 (diff) |
Core/LFG: Allow group bound to LFG instance to re-queue if someone leaves the party
(cherry picked from commit 064b47eccf6e9f4cb423340576a9a6f278ab4e69)
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/DungeonFinding/LFGMgr.cpp | 35 | ||||
-rw-r--r-- | src/server/game/DungeonFinding/LFGMgr.h | 2 |
2 files changed, 33 insertions, 4 deletions
diff --git a/src/server/game/DungeonFinding/LFGMgr.cpp b/src/server/game/DungeonFinding/LFGMgr.cpp index 3272c29a447..f4df5c85c8f 100644 --- a/src/server/game/DungeonFinding/LFGMgr.cpp +++ b/src/server/game/DungeonFinding/LFGMgr.cpp @@ -33,6 +33,7 @@ #include "GroupMgr.h" #include "GameEventMgr.h" #include "WorldSession.h" +#include "InstanceSaveMgr.h" namespace lfg { @@ -482,7 +483,7 @@ void LFGMgr::JoinLfg(Player* player, uint8 roles, LfgDungeonSet& dungeons, const dungeons = GetDungeonsByRandom(rDungeonId); // if we have lockmap then there are no compatible dungeons - GetCompatibleDungeons(dungeons, players, joinData.lockmap); + GetCompatibleDungeons(dungeons, players, joinData.lockmap, isContinue); if (dungeons.empty()) joinData.result = grp ? LFG_JOIN_INTERNAL_ERROR : LFG_JOIN_NOT_MEET_REQS; } @@ -747,20 +748,48 @@ void LFGMgr::UpdateRoleCheck(ObjectGuid gguid, ObjectGuid guid /* = ObjectGuid:: @param[in] players Set of players to check their dungeon restrictions @param[out] lockMap Map of players Lock status info of given dungeons (Empty if dungeons is not empty) */ -void LFGMgr::GetCompatibleDungeons(LfgDungeonSet& dungeons, GuidSet const& players, LfgLockPartyMap& lockMap) +void LFGMgr::GetCompatibleDungeons(LfgDungeonSet& dungeons, GuidSet const& players, LfgLockPartyMap& lockMap, bool isContinue) { lockMap.clear(); + + std::map<uint32, uint32> lockedDungeons; + for (GuidSet::const_iterator it = players.begin(); it != players.end() && !dungeons.empty(); ++it) { ObjectGuid guid = (*it); LfgLockMap const& cachedLockMap = GetLockedDungeons(guid); + Player* player = ObjectAccessor::FindPlayer(guid); for (LfgLockMap::const_iterator it2 = cachedLockMap.begin(); it2 != cachedLockMap.end() && !dungeons.empty(); ++it2) { uint32 dungeonId = (it2->first & 0x00FFFFFF); // Compare dungeon ids LfgDungeonSet::iterator itDungeon = dungeons.find(dungeonId); if (itDungeon != dungeons.end()) { - dungeons.erase(itDungeon); + bool eraseDungeon = true; + + // Don't remove the dungeon if team members are trying to continue a locked instance + if (it2->second == LFG_LOCKSTATUS_RAID_LOCKED && isContinue) + { + LFGDungeonData const* dungeon = GetLFGDungeon(dungeonId); + ASSERT(dungeon); + ASSERT(player); + if (InstancePlayerBind* playerBind = player->GetBoundInstance(dungeon->map, Difficulty(dungeon->difficulty))) + { + if (InstanceSave* playerSave = playerBind->save) + { + uint32 dungeonInstanceId = playerSave->GetInstanceId(); + auto itLockedDungeon = lockedDungeons.find(dungeonId); + if (itLockedDungeon == lockedDungeons.end() || itLockedDungeon->second == dungeonInstanceId) + eraseDungeon = false; + + lockedDungeons[dungeonId] = dungeonInstanceId; + } + } + } + + if (eraseDungeon) + dungeons.erase(itDungeon); + lockMap[guid][dungeonId] = it2->second; } } diff --git a/src/server/game/DungeonFinding/LFGMgr.h b/src/server/game/DungeonFinding/LFGMgr.h index 9f990131a71..2869c6cea74 100644 --- a/src/server/game/DungeonFinding/LFGMgr.h +++ b/src/server/game/DungeonFinding/LFGMgr.h @@ -436,7 +436,7 @@ class LFGMgr void DecreaseKicksLeft(ObjectGuid guid); void SetState(ObjectGuid guid, LfgState state); void RemovePlayerData(ObjectGuid guid); - void GetCompatibleDungeons(LfgDungeonSet& dungeons, GuidSet const& players, LfgLockPartyMap& lockMap); + void GetCompatibleDungeons(LfgDungeonSet& dungeons, GuidSet const& players, LfgLockPartyMap& lockMap, bool isContinue); void _SaveToDB(ObjectGuid guid, uint32 db_guid); LFGDungeonData const* GetLFGDungeon(uint32 id); |