aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Spells/SpellMgr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/game/Spells/SpellMgr.cpp')
-rw-r--r--src/server/game/Spells/SpellMgr.cpp67
1 files changed, 35 insertions, 32 deletions
diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp
index a14eddcc383..e0800b2782d 100644
--- a/src/server/game/Spells/SpellMgr.cpp
+++ b/src/server/game/Spells/SpellMgr.cpp
@@ -17,17 +17,21 @@
*/
#include "SpellMgr.h"
-#include "SpellInfo.h"
-#include "Spell.h"
-#include "ObjectMgr.h"
-#include "SpellAuraDefines.h"
-#include "SharedDefines.h"
-#include "DBCStores.h"
-#include "Chat.h"
-#include "BattlegroundMgr.h"
-#include "BattlefieldWG.h"
#include "BattlefieldMgr.h"
+#include "BattlefieldWG.h"
+#include "BattlegroundMgr.h"
+#include "Chat.h"
+#include "DatabaseEnv.h"
+#include "DBCStores.h"
+#include "Log.h"
+#include "Map.h"
+#include "MotionMaster.h"
+#include "ObjectMgr.h"
#include "Player.h"
+#include "SharedDefines.h"
+#include "Spell.h"
+#include "SpellAuraDefines.h"
+#include "SpellInfo.h"
bool IsPrimaryProfessionSkill(uint32 skill)
{
@@ -215,7 +219,7 @@ uint32 SpellMgr::GetSpellIdForDifficulty(uint32 spellId, Unit const* caster) con
SpellInfo const* SpellMgr::GetSpellForDifficultyFromSpell(SpellInfo const* spell, Unit const* caster) const
{
if (!spell)
- return NULL;
+ return nullptr;
uint32 newSpellId = GetSpellIdForDifficulty(spell->Id, caster);
SpellInfo const* newSpell = GetSpellInfo(newSpellId);
@@ -233,7 +237,7 @@ SpellChainNode const* SpellMgr::GetSpellChainNode(uint32 spell_id) const
{
SpellChainMap::const_iterator itr = mSpellChains.find(spell_id);
if (itr == mSpellChains.end())
- return NULL;
+ return nullptr;
return &itr->second;
}
@@ -319,7 +323,7 @@ SpellLearnSkillNode const* SpellMgr::GetSpellLearnSkill(uint32 spell_id) const
if (itr != mSpellLearnSkills.end())
return &itr->second;
else
- return NULL;
+ return nullptr;
}
SpellLearnSpellMapBounds SpellMgr::GetSpellLearnSpellMapBounds(uint32 spell_id) const
@@ -346,7 +350,7 @@ SpellTargetPosition const* SpellMgr::GetSpellTargetPosition(uint32 spell_id, Spe
SpellTargetPositionMap::const_iterator itr = mSpellTargetPositions.find(std::make_pair(spell_id, effIndex));
if (itr != mSpellTargetPositions.end())
return &itr->second;
- return NULL;
+ return nullptr;
}
SpellSpellGroupMapBounds SpellMgr::GetSpellSpellGroupMapBounds(uint32 spell_id) const
@@ -493,7 +497,7 @@ SpellProcEntry const* SpellMgr::GetSpellProcEntry(uint32 spellId) const
SpellProcMap::const_iterator itr = mSpellProcMap.find(spellId);
if (itr != mSpellProcMap.end())
return &itr->second;
- return NULL;
+ return nullptr;
}
bool SpellMgr::CanSpellTriggerProcOnEvent(SpellProcEntry const& procEntry, ProcEventInfo& eventInfo)
@@ -591,7 +595,7 @@ SpellBonusEntry const* SpellMgr::GetSpellBonusData(uint32 spellId) const
if (itr2 != mSpellBonusMap.end())
return &itr2->second;
}
- return NULL;
+ return nullptr;
}
SpellThreatEntry const* SpellMgr::GetSpellThreatEntry(uint32 spellID) const
@@ -606,7 +610,7 @@ SpellThreatEntry const* SpellMgr::GetSpellThreatEntry(uint32 spellID) const
if (itr != mSpellThreatMap.end())
return &itr->second;
}
- return NULL;
+ return nullptr;
}
SkillLineAbilityMapBounds SpellMgr::GetSkillLineAbilityMapBounds(uint32 spell_id) const
@@ -620,7 +624,7 @@ PetAura const* SpellMgr::GetPetAura(uint32 spell_id, uint8 eff) const
if (itr != mSpellPetAuraMap.end())
return &itr->second;
else
- return NULL;
+ return nullptr;
}
SpellEnchantProcEntry const* SpellMgr::GetSpellEnchantProcEvent(uint32 enchId) const
@@ -628,7 +632,7 @@ SpellEnchantProcEntry const* SpellMgr::GetSpellEnchantProcEvent(uint32 enchId) c
SpellEnchantProcEventMap::const_iterator itr = mSpellEnchantProcEventMap.find(enchId);
if (itr != mSpellEnchantProcEventMap.end())
return &itr->second;
- return NULL;
+ return nullptr;
}
bool SpellMgr::IsArenaAllowedEnchancment(uint32 ench_id) const
@@ -639,7 +643,7 @@ bool SpellMgr::IsArenaAllowedEnchancment(uint32 ench_id) const
const std::vector<int32>* SpellMgr::GetSpellLinked(int32 spell_id) const
{
SpellLinkedMap::const_iterator itr = mSpellLinkedMap.find(spell_id);
- return itr != mSpellLinkedMap.end() ? &(itr->second) : NULL;
+ return itr != mSpellLinkedMap.end() ? &(itr->second) : nullptr;
}
PetLevelupSpellSet const* SpellMgr::GetPetLevelupSpellList(uint32 petFamily) const
@@ -648,7 +652,7 @@ PetLevelupSpellSet const* SpellMgr::GetPetLevelupSpellList(uint32 petFamily) con
if (itr != mPetLevelupSpellMap.end())
return &itr->second;
else
- return NULL;
+ return nullptr;
}
PetDefaultSpellsEntry const* SpellMgr::GetPetDefaultSpellsEntry(int32 id) const
@@ -656,7 +660,7 @@ PetDefaultSpellsEntry const* SpellMgr::GetPetDefaultSpellsEntry(int32 id) const
PetDefaultSpellsMap::const_iterator itr = mPetDefaultSpellsMap.find(id);
if (itr != mPetDefaultSpellsMap.end())
return &itr->second;
- return NULL;
+ return nullptr;
}
SpellAreaMapBounds SpellMgr::GetSpellAreaMapBounds(uint32 spell_id) const
@@ -794,7 +798,7 @@ bool SpellArea::IsFitToRequirements(Player const* player, uint32 newZone, uint32
void SpellMgr::UnloadSpellInfoChains()
{
for (SpellChainMap::iterator itr = mSpellChains.begin(); itr != mSpellChains.end(); ++itr)
- mSpellInfoMap[itr->first]->ChainEntry = NULL;
+ mSpellInfoMap[itr->first]->ChainEntry = nullptr;
mSpellChains.clear();
}
@@ -810,7 +814,7 @@ void SpellMgr::LoadSpellTalentRanks()
if (!talentInfo)
continue;
- SpellInfo const* lastSpell = NULL;
+ SpellInfo const* lastSpell = nullptr;
for (uint8 rank = MAX_TALENT_RANK - 1; rank > 0; --rank)
{
if (talentInfo->RankID[rank])
@@ -830,7 +834,7 @@ void SpellMgr::LoadSpellTalentRanks()
continue;
}
- SpellInfo const* prevSpell = NULL;
+ SpellInfo const* prevSpell = nullptr;
for (uint8 rank = 0; rank < MAX_TALENT_RANK; ++rank)
{
uint32 spellId = talentInfo->RankID[rank];
@@ -850,7 +854,7 @@ void SpellMgr::LoadSpellTalentRanks()
node.rank = rank + 1;
node.prev = prevSpell;
- node.next = node.rank < MAX_TALENT_RANK ? GetSpellInfo(talentInfo->RankID[node.rank]) : NULL;
+ node.next = node.rank < MAX_TALENT_RANK ? GetSpellInfo(talentInfo->RankID[node.rank]) : nullptr;
mSpellChains[spellId] = node;
mSpellInfoMap[spellId]->ChainEntry = &mSpellChains[spellId];
@@ -963,7 +967,7 @@ void SpellMgr::LoadSpellRanks()
if (itr == rankChain.end())
{
- mSpellChains[addedSpell].next = NULL;
+ mSpellChains[addedSpell].next = nullptr;
break;
}
else
@@ -2224,7 +2228,7 @@ bool LoadPetDefaultSpells_helper(CreatureTemplate const* cInfo, PetDefaultSpells
return false;
// remove duplicates with levelupSpells if any
- if (PetLevelupSpellSet const* levelupSpells = cInfo->family ? sSpellMgr->GetPetLevelupSpellList(cInfo->family) : NULL)
+ if (PetLevelupSpellSet const* levelupSpells = cInfo->family ? sSpellMgr->GetPetLevelupSpellList(cInfo->family) : nullptr)
{
for (uint8 j = 0; j < MAX_CREATURE_SPELL_DATA_SLOT; ++j)
{
@@ -2533,11 +2537,10 @@ void SpellMgr::LoadSpellInfoStore()
uint32 oldMSTime = getMSTime();
UnloadSpellInfoStore();
- mSpellInfoMap.resize(sSpellStore.GetNumRows(), NULL);
+ mSpellInfoMap.resize(sSpellStore.GetNumRows(), nullptr);
- for (uint32 i = 0; i < sSpellStore.GetNumRows(); ++i)
- if (SpellEntry const* spellEntry = sSpellStore.LookupEntry(i))
- mSpellInfoMap[i] = new SpellInfo(spellEntry);
+ for (SpellEntry const* spellEntry : sSpellStore)
+ mSpellInfoMap[spellEntry->Id] = new SpellInfo(spellEntry);
TC_LOG_INFO("server.loading", ">> Loaded SpellInfo store in %u ms", GetMSTimeDiffToNow(oldMSTime));
}
@@ -2561,7 +2564,7 @@ void SpellMgr::LoadSpellInfoCustomAttributes()
{
uint32 oldMSTime = getMSTime();
uint32 oldMSTime2 = oldMSTime;
- SpellInfo* spellInfo = NULL;
+ SpellInfo* spellInfo = nullptr;
QueryResult result = WorldDatabase.Query("SELECT entry, attributes FROM spell_custom_attr");