aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoschiwald <joschiwald.trinity@gmail.com>2017-01-04 00:08:52 +0100
committerjoschiwald <joschiwald.trinity@gmail.com>2017-01-04 00:08:52 +0100
commitfc22e97369b04b3c900d42dab66cf40f5f7eaa08 (patch)
treeb9fe150a1724b0a0a4b74e1960e4054b333e2a8f
parentd0b9521954d61edb2c16cf2da211cf623a2d5dd5 (diff)
Core/SpellScripts: Added some const correctness
-rw-r--r--src/common/Utilities/Util.h13
-rw-r--r--src/server/game/Spells/SpellScript.cpp212
-rw-r--r--src/server/game/Spells/SpellScript.h78
3 files changed, 156 insertions, 147 deletions
diff --git a/src/common/Utilities/Util.h b/src/common/Utilities/Util.h
index 23227ff21e8..d42d0314d76 100644
--- a/src/common/Utilities/Util.h
+++ b/src/common/Utilities/Util.h
@@ -335,6 +335,7 @@ class HookList final
ContainerType _container;
public:
+ typedef typename ContainerType::const_iterator const_iterator;
typedef typename ContainerType::iterator iterator;
HookList<T>& operator+=(T t)
@@ -343,7 +344,7 @@ class HookList final
return *this;
}
- size_t size()
+ size_t size() const
{
return _container.size();
}
@@ -357,6 +358,16 @@ class HookList final
{
return _container.end();
}
+
+ const_iterator begin() const
+ {
+ return _container.begin();
+ }
+
+ const_iterator end() const
+ {
+ return _container.end();
+ }
};
class TC_COMMON_API flag128
diff --git a/src/server/game/Spells/SpellScript.cpp b/src/server/game/Spells/SpellScript.cpp
index ef04c0b33ae..c50043fd2dd 100644
--- a/src/server/game/Spells/SpellScript.cpp
+++ b/src/server/game/Spells/SpellScript.cpp
@@ -71,7 +71,7 @@ _SpellScript::EffectHook::EffectHook(uint8 _effIndex)
effIndex = _effIndex;
}
-uint32 _SpellScript::EffectHook::GetAffectedEffectsMask(SpellInfo const* spellEntry)
+uint32 _SpellScript::EffectHook::GetAffectedEffectsMask(SpellInfo const* spellEntry) const
{
uint32 mask = 0;
if ((effIndex == EFFECT_ALL) || (effIndex == EFFECT_FIRST_FOUND))
@@ -92,12 +92,12 @@ uint32 _SpellScript::EffectHook::GetAffectedEffectsMask(SpellInfo const* spellEn
return mask;
}
-bool _SpellScript::EffectHook::IsEffectAffected(SpellInfo const* spellEntry, uint8 effIndexToCheck)
+bool _SpellScript::EffectHook::IsEffectAffected(SpellInfo const* spellEntry, uint8 effIndexToCheck) const
{
return (GetAffectedEffectsMask(spellEntry) & 1 << effIndexToCheck) != 0;
}
-std::string _SpellScript::EffectHook::EffIndexToString()
+std::string _SpellScript::EffectHook::EffIndexToString() const
{
switch (effIndex)
{
@@ -115,7 +115,7 @@ std::string _SpellScript::EffectHook::EffIndexToString()
return "Invalid Value";
}
-bool _SpellScript::EffectNameCheck::Check(SpellInfo const* spellEntry, uint8 effIndex)
+bool _SpellScript::EffectNameCheck::Check(SpellInfo const* spellEntry, uint8 effIndex) const
{
SpellEffectInfo const* effect = spellEntry->GetEffect(effIndex);
if (!effect)
@@ -127,7 +127,7 @@ bool _SpellScript::EffectNameCheck::Check(SpellInfo const* spellEntry, uint8 eff
return (effName == SPELL_EFFECT_ANY) || (effect->Effect == effName);
}
-std::string _SpellScript::EffectNameCheck::ToString()
+std::string _SpellScript::EffectNameCheck::ToString() const
{
switch (effName)
{
@@ -140,7 +140,7 @@ std::string _SpellScript::EffectNameCheck::ToString()
}
}
-bool _SpellScript::EffectAuraNameCheck::Check(SpellInfo const* spellEntry, uint8 effIndex)
+bool _SpellScript::EffectAuraNameCheck::Check(SpellInfo const* spellEntry, uint8 effIndex) const
{
SpellEffectInfo const* effect = spellEntry->GetEffect(effIndex);
if (!effect)
@@ -152,7 +152,7 @@ bool _SpellScript::EffectAuraNameCheck::Check(SpellInfo const* spellEntry, uint8
return (effAurName == SPELL_AURA_ANY) || (effect->ApplyAuraName == effAurName);
}
-std::string _SpellScript::EffectAuraNameCheck::ToString()
+std::string _SpellScript::EffectAuraNameCheck::ToString() const
{
switch (effAurName)
{
@@ -191,12 +191,12 @@ SpellScript::EffectHandler::EffectHandler(SpellEffectFnType _pEffectHandlerScrip
pEffectHandlerScript = _pEffectHandlerScript;
}
-std::string SpellScript::EffectHandler::ToString()
+std::string SpellScript::EffectHandler::ToString() const
{
return "Index: " + EffIndexToString() + " Name: " +_SpellScript::EffectNameCheck::ToString();
}
-bool SpellScript::EffectHandler::CheckEffect(SpellInfo const* spellEntry, uint8 effIndexToCheck)
+bool SpellScript::EffectHandler::CheckEffect(SpellInfo const* spellEntry, uint8 effIndexToCheck) const
{
return _SpellScript::EffectNameCheck::Check(spellEntry, effIndexToCheck);
}
@@ -229,14 +229,14 @@ void SpellScript::HitHandler::Call(SpellScript* spellScript)
SpellScript::TargetHook::TargetHook(uint8 _effectIndex, uint16 _targetType, bool _area, bool _dest)
: _SpellScript::EffectHook(_effectIndex), targetType(_targetType), area(_area), dest(_dest) { }
-std::string SpellScript::TargetHook::ToString()
+std::string SpellScript::TargetHook::ToString() const
{
std::ostringstream oss;
oss << "Index: " << EffIndexToString() << " Target: " << targetType;
return oss.str();
}
-bool SpellScript::TargetHook::CheckEffect(SpellInfo const* spellEntry, uint8 effIndexToCheck)
+bool SpellScript::TargetHook::CheckEffect(SpellInfo const* spellEntry, uint8 effIndexToCheck) const
{
if (!targetType)
return false;
@@ -322,35 +322,35 @@ void SpellScript::DestinationTargetSelectHandler::Call(SpellScript* spellScript,
bool SpellScript::_Validate(SpellInfo const* entry)
{
for (auto itr = OnEffectLaunch.begin(); itr != OnEffectLaunch.end(); ++itr)
- if (!(*itr).GetAffectedEffectsMask(entry))
+ if (!itr->GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnEffectLaunch` of SpellScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
for (auto itr = OnEffectLaunchTarget.begin(); itr != OnEffectLaunchTarget.end(); ++itr)
- if (!(*itr).GetAffectedEffectsMask(entry))
+ if (!itr->GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnEffectLaunchTarget` of SpellScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
for (auto itr = OnEffectHit.begin(); itr != OnEffectHit.end(); ++itr)
- if (!(*itr).GetAffectedEffectsMask(entry))
+ if (!itr->GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnEffectHit` of SpellScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
for (auto itr = OnEffectHitTarget.begin(); itr != OnEffectHitTarget.end(); ++itr)
- if (!(*itr).GetAffectedEffectsMask(entry))
+ if (!itr->GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnEffectHitTarget` of SpellScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
for (auto itr = OnEffectSuccessfulDispel.begin(); itr != OnEffectSuccessfulDispel.end(); ++itr)
- if (!(*itr).GetAffectedEffectsMask(entry))
+ if (!itr->GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnEffectSuccessfulDispel` of SpellScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
for (auto itr = OnObjectAreaTargetSelect.begin(); itr != OnObjectAreaTargetSelect.end(); ++itr)
- if (!(*itr).GetAffectedEffectsMask(entry))
+ if (!itr->GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnObjectAreaTargetSelect` of SpellScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
for (auto itr = OnObjectTargetSelect.begin(); itr != OnObjectTargetSelect.end(); ++itr)
- if (!(*itr).GetAffectedEffectsMask(entry))
+ if (!itr->GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnObjectTargetSelect` of SpellScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
for (auto itr = OnDestinationTargetSelect.begin(); itr != OnDestinationTargetSelect.end(); ++itr)
- if (!(*itr).GetAffectedEffectsMask(entry))
+ if (!itr->GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnDestinationTargetSelect` of SpellScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
return _SpellScript::_Validate(entry);
@@ -408,26 +408,26 @@ bool SpellScript::IsInEffectHook() const
return (m_currentScriptState >= SPELL_SCRIPT_HOOK_EFFECT_LAUNCH && m_currentScriptState <= SPELL_SCRIPT_HOOK_EFFECT_HIT_TARGET);
}
-Unit* SpellScript::GetCaster()
+Unit* SpellScript::GetCaster() const
{
return m_spell->GetCaster();
}
-Unit* SpellScript::GetOriginalCaster()
+Unit* SpellScript::GetOriginalCaster() const
{
return m_spell->GetOriginalCaster();
}
-SpellInfo const* SpellScript::GetSpellInfo()
+SpellInfo const* SpellScript::GetSpellInfo() const
{
return m_spell->GetSpellInfo();
}
-WorldLocation const* SpellScript::GetExplTargetDest()
+WorldLocation const* SpellScript::GetExplTargetDest() const
{
if (m_spell->m_targets.HasDst())
return m_spell->m_targets.GetDstPos();
- return NULL;
+ return nullptr;
}
void SpellScript::SetExplTargetDest(WorldLocation& loc)
@@ -435,93 +435,91 @@ void SpellScript::SetExplTargetDest(WorldLocation& loc)
m_spell->m_targets.SetDst(loc);
}
-WorldObject* SpellScript::GetExplTargetWorldObject()
+WorldObject* SpellScript::GetExplTargetWorldObject() const
{
return m_spell->m_targets.GetObjectTarget();
}
-Unit* SpellScript::GetExplTargetUnit()
+Unit* SpellScript::GetExplTargetUnit() const
{
return m_spell->m_targets.GetUnitTarget();
}
-GameObject* SpellScript::GetExplTargetGObj()
+GameObject* SpellScript::GetExplTargetGObj() const
{
return m_spell->m_targets.GetGOTarget();
}
-Item* SpellScript::GetExplTargetItem()
+Item* SpellScript::GetExplTargetItem() const
{
return m_spell->m_targets.GetItemTarget();
}
-Unit* SpellScript::GetHitUnit()
+Unit* SpellScript::GetHitUnit() const
{
if (!IsInTargetHook())
{
TC_LOG_ERROR("scripts", "Script: `%s` Spell: `%u`: function SpellScript::GetHitUnit was called, but function has no effect in current hook!", m_scriptName->c_str(), m_scriptSpellId);
- return NULL;
+ return nullptr;
}
return m_spell->unitTarget;
}
-Creature* SpellScript::GetHitCreature()
+Creature* SpellScript::GetHitCreature() const
{
if (!IsInTargetHook())
{
TC_LOG_ERROR("scripts", "Script: `%s` Spell: `%u`: function SpellScript::GetHitCreature was called, but function has no effect in current hook!", m_scriptName->c_str(), m_scriptSpellId);
- return NULL;
+ return nullptr;
}
if (m_spell->unitTarget)
return m_spell->unitTarget->ToCreature();
- else
- return NULL;
+ return nullptr;
}
-Player* SpellScript::GetHitPlayer()
+Player* SpellScript::GetHitPlayer() const
{
if (!IsInTargetHook())
{
TC_LOG_ERROR("scripts", "Script: `%s` Spell: `%u`: function SpellScript::GetHitPlayer was called, but function has no effect in current hook!", m_scriptName->c_str(), m_scriptSpellId);
- return NULL;
+ return nullptr;
}
if (m_spell->unitTarget)
return m_spell->unitTarget->ToPlayer();
- else
- return NULL;
+ return nullptr;
}
-Item* SpellScript::GetHitItem()
+Item* SpellScript::GetHitItem() const
{
if (!IsInTargetHook())
{
TC_LOG_ERROR("scripts", "Script: `%s` Spell: `%u`: function SpellScript::GetHitItem was called, but function has no effect in current hook!", m_scriptName->c_str(), m_scriptSpellId);
- return NULL;
+ return nullptr;
}
return m_spell->itemTarget;
}
-GameObject* SpellScript::GetHitGObj()
+GameObject* SpellScript::GetHitGObj() const
{
if (!IsInTargetHook())
{
TC_LOG_ERROR("scripts", "Script: `%s` Spell: `%u`: function SpellScript::GetHitGObj was called, but function has no effect in current hook!", m_scriptName->c_str(), m_scriptSpellId);
- return NULL;
+ return nullptr;
}
return m_spell->gameObjTarget;
}
-WorldLocation* SpellScript::GetHitDest()
+WorldLocation* SpellScript::GetHitDest() const
{
if (!IsInEffectHook())
{
TC_LOG_ERROR("scripts", "Script: `%s` Spell: `%u`: function SpellScript::GetHitDest was called, but function has no effect in current hook!", m_scriptName->c_str(), m_scriptSpellId);
- return NULL;
+ return nullptr;
}
return m_spell->destTarget;
}
-int32 SpellScript::GetHitDamage()
+int32 SpellScript::GetHitDamage() const
{
if (!IsInTargetHook())
{
@@ -541,7 +539,7 @@ void SpellScript::SetHitDamage(int32 damage)
m_spell->m_damage = damage;
}
-int32 SpellScript::GetHitHeal()
+int32 SpellScript::GetHitHeal() const
{
if (!IsInTargetHook())
{
@@ -561,17 +559,17 @@ void SpellScript::SetHitHeal(int32 heal)
m_spell->m_healing = heal;
}
-Aura* SpellScript::GetHitAura()
+Aura* SpellScript::GetHitAura() const
{
if (!IsInTargetHook())
{
TC_LOG_ERROR("scripts", "Script: `%s` Spell: `%u`: function SpellScript::GetHitAura was called, but function has no effect in current hook!", m_scriptName->c_str(), m_scriptSpellId);
- return NULL;
+ return nullptr;
}
if (!m_spell->m_spellAura)
- return NULL;
+ return nullptr;
if (m_spell->m_spellAura->IsRemoved())
- return NULL;
+ return nullptr;
return m_spell->m_spellAura;
}
@@ -636,7 +634,7 @@ void SpellScript::SetEffectValue(int32 value)
m_spell->damage = value;
}
-Item* SpellScript::GetCastItem()
+Item* SpellScript::GetCastItem() const
{
return m_spell->m_CastItem;
}
@@ -646,7 +644,7 @@ void SpellScript::CreateItem(uint32 effIndex, uint32 itemId)
m_spell->DoCreateItem(effIndex, itemId);
}
-SpellInfo const* SpellScript::GetTriggeringSpell()
+SpellInfo const* SpellScript::GetTriggeringSpell() const
{
return m_spell->m_triggeredByAuraSpell;
}
@@ -668,7 +666,7 @@ void SpellScript::SetCustomCastResultMessage(SpellCustomErrors result)
m_spell->m_customError = result;
}
-SpellValue const* SpellScript::GetSpellValue()
+SpellValue const* SpellScript::GetSpellValue() const
{
return m_spell->m_spellValue;
}
@@ -680,73 +678,73 @@ SpellEffectInfo const* SpellScript::GetEffectInfo(SpellEffIndex effIndex) const
bool AuraScript::_Validate(SpellInfo const* entry)
{
- for (auto itr = DoCheckAreaTarget.begin(); itr != DoCheckAreaTarget.end(); ++itr)
+ for (auto itr = DoCheckAreaTarget.begin(); itr != DoCheckAreaTarget.end(); ++itr)
if (!entry->HasAreaAuraEffect() && !entry->HasEffect(SPELL_EFFECT_PERSISTENT_AREA_AURA) && !entry->HasEffect(SPELL_EFFECT_APPLY_AURA))
TC_LOG_ERROR("scripts", "Spell `%u` of script `%s` does not have apply aura effect - handler bound to hook `DoCheckAreaTarget` of AuraScript won't be executed", entry->Id, m_scriptName->c_str());
- for (auto itr = OnDispel.begin(); itr != OnDispel.end(); ++itr)
+ for (auto itr = OnDispel.begin(); itr != OnDispel.end(); ++itr)
if (!entry->HasEffect(SPELL_EFFECT_APPLY_AURA) && !entry->HasAreaAuraEffect())
TC_LOG_ERROR("scripts", "Spell `%u` of script `%s` does not have apply aura effect - handler bound to hook `OnDispel` of AuraScript won't be executed", entry->Id, m_scriptName->c_str());
- for (auto itr = AfterDispel.begin(); itr != AfterDispel.end(); ++itr)
+ for (auto itr = AfterDispel.begin(); itr != AfterDispel.end(); ++itr)
if (!entry->HasEffect(SPELL_EFFECT_APPLY_AURA) && !entry->HasAreaAuraEffect())
TC_LOG_ERROR("scripts", "Spell `%u` of script `%s` does not have apply aura effect - handler bound to hook `AfterDispel` of AuraScript won't be executed", entry->Id, m_scriptName->c_str());
- for (auto itr = OnEffectApply.begin(); itr != OnEffectApply.end(); ++itr)
- if (!(*itr).GetAffectedEffectsMask(entry))
- TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnEffectApply` of AuraScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
+ for (auto itr = OnEffectApply.begin(); itr != OnEffectApply.end(); ++itr)
+ if (!itr->GetAffectedEffectsMask(entry))
+ TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnEffectApply` of AuraScript won't be executed", entry->Id, itr->ToString().c_str(), m_scriptName->c_str());
- for (auto itr = OnEffectRemove.begin(); itr != OnEffectRemove.end(); ++itr)
- if (!(*itr).GetAffectedEffectsMask(entry))
- TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnEffectRemove` of AuraScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
+ for (auto itr = OnEffectRemove.begin(); itr != OnEffectRemove.end(); ++itr)
+ if (!itr->GetAffectedEffectsMask(entry))
+ TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnEffectRemove` of AuraScript won't be executed", entry->Id, itr->ToString().c_str(), m_scriptName->c_str());
- for (auto itr = AfterEffectApply.begin(); itr != AfterEffectApply.end(); ++itr)
- if (!(*itr).GetAffectedEffectsMask(entry))
- TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `AfterEffectApply` of AuraScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
+ for (auto itr = AfterEffectApply.begin(); itr != AfterEffectApply.end(); ++itr)
+ if (!itr->GetAffectedEffectsMask(entry))
+ TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `AfterEffectApply` of AuraScript won't be executed", entry->Id, itr->ToString().c_str(), m_scriptName->c_str());
- for (auto itr = AfterEffectRemove.begin(); itr != AfterEffectRemove.end(); ++itr)
- if (!(*itr).GetAffectedEffectsMask(entry))
- TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `AfterEffectRemove` of AuraScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
+ for (auto itr = AfterEffectRemove.begin(); itr != AfterEffectRemove.end(); ++itr)
+ if (!itr->GetAffectedEffectsMask(entry))
+ TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `AfterEffectRemove` of AuraScript won't be executed", entry->Id, itr->ToString().c_str(), m_scriptName->c_str());
- for (auto itr = OnEffectPeriodic.begin(); itr != OnEffectPeriodic.end(); ++itr)
- if (!(*itr).GetAffectedEffectsMask(entry))
- TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnEffectPeriodic` of AuraScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
+ for (auto itr = OnEffectPeriodic.begin(); itr != OnEffectPeriodic.end(); ++itr)
+ if (!itr->GetAffectedEffectsMask(entry))
+ TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnEffectPeriodic` of AuraScript won't be executed", entry->Id, itr->ToString().c_str(), m_scriptName->c_str());
- for (auto itr = OnEffectUpdatePeriodic.begin(); itr != OnEffectUpdatePeriodic.end(); ++itr)
- if (!(*itr).GetAffectedEffectsMask(entry))
- TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnEffectUpdatePeriodic` of AuraScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
+ for (auto itr = OnEffectUpdatePeriodic.begin(); itr != OnEffectUpdatePeriodic.end(); ++itr)
+ if (!itr->GetAffectedEffectsMask(entry))
+ TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnEffectUpdatePeriodic` of AuraScript won't be executed", entry->Id, itr->ToString().c_str(), m_scriptName->c_str());
- for (auto itr = DoEffectCalcAmount.begin(); itr != DoEffectCalcAmount.end(); ++itr)
- if (!(*itr).GetAffectedEffectsMask(entry))
- TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `DoEffectCalcAmount` of AuraScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
+ for (auto itr = DoEffectCalcAmount.begin(); itr != DoEffectCalcAmount.end(); ++itr)
+ if (!itr->GetAffectedEffectsMask(entry))
+ TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `DoEffectCalcAmount` of AuraScript won't be executed", entry->Id, itr->ToString().c_str(), m_scriptName->c_str());
- for (auto itr = DoEffectCalcPeriodic.begin(); itr != DoEffectCalcPeriodic.end(); ++itr)
- if (!(*itr).GetAffectedEffectsMask(entry))
- TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `DoEffectCalcPeriodic` of AuraScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
+ for (auto itr = DoEffectCalcPeriodic.begin(); itr != DoEffectCalcPeriodic.end(); ++itr)
+ if (!itr->GetAffectedEffectsMask(entry))
+ TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `DoEffectCalcPeriodic` of AuraScript won't be executed", entry->Id, itr->ToString().c_str(), m_scriptName->c_str());
- for (auto itr = DoEffectCalcSpellMod.begin(); itr != DoEffectCalcSpellMod.end(); ++itr)
- if (!(*itr).GetAffectedEffectsMask(entry))
- TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `DoEffectCalcSpellMod` of AuraScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
+ for (auto itr = DoEffectCalcSpellMod.begin(); itr != DoEffectCalcSpellMod.end(); ++itr)
+ if (!itr->GetAffectedEffectsMask(entry))
+ TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `DoEffectCalcSpellMod` of AuraScript won't be executed", entry->Id, itr->ToString().c_str(), m_scriptName->c_str());
- for (auto itr = OnEffectAbsorb.begin(); itr != OnEffectAbsorb.end(); ++itr)
- if (!(*itr).GetAffectedEffectsMask(entry))
- TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnEffectAbsorb` of AuraScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
+ for (auto itr = OnEffectAbsorb.begin(); itr != OnEffectAbsorb.end(); ++itr)
+ if (!itr->GetAffectedEffectsMask(entry))
+ TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnEffectAbsorb` of AuraScript won't be executed", entry->Id, itr->ToString().c_str(), m_scriptName->c_str());
- for (auto itr = AfterEffectAbsorb.begin(); itr != AfterEffectAbsorb.end(); ++itr)
- if (!(*itr).GetAffectedEffectsMask(entry))
- TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `AfterEffectAbsorb` of AuraScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
+ for (auto itr = AfterEffectAbsorb.begin(); itr != AfterEffectAbsorb.end(); ++itr)
+ if (!itr->GetAffectedEffectsMask(entry))
+ TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `AfterEffectAbsorb` of AuraScript won't be executed", entry->Id, itr->ToString().c_str(), m_scriptName->c_str());
- for (auto itr = OnEffectManaShield.begin(); itr != OnEffectManaShield.end(); ++itr)
- if (!(*itr).GetAffectedEffectsMask(entry))
- TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnEffectManaShield` of AuraScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
+ for (auto itr = OnEffectManaShield.begin(); itr != OnEffectManaShield.end(); ++itr)
+ if (!itr->GetAffectedEffectsMask(entry))
+ TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnEffectManaShield` of AuraScript won't be executed", entry->Id, itr->ToString().c_str(), m_scriptName->c_str());
- for (auto itr = AfterEffectManaShield.begin(); itr != AfterEffectManaShield.end(); ++itr)
- if (!(*itr).GetAffectedEffectsMask(entry))
- TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `AfterEffectManaShield` of AuraScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
+ for (auto itr = AfterEffectManaShield.begin(); itr != AfterEffectManaShield.end(); ++itr)
+ if (!itr->GetAffectedEffectsMask(entry))
+ TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `AfterEffectManaShield` of AuraScript won't be executed", entry->Id, itr->ToString().c_str(), m_scriptName->c_str());
- for (auto itr = OnEffectSplit.begin(); itr != OnEffectSplit.end(); ++itr)
- if (!(*itr).GetAffectedEffectsMask(entry))
- TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnEffectSplit` of AuraScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
+ for (auto itr = OnEffectSplit.begin(); itr != OnEffectSplit.end(); ++itr)
+ if (!itr->GetAffectedEffectsMask(entry))
+ TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnEffectSplit` of AuraScript won't be executed", entry->Id, itr->ToString().c_str(), m_scriptName->c_str());
for (auto itr = DoCheckProc.begin(); itr != DoCheckProc.end(); ++itr)
if (!entry->HasEffect(SPELL_EFFECT_APPLY_AURA) && !entry->HasAreaAuraEffect())
@@ -765,12 +763,12 @@ bool AuraScript::_Validate(SpellInfo const* entry)
TC_LOG_ERROR("scripts", "Spell `%u` of script `%s` does not have apply aura effect - handler bound to hook `AfterProc` of AuraScript won't be executed", entry->Id, m_scriptName->c_str());
for (auto itr = OnEffectProc.begin(); itr != OnEffectProc.end(); ++itr)
- if (!(*itr).GetAffectedEffectsMask(entry))
- TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnEffectProc` of AuraScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
+ if (!itr->GetAffectedEffectsMask(entry))
+ TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnEffectProc` of AuraScript won't be executed", entry->Id, itr->ToString().c_str(), m_scriptName->c_str());
for (auto itr = AfterEffectProc.begin(); itr != AfterEffectProc.end(); ++itr)
- if (!(*itr).GetAffectedEffectsMask(entry))
- TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `AfterEffectProc` of AuraScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
+ if (!itr->GetAffectedEffectsMask(entry))
+ TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `AfterEffectProc` of AuraScript won't be executed", entry->Id, itr->ToString().c_str(), m_scriptName->c_str());
return _SpellScript::_Validate(entry);
}
@@ -798,12 +796,12 @@ void AuraScript::AuraDispelHandler::Call(AuraScript* auraScript, DispelInfo* _di
AuraScript::EffectBase::EffectBase(uint8 _effIndex, uint16 _effName)
: _SpellScript::EffectAuraNameCheck(_effName), _SpellScript::EffectHook(_effIndex) { }
-bool AuraScript::EffectBase::CheckEffect(SpellInfo const* spellEntry, uint8 effIndexToCheck)
+bool AuraScript::EffectBase::CheckEffect(SpellInfo const* spellEntry, uint8 effIndexToCheck) const
{
return _SpellScript::EffectAuraNameCheck::Check(spellEntry, effIndexToCheck);
}
-std::string AuraScript::EffectBase::ToString()
+std::string AuraScript::EffectBase::ToString() const
{
return "Index: " + EffIndexToString() + " AuraName: " +_SpellScript::EffectAuraNameCheck::ToString();
}
@@ -943,7 +941,7 @@ void AuraScript::EffectProcHandler::Call(AuraScript* auraScript, AuraEffect cons
bool AuraScript::_Load(Aura* aura)
{
m_aura = aura;
- _PrepareScriptCall((AuraScriptHookType)SPELL_SCRIPT_STATE_LOADING, NULL);
+ _PrepareScriptCall((AuraScriptHookType)SPELL_SCRIPT_STATE_LOADING, nullptr);
bool load = Load();
_FinishScriptCall();
return load;
@@ -966,7 +964,7 @@ void AuraScript::_FinishScriptCall()
m_scriptStates.pop();
}
-bool AuraScript::_IsDefaultActionPrevented()
+bool AuraScript::_IsDefaultActionPrevented() const
{
switch (m_currentScriptState)
{
@@ -1190,7 +1188,7 @@ Unit* AuraScript::GetTarget() const
TC_LOG_ERROR("scripts", "Script: `%s` Spell: `%u` AuraScript::GetTarget called in a hook in which the call won't have effect!", m_scriptName->c_str(), m_scriptSpellId);
}
- return NULL;
+ return nullptr;
}
AuraApplication const* AuraScript::GetTargetApplication() const
diff --git a/src/server/game/Spells/SpellScript.h b/src/server/game/Spells/SpellScript.h
index e9ed5162b14..0f7d78f292b 100644
--- a/src/server/game/Spells/SpellScript.h
+++ b/src/server/game/Spells/SpellScript.h
@@ -75,10 +75,10 @@ class TC_GAME_API _SpellScript
EffectHook(uint8 _effIndex);
virtual ~EffectHook() { }
- uint32 GetAffectedEffectsMask(SpellInfo const* spellInfo);
- bool IsEffectAffected(SpellInfo const* spellInfo, uint8 effIndex);
- virtual bool CheckEffect(SpellInfo const* spellInfo, uint8 effIndex) = 0;
- std::string EffIndexToString();
+ uint32 GetAffectedEffectsMask(SpellInfo const* spellInfo) const;
+ bool IsEffectAffected(SpellInfo const* spellInfo, uint8 effIndex) const;
+ virtual bool CheckEffect(SpellInfo const* spellInfo, uint8 effIndex) const = 0;
+ std::string EffIndexToString() const;
protected:
uint8 effIndex;
};
@@ -87,8 +87,8 @@ class TC_GAME_API _SpellScript
{
public:
EffectNameCheck(uint16 _effName) { effName = _effName; }
- bool Check(SpellInfo const* spellInfo, uint8 effIndex);
- std::string ToString();
+ bool Check(SpellInfo const* spellInfo, uint8 effIndex) const;
+ std::string ToString() const;
private:
uint16 effName;
};
@@ -97,8 +97,8 @@ class TC_GAME_API _SpellScript
{
public:
EffectAuraNameCheck(uint16 _effAurName) { effAurName = _effAurName; }
- bool Check(SpellInfo const* spellInfo, uint8 effIndex);
- std::string ToString();
+ bool Check(SpellInfo const* spellInfo, uint8 effIndex) const;
+ std::string ToString() const;
private:
uint16 effAurName;
};
@@ -199,8 +199,8 @@ class TC_GAME_API SpellScript : public _SpellScript
{
public:
EffectHandler(SpellEffectFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName);
- std::string ToString();
- bool CheckEffect(SpellInfo const* spellInfo, uint8 effIndex) override;
+ std::string ToString() const;
+ bool CheckEffect(SpellInfo const* spellInfo, uint8 effIndex) const override;
void Call(SpellScript* spellScript, SpellEffIndex effIndex);
private:
SpellEffectFnType pEffectHandlerScript;
@@ -228,8 +228,8 @@ class TC_GAME_API SpellScript : public _SpellScript
{
public:
TargetHook(uint8 _effectIndex, uint16 _targetType, bool _area, bool _dest);
- bool CheckEffect(SpellInfo const* spellInfo, uint8 effIndex) override;
- std::string ToString();
+ bool CheckEffect(SpellInfo const* spellInfo, uint8 effIndex) const override;
+ std::string ToString() const;
uint16 GetTarget() const { return targetType; }
protected:
uint16 targetType;
@@ -279,8 +279,8 @@ class TC_GAME_API SpellScript : public _SpellScript
bool _Validate(SpellInfo const* entry) override;
bool _Load(Spell* spell);
void _InitHit();
- bool _IsEffectPrevented(SpellEffIndex effIndex) { return (m_hitPreventEffectMask & (1 << effIndex)) != 0; }
- bool _IsDefaultEffectPrevented(SpellEffIndex effIndex) { return (m_hitPreventDefaultEffectMask & (1 << effIndex)) != 0; }
+ bool _IsEffectPrevented(SpellEffIndex effIndex) const { return (m_hitPreventEffectMask & (1 << effIndex)) != 0; }
+ bool _IsDefaultEffectPrevented(SpellEffIndex effIndex) const { return (m_hitPreventDefaultEffectMask & (1 << effIndex)) != 0; }
void _PrepareScriptCall(SpellScriptHookType hookType);
void _FinishScriptCall();
bool IsInCheckCastHook() const;
@@ -368,11 +368,11 @@ class TC_GAME_API SpellScript : public _SpellScript
// methods allowing interaction with Spell object
//
// methods useable during all spell handling phases
- Unit* GetCaster();
- Unit* GetOriginalCaster();
- SpellInfo const* GetSpellInfo();
- SpellValue const* GetSpellValue();
- SpellEffectInfo const* GetEffectInfo(SpellEffIndex) const;
+ Unit* GetCaster() const;
+ Unit* GetOriginalCaster() const;
+ SpellInfo const* GetSpellInfo() const;
+ SpellValue const* GetSpellValue() const;
+ SpellEffectInfo const* GetEffectInfo(SpellEffIndex effIndex) const;
// methods useable after spell is prepared
// accessors to the explicit targets of the spell
@@ -386,48 +386,48 @@ class TC_GAME_API SpellScript : public _SpellScript
// - ImplicitTargetXX set to TARGET_XXX_TARGET_YYY, _TARGET_ here means that explicit target is used by the effect, so spell needs one too
// returns: WorldLocation which was selected as a spell destination or NULL
- WorldLocation const* GetExplTargetDest();
+ WorldLocation const* GetExplTargetDest() const;
void SetExplTargetDest(WorldLocation& loc);
// returns: WorldObject which was selected as an explicit spell target or NULL if there's no target
- WorldObject* GetExplTargetWorldObject();
+ WorldObject* GetExplTargetWorldObject() const;
// returns: Unit which was selected as an explicit spell target or NULL if there's no target
- Unit* GetExplTargetUnit();
+ Unit* GetExplTargetUnit() const;
// returns: GameObject which was selected as an explicit spell target or NULL if there's no target
- GameObject* GetExplTargetGObj();
+ GameObject* GetExplTargetGObj() const;
// returns: Item which was selected as an explicit spell target or NULL if there's no target
- Item* GetExplTargetItem();
+ Item* GetExplTargetItem() const;
// methods useable only during spell hit on target, or during spell launch on target:
// returns: target of current effect if it was Unit otherwise NULL
- Unit* GetHitUnit();
+ Unit* GetHitUnit() const;
// returns: target of current effect if it was Creature otherwise NULL
- Creature* GetHitCreature();
+ Creature* GetHitCreature() const;
// returns: target of current effect if it was Player otherwise NULL
- Player* GetHitPlayer();
+ Player* GetHitPlayer() const;
// returns: target of current effect if it was Item otherwise NULL
- Item* GetHitItem();
+ Item* GetHitItem() const;
// returns: target of current effect if it was GameObject otherwise NULL
- GameObject* GetHitGObj();
+ GameObject* GetHitGObj() const;
// returns: destination of current effect
- WorldLocation* GetHitDest();
+ WorldLocation* GetHitDest() const;
// setter/getter for for damage done by spell to target of spell hit
// returns damage calculated before hit, and real dmg done after hit
- int32 GetHitDamage();
+ int32 GetHitDamage() const;
void SetHitDamage(int32 damage);
void PreventHitDamage() { SetHitDamage(0); }
// setter/getter for for heal done by spell to target of spell hit
// returns healing calculated before hit, and real dmg done after hit
- int32 GetHitHeal();
+ int32 GetHitHeal() const;
void SetHitHeal(int32 heal);
void PreventHitHeal() { SetHitHeal(0); }
- Spell* GetSpell() { return m_spell; }
+ Spell* GetSpell() const { return m_spell; }
// returns current spell hit target aura
- Aura* GetHitAura();
+ Aura* GetHitAura() const;
// prevents applying aura on current spell hit target
void PreventHitAura();
@@ -448,13 +448,13 @@ class TC_GAME_API SpellScript : public _SpellScript
void SetEffectValue(int32 value);
// returns: cast item if present.
- Item* GetCastItem();
+ Item* GetCastItem() const;
// Creates item. Calls Spell::DoCreateItem method.
void CreateItem(uint32 effIndex, uint32 itemId);
// Returns SpellInfo from the spell that triggered the current one
- SpellInfo const* GetTriggeringSpell();
+ SpellInfo const* GetTriggeringSpell() const;
// finishes spellcast prematurely with selected error message
void FinishCast(SpellCastResult result);
@@ -540,8 +540,8 @@ class TC_GAME_API AuraScript : public _SpellScript
{
public:
EffectBase(uint8 _effIndex, uint16 _effName);
- std::string ToString();
- bool CheckEffect(SpellInfo const* spellInfo, uint8 effIndex) override;
+ std::string ToString() const;
+ bool CheckEffect(SpellInfo const* spellInfo, uint8 effIndex) const override;
};
class TC_GAME_API EffectPeriodicHandler : public EffectBase
{
@@ -666,7 +666,7 @@ class TC_GAME_API AuraScript : public _SpellScript
bool _Load(Aura* aura);
void _PrepareScriptCall(AuraScriptHookType hookType, AuraApplication const* aurApp = NULL);
void _FinishScriptCall();
- bool _IsDefaultActionPrevented();
+ bool _IsDefaultActionPrevented() const;
private:
Aura* m_aura;
AuraApplication const* m_auraApplication;