aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Conditions/DisableMgr.cpp
diff options
context:
space:
mode:
authorariel- <ariel-@users.noreply.github.com>2018-02-10 16:43:01 -0300
committerShauren <shauren.trinity@gmail.com>2021-08-28 15:59:11 +0200
commit962f6d7988b9003e550f6745be7cff812e9d8efa (patch)
treeee6ab5872b947afb00f4ca99e87c7dddea35bdb3 /src/server/game/Conditions/DisableMgr.cpp
parent65dca120d34febdaa84a63e17f638ab0fa59b3df (diff)
Core/Spells: rework part 5: GameObject casting
Closes #21330 Closes #18885 Ref #18752 (cherry picked from commit 45c5e1b9d63796d168339a44f63418f220cf2403)
Diffstat (limited to 'src/server/game/Conditions/DisableMgr.cpp')
-rw-r--r--src/server/game/Conditions/DisableMgr.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/server/game/Conditions/DisableMgr.cpp b/src/server/game/Conditions/DisableMgr.cpp
index e9a179eff46..1c1d9f4cb99 100644
--- a/src/server/game/Conditions/DisableMgr.cpp
+++ b/src/server/game/Conditions/DisableMgr.cpp
@@ -272,7 +272,7 @@ void CheckQuestDisables()
TC_LOG_INFO("server.loading", ">> Checked " SZFMTD " quest disables in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
}
-bool IsDisabledFor(DisableType type, uint32 entry, Unit const* unit, uint8 flags)
+bool IsDisabledFor(DisableType type, uint32 entry, WorldObject const* ref, uint8 flags /*= 0*/)
{
ASSERT(type < MAX_DISABLE_TYPES);
if (m_DisableMap[type].empty())
@@ -287,15 +287,16 @@ bool IsDisabledFor(DisableType type, uint32 entry, Unit const* unit, uint8 flags
case DISABLE_TYPE_SPELL:
{
uint8 spellFlags = itr->second.flags;
- if (unit)
+ if (ref)
{
- if ((spellFlags & SPELL_DISABLE_PLAYER && unit->GetTypeId() == TYPEID_PLAYER) ||
- (unit->GetTypeId() == TYPEID_UNIT && ((unit->IsPet() && spellFlags & SPELL_DISABLE_PET) || spellFlags & SPELL_DISABLE_CREATURE)))
+ if ((ref->GetTypeId() == TYPEID_PLAYER && (spellFlags & SPELL_DISABLE_PLAYER)) ||
+ (ref->GetTypeId() == TYPEID_UNIT && ((spellFlags & SPELL_DISABLE_CREATURE) || (ref->ToUnit()->IsPet() && (spellFlags & SPELL_DISABLE_PET)))) ||
+ (ref->GetTypeId() == TYPEID_GAMEOBJECT && (spellFlags & SPELL_DISABLE_GAMEOBJECT)))
{
if (spellFlags & SPELL_DISABLE_MAP)
{
std::unordered_set<uint32> const& mapIds = itr->second.params[0];
- if (mapIds.find(unit->GetMapId()) != mapIds.end())
+ if (mapIds.find(ref->GetMapId()) != mapIds.end())
return true; // Spell is disabled on current map
if (!(spellFlags & SPELL_DISABLE_AREA))
@@ -307,7 +308,7 @@ bool IsDisabledFor(DisableType type, uint32 entry, Unit const* unit, uint8 flags
if (spellFlags & SPELL_DISABLE_AREA)
{
std::unordered_set<uint32> const& areaIds = itr->second.params[1];
- if (areaIds.find(unit->GetAreaId()) != areaIds.end())
+ if (areaIds.find(ref->GetAreaId()) != areaIds.end())
return true; // Spell is disabled in this area
return false; // Spell is disabled in another area, but not this one, return false
}
@@ -326,7 +327,7 @@ bool IsDisabledFor(DisableType type, uint32 entry, Unit const* unit, uint8 flags
}
case DISABLE_TYPE_MAP:
case DISABLE_TYPE_LFG_MAP:
- if (Player const* player = unit->ToPlayer())
+ if (Player const* player = ref->ToPlayer())
{
MapEntry const* mapEntry = sMapStore.LookupEntry(entry);
if (mapEntry->IsDungeon())
@@ -353,9 +354,9 @@ bool IsDisabledFor(DisableType type, uint32 entry, Unit const* unit, uint8 flags
}
return false;
case DISABLE_TYPE_QUEST:
- if (!unit)
+ if (!ref)
return true;
- if (Player const* player = unit->ToPlayer())
+ if (Player const* player = ref->ToPlayer())
if (player->IsGameMaster())
return false;
return true;