aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Conditions
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
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')
-rw-r--r--src/server/game/Conditions/DisableMgr.cpp19
-rw-r--r--src/server/game/Conditions/DisableMgr.h15
2 files changed, 18 insertions, 16 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;
diff --git a/src/server/game/Conditions/DisableMgr.h b/src/server/game/Conditions/DisableMgr.h
index 8e0ce34f8ae..75681945e33 100644
--- a/src/server/game/Conditions/DisableMgr.h
+++ b/src/server/game/Conditions/DisableMgr.h
@@ -20,7 +20,7 @@
#include "Define.h"
-class Unit;
+class WorldObject;
enum DisableType
{
@@ -39,16 +39,17 @@ enum DisableType
enum SpellDisableTypes
{
- SPELL_DISABLE_PLAYER = 0x1,
- SPELL_DISABLE_CREATURE = 0x2,
- SPELL_DISABLE_PET = 0x4,
- SPELL_DISABLE_DEPRECATED_SPELL = 0x8,
+ SPELL_DISABLE_PLAYER = 0x01,
+ SPELL_DISABLE_CREATURE = 0x02,
+ SPELL_DISABLE_PET = 0x04,
+ SPELL_DISABLE_DEPRECATED_SPELL = 0x08,
SPELL_DISABLE_MAP = 0x10,
SPELL_DISABLE_AREA = 0x20,
SPELL_DISABLE_LOS = 0x40,
+ SPELL_DISABLE_GAMEOBJECT = 0x80,
MAX_SPELL_DISABLE_TYPE = ( SPELL_DISABLE_PLAYER | SPELL_DISABLE_CREATURE | SPELL_DISABLE_PET |
SPELL_DISABLE_DEPRECATED_SPELL | SPELL_DISABLE_MAP | SPELL_DISABLE_AREA |
- SPELL_DISABLE_LOS)
+ SPELL_DISABLE_LOS | SPELL_DISABLE_GAMEOBJECT )
};
enum MMapDisableTypes
@@ -59,7 +60,7 @@ enum MMapDisableTypes
namespace DisableMgr
{
TC_GAME_API void LoadDisables();
- TC_GAME_API bool IsDisabledFor(DisableType type, uint32 entry, Unit const* unit, uint8 flags = 0);
+ TC_GAME_API bool IsDisabledFor(DisableType type, uint32 entry, WorldObject const* ref, uint8 flags = 0);
TC_GAME_API void CheckQuestDisables();
TC_GAME_API bool IsVMAPDisabledFor(uint32 entry, uint8 flags);
TC_GAME_API bool IsPathfindingEnabled(uint32 mapId);