diff --git a/Source/Game/Globals/ObjectManager.cs b/Source/Game/Globals/ObjectManager.cs index 6b95059c1..ea35b6848 100644 --- a/Source/Game/Globals/ObjectManager.cs +++ b/Source/Game/Globals/ObjectManager.cs @@ -5294,7 +5294,7 @@ namespace Game { uint mapID = result.Read(0); - if (!Global.MapMgr.IsValidMAP(mapID, true)) + if (!Global.MapMgr.IsValidMAP(mapID)) { Log.outError(LogFilter.Sql, "ObjectMgr.LoadInstanceTemplate: bad mapid {0} for template!", mapID); continue; @@ -10549,8 +10549,7 @@ namespace Game } public AreaTriggerStruct GetGoBackTrigger(uint Map) { - bool useParentDbValue = false; - uint parentId = 0; + uint? parentId = null; MapRecord mapEntry = CliDB.MapStorage.LookupByKey(Map); if (mapEntry == null || mapEntry.CorpseMapID < 0) return null; @@ -10558,18 +10557,14 @@ namespace Game if (mapEntry.IsDungeon()) { InstanceTemplate iTemplate = GetInstanceTemplate(Map); - - if (iTemplate == null) - return null; - - parentId = iTemplate.Parent; - useParentDbValue = true; + if (iTemplate != null) + parentId = iTemplate.Parent; } - uint entrance_map = (uint)mapEntry.CorpseMapID; + uint entrance_map = parentId.GetValueOrDefault((uint)mapEntry.CorpseMapID); foreach (var pair in _areaTriggerStorage) { - if ((!useParentDbValue && pair.Value.target_mapId == entrance_map) || (useParentDbValue && pair.Value.target_mapId == parentId)) + if (pair.Value.target_mapId == entrance_map) { AreaTriggerRecord atEntry = CliDB.AreaTriggerStorage.LookupByKey(pair.Key); if (atEntry != null && atEntry.ContinentID == Map) diff --git a/Source/Game/Handlers/MovementHandler.cs b/Source/Game/Handlers/MovementHandler.cs index 48a21f131..40e4135b5 100644 --- a/Source/Game/Handlers/MovementHandler.cs +++ b/Source/Game/Handlers/MovementHandler.cs @@ -248,10 +248,9 @@ namespace Game // get the destination map entry, not the current one, this will fix homebind and reset greeting MapRecord mapEntry = CliDB.MapStorage.LookupByKey(loc.GetMapId()); - InstanceTemplate mInstance = Global.ObjectMgr.GetInstanceTemplate(loc.GetMapId()); // reset instance validity, except if going to an instance inside an instance - if (!player.m_InstanceValid && mInstance == null) + if (!player.m_InstanceValid && !mapEntry.IsDungeon()) player.m_InstanceValid = true; Map oldMap = player.GetMap(); @@ -375,7 +374,7 @@ namespace Game } } - if (mInstance != null) + if (mapEntry.IsDungeon()) { // check if this instance has a reset time and send it to player if so Difficulty diff = newMap.GetDifficultyID(); diff --git a/Source/Game/Maps/GridDefines.cs b/Source/Game/Maps/GridDefines.cs index 419c8a888..f70257ff2 100644 --- a/Source/Game/Maps/GridDefines.cs +++ b/Source/Game/Maps/GridDefines.cs @@ -45,17 +45,17 @@ namespace Game.Maps public static bool IsValidMapCoord(uint mapid, float x, float y) { - return Global.MapMgr.IsValidMAP(mapid, false) && IsValidMapCoord(x, y); + return Global.MapMgr.IsValidMAP(mapid) && IsValidMapCoord(x, y); } public static bool IsValidMapCoord(uint mapid, float x, float y, float z) { - return Global.MapMgr.IsValidMAP(mapid, false) && IsValidMapCoord(x, y, z); + return Global.MapMgr.IsValidMAP(mapid) && IsValidMapCoord(x, y, z); } public static bool IsValidMapCoord(uint mapid, float x, float y, float z, float o) { - return Global.MapMgr.IsValidMAP(mapid, false) && IsValidMapCoord(x, y, z, o); + return Global.MapMgr.IsValidMAP(mapid) && IsValidMapCoord(x, y, z, o); } public static bool IsValidMapCoord(uint mapid, Position pos) diff --git a/Source/Game/Maps/Instances/InstanceSaveManager.cs b/Source/Game/Maps/Instances/InstanceSaveManager.cs index 9b9cfa8d0..b18a7fbb1 100644 --- a/Source/Game/Maps/Instances/InstanceSaveManager.cs +++ b/Source/Game/Maps/Instances/InstanceSaveManager.cs @@ -696,11 +696,6 @@ namespace Game.Maps return GetResetTime(); } - InstanceTemplate GetTemplate() - { - return Global.ObjectMgr.GetInstanceTemplate(m_mapid); - } - MapRecord GetMapEntry() { return CliDB.MapStorage.LookupByKey(m_mapid); diff --git a/Source/Game/Maps/Instances/MapInstance.cs b/Source/Game/Maps/Instances/MapInstance.cs index e3719e8a6..11be403f7 100644 --- a/Source/Game/Maps/Instances/MapInstance.cs +++ b/Source/Game/Maps/Instances/MapInstance.cs @@ -184,12 +184,6 @@ namespace Game.Maps Log.outError(LogFilter.Maps, "CreateInstance: no record for map {0}", GetId()); Cypher.Assert(false); } - InstanceTemplate iTemplate = Global.ObjectMgr.GetInstanceTemplate(GetId()); - if (iTemplate == null) - { - Log.outError(LogFilter.Maps, "CreateInstance: no instance template for map {0}", GetId()); - Cypher.Assert(false); - } // some instances only have one difficulty Global.DB2Mgr.GetDownscaledMapDifficultyData(GetId(), ref difficulty); diff --git a/Source/Game/Maps/MapManager.cs b/Source/Game/Maps/MapManager.cs index a97e0b14d..5dd295cde 100644 --- a/Source/Game/Maps/MapManager.cs +++ b/Source/Game/Maps/MapManager.cs @@ -140,10 +140,6 @@ namespace Game.Entities if (!entry.IsDungeon()) return EnterState.CanEnter; - InstanceTemplate instance = Global.ObjectMgr.GetInstanceTemplate(mapid); - if (instance == null) - return EnterState.CannotEnterUninstancedDungeon; - Difficulty targetDifficulty = player.GetDifficultyID(entry); // Get the highest available difficulty if current setting is higher than the instance allows MapDifficultyRecord mapDiff = Global.DB2Mgr.GetDownscaledMapDifficultyData(entry.Id, ref targetDifficulty); @@ -254,16 +250,9 @@ namespace Game.Entities return Map.ExistMap(mapid, gx, gy) && Map.ExistVMap(mapid, gx, gy); } - public bool IsValidMAP(uint mapid, bool startUp) + public bool IsValidMAP(uint mapId) { - MapRecord mEntry = CliDB.MapStorage.LookupByKey(mapid); - - if (startUp) - return mEntry != null; - else - return mEntry != null && (!mEntry.IsDungeon() || Global.ObjectMgr.GetInstanceTemplate(mapid) != null); - - // TODO: add check for Battlegroundtemplate + return CliDB.MapStorage.ContainsKey(mapId); } public void UnloadAll() diff --git a/Source/Game/Spells/Spell.cs b/Source/Game/Spells/Spell.cs index 66a841a05..7ae046b50 100644 --- a/Source/Game/Spells/Spell.cs +++ b/Source/Game/Spells/Spell.cs @@ -5435,9 +5435,6 @@ namespace Game.Spells return SpellCastResult.TargetLockedToRaidInstance; } } - InstanceTemplate instance = Global.ObjectMgr.GetInstanceTemplate(mapId); - if (instance == null) - return SpellCastResult.TargetNotInInstance; if (!target.Satisfy(Global.ObjectMgr.GetAccessRequirement(mapId, difficulty), mapId)) return SpellCastResult.BadTargets; }