diff options
author | Shauren <shauren.trinity@gmail.com> | 2020-01-02 14:19:35 +0100 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2022-10-04 00:19:38 +0200 |
commit | 9b924522d0549dd67b10e2cbdfc20297dd21e182 (patch) | |
tree | f0fcdf96902b7c497c1bc65db83621a8dfadf43a /src/server/game/Maps/MapManager.cpp | |
parent | a131542855d23022714a97640be1c8d68a741c31 (diff) |
Core/Instances: Delete InstanceSaveMgr and replace most of its uses with new InstanceLockMgr
Diffstat (limited to 'src/server/game/Maps/MapManager.cpp')
-rw-r--r-- | src/server/game/Maps/MapManager.cpp | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/src/server/game/Maps/MapManager.cpp b/src/server/game/Maps/MapManager.cpp index 8a525d2b64e..788d27301a4 100644 --- a/src/server/game/Maps/MapManager.cpp +++ b/src/server/game/Maps/MapManager.cpp @@ -23,7 +23,6 @@ #include "GarrisonMap.h" #include "Group.h" #include "InstanceLockMgr.h" -#include "InstanceSaveMgr.h" #include "Log.h" #include "Map.h" #include "Player.h" @@ -250,6 +249,49 @@ Map* MapManager::FindMap(uint32 mapId, uint32 instanceId) const return FindMap_i(mapId, instanceId); } +uint32 MapManager::FindInstanceIdForPlayer(uint32 mapId, Player const* player) const +{ + MapEntry const* entry = sMapStore.LookupEntry(mapId); + if (!entry) + return 0; + + if (entry->IsBattlegroundOrArena()) + return player->GetBattlegroundId(); + else if (entry->IsDungeon()) + { + Group const* group = player->GetGroup(); + Difficulty difficulty = group ? group->GetDifficultyID(entry) : player->GetDifficultyID(entry); + MapDb2Entries entries{ entry, sDB2Manager.GetDownscaledMapDifficultyData(mapId, difficulty) }; + ObjectGuid instanceOwnerGuid = group ? group->GetRecentInstanceOwner(mapId) : player->GetGUID(); + InstanceLock* instanceLock = sInstanceLockMgr.FindActiveInstanceLock(instanceOwnerGuid, entries); + uint32 newInstanceId = 0; + if (instanceLock) + newInstanceId = instanceLock->GetInstanceId(); + else if (!entries.MapDifficulty->HasResetSchedule()) // Try finding instance id for normal dungeon + newInstanceId = group ? group->GetRecentInstanceId(mapId) : player->GetRecentInstanceId(mapId); + + if (!newInstanceId) + return 0; + + Map* map = FindMap(mapId, newInstanceId); + + // is is possible that instance id is already in use by another group for boss-based locks + if (!entries.IsInstanceIdBound() && instanceLock && map && map->ToInstanceMap()->GetInstanceLock() != instanceLock) + return 0; + + return newInstanceId; + } + else if (entry->IsGarrison()) + return uint32(player->GetGUID().GetCounter()); + else + { + if (entry->IsSplitByFaction()) + return player->GetTeamId(); + + return 0; + } +} + void MapManager::Update(uint32 diff) { i_timer.Update(diff); |