aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Spells/Spell.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/game/Spells/Spell.cpp')
-rw-r--r--src/server/game/Spells/Spell.cpp16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index 8e29980fe83..4b2a8cb63a4 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -34,6 +34,7 @@
#include "GameObjectAI.h"
#include "GridNotifiersImpl.h"
#include "Guild.h"
+#include "InstanceLockMgr.h"
#include "InstanceScript.h"
#include "Item.h"
#include "Log.h"
@@ -6219,16 +6220,13 @@ SpellCastResult Spell::CheckCast(bool strict, int32* param1 /*= nullptr*/, int32
return SPELL_FAILED_SUMMON_PENDING;
// check if our map is dungeon
- MapEntry const* map = sMapStore.LookupEntry(m_caster->GetMapId());
- if (map->IsDungeon())
+ if (InstanceMap const* map = m_caster->GetMap()->ToInstanceMap())
{
- uint32 mapId = m_caster->GetMap()->GetId();
- Difficulty difficulty = m_caster->GetMap()->GetDifficultyID();
- if (map->IsRaid())
- if (InstancePlayerBind* targetBind = target->GetBoundInstance(mapId, difficulty))
- if (InstancePlayerBind* casterBind = m_caster->ToPlayer()->GetBoundInstance(mapId, difficulty))
- if (targetBind->perm && targetBind->save != casterBind->save)
- return SPELL_FAILED_TARGET_LOCKED_TO_RAID_INSTANCE;
+ uint32 mapId = map->GetId();
+ Difficulty difficulty = map->GetDifficultyID();
+ if (InstanceLock const* mapLock = map->GetInstanceLock())
+ if (sInstanceLockMgr.CanJoinInstanceLock(target->GetGUID(), { mapId, difficulty }, mapLock) != TRANSFER_ABORT_NONE)
+ return SPELL_FAILED_TARGET_LOCKED_TO_RAID_INSTANCE;
if (!target->Satisfy(sObjectMgr->GetAccessRequirement(mapId, difficulty), mapId))
return SPELL_FAILED_BAD_TARGETS;