aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/game/Pet.cpp11
-rw-r--r--src/game/Player.cpp11
-rw-r--r--src/game/SpellMgr.cpp156
-rw-r--r--src/game/SpellMgr.h32
4 files changed, 64 insertions, 146 deletions
diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp
index 6a7d809da03..4071cfb50bb 100644
--- a/src/game/Pet.cpp
+++ b/src/game/Pet.cpp
@@ -1858,19 +1858,12 @@ void Pet::CastPetAura(PetAura const* aura)
CastSpell(this, auraId, true);
}
-struct DoPetLearnSpell
-{
- DoPetLearnSpell(Pet& _pet) : pet(_pet) {}
- void operator() (uint32 spell_id) { pet.learnSpell(spell_id); }
- Pet& pet;
-};
-
void Pet::learnSpellHighRank(uint32 spellid)
{
learnSpell(spellid);
- DoPetLearnSpell worker(*this);
- spellmgr.doForHighRanks(spellid,worker);
+ if(uint32 next = spellmgr.GetNextSpellInChain(spellid))
+ learnSpellHighRank(next);
}
void Pet::SynchronizeLevelWithOwner()
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index 8c12bd9d029..f96eff21012 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -20563,19 +20563,12 @@ bool Player::IsAllowUseFlyMountsHere() const
return v_map == 530 || v_map == 571 && HasSpell(54197) && zoneId != 4197;
}
-struct DoPlayerLearnSpell
-{
- DoPlayerLearnSpell(Player& _player) : player(_player) {}
- void operator() (uint32 spell_id) { player.learnSpell(spell_id,false); }
- Player& player;
-};
-
void Player::learnSpellHighRank(uint32 spellid)
{
learnSpell(spellid,false);
- DoPlayerLearnSpell worker(*this);
- spellmgr.doForHighRanks(spellid,worker);
+ if(uint32 next = spellmgr.GetNextSpellInChain(spellid))
+ learnSpellHighRank(next);
}
void Player::_LoadSkills()
diff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cpp
index 5e82f472e8a..234a7e3aaa1 100644
--- a/src/game/SpellMgr.cpp
+++ b/src/game/SpellMgr.cpp
@@ -1206,13 +1206,6 @@ bool SpellMgr::IsAffectedByMod(SpellEntry const *spellInfo, SpellModifier *mod)
return false;
}
-struct DoSpellProcEvent
-{
- DoSpellProcEvent(SpellProcEventEntry const& _spe) : spe(_spe) {}
- void operator() (uint32 spell_id) { spellmgr.mSpellProcEventMap[spell_id] = spe; }
- SpellProcEventEntry const& spe;
-};
-
void SpellMgr::LoadSpellProcEvents()
{
mSpellProcEventMap.clear(); // need for reload case
@@ -1247,15 +1240,6 @@ void SpellMgr::LoadSpellProcEvents()
continue;
}
- uint32 first_id = GetFirstSpellInChain(entry);
-
- if ( first_id != entry )
- {
- sLog.outErrorDb("Spell %u listed in `spell_proc_event` is not first rank (%u) in chain", entry, first_id);
- // prevent loading since it won't have an effect anyway
- continue;
- }
-
SpellProcEventEntry spe;
spe.schoolMask = fields[1].GetUInt32();
@@ -1271,10 +1255,6 @@ void SpellMgr::LoadSpellProcEvents()
mSpellProcEventMap[entry] = spe;
- // also add to high ranks
- DoSpellProcEvent worker(spe);
- doForHighRanks(entry,worker);
-
if (spell->procFlags==0)
{
if (spe.procFlags == 0)
@@ -1296,74 +1276,6 @@ void SpellMgr::LoadSpellProcEvents()
sLog.outString( ">> Loaded %u extra spell proc event conditions", count );
}
-struct DoSpellProcItemEnchant
-{
- DoSpellProcItemEnchant(SpellEnchantProcEntry const &_spe) : spe(_spe) {}
- void operator() (uint32 spell_id) { spellmgr.mSpellEnchantProcEventMap[spell_id] = spe; }
- SpellEnchantProcEntry const &spe;
-};
-
-void SpellMgr::LoadSpellEnchantProcData()
-{
- mSpellEnchantProcEventMap.clear(); // need for reload case
-
- uint32 count = 0;
-
- // 0 1 2 3
- QueryResult *result = WorldDatabase.Query("SELECT entry, customChance, PPMChance, procEx FROM spell_enchant_proc_data");
- if( !result )
- {
-
- barGoLink bar( 1 );
-
- bar.step();
-
- sLog.outString();
- sLog.outString( ">> Loaded %u spell enchant proc event conditions", count );
- return;
- }
-
- barGoLink bar( result->GetRowCount() );
- do
- {
- Field *fields = result->Fetch();
-
- bar.step();
-
- uint32 entry = fields[0].GetUInt32();
-
- SpellItemEnchantmentEntry const *ench = sSpellItemEnchantmentStore.LookupEntry(entry);
- if (!ench)
- {
- sLog.outErrorDb("Enchancment %u listed in `spell_enchant_proc_data` does not exist", entry);
- continue;
- }
-
- SpellEnchantProcEntry spe;
-
- spe.customChance = fields[1].GetUInt32();
- spe.PPMChance = fields[2].GetFloat();
- spe.procEx = fields[3].GetUInt32();
-
- // also add to high ranks
- DoSpellProcItemEnchant worker(spe);
- doForThisAndHighRanks(entry,worker);
-
- ++count;
- } while( result->NextRow() );
-
- delete result;
-
- sLog.outString( ">> Loaded %u enchant proc data definitions", count);
-}
-
-struct DoSpellBonusess
-{
- DoSpellBonusess(SpellBonusEntry const& _spellBonus) : spellBonus(_spellBonus) {}
- void operator() (uint32 spell_id) { spellmgr.mSpellBonusMap[spell_id] = spellBonus; }
- SpellBonusEntry const& spellBonus;
-};
-
void SpellMgr::LoadSpellBonusess()
{
mSpellBonusMap.clear(); // need for reload case
@@ -1386,22 +1298,13 @@ void SpellMgr::LoadSpellBonusess()
bar.step();
uint32 entry = fields[0].GetUInt32();
- SpellEntry const* spell = sSpellStore.LookupEntry(entry);
+ const SpellEntry *spell = sSpellStore.LookupEntry(entry);
if (!spell)
{
sLog.outErrorDb("Spell %u listed in `spell_bonus_data` does not exist", entry);
continue;
}
- uint32 first_id = GetFirstSpellInChain(entry);
-
- if ( first_id != entry )
- {
- sLog.outErrorDb("Spell %u listed in `spell_bonus_data` is not first rank (%u) in chain", entry, first_id);
- // prevent loading since it won't have an effect anyway
- continue;
- }
-
SpellBonusEntry sbe;
sbe.direct_damage = fields[1].GetFloat();
@@ -1411,11 +1314,6 @@ void SpellMgr::LoadSpellBonusess()
mSpellBonusMap[entry] = sbe;
++count;
-
- // also add to high ranks
- DoSpellBonusess worker(sbe);
- doForHighRanks(entry,worker);
-
} while( result->NextRow() );
delete result;
@@ -3425,6 +3323,58 @@ bool IsDispelableBySpell(SpellEntry const * dispelSpell, uint32 spellId, bool de
return def;
}
+void SpellMgr::LoadSpellEnchantProcData()
+{
+ mSpellEnchantProcEventMap.clear(); // need for reload case
+
+ uint32 count = 0;
+
+ // 0 1 2 3
+ QueryResult *result = WorldDatabase.Query("SELECT entry, customChance, PPMChance, procEx FROM spell_enchant_proc_data");
+ if( !result )
+ {
+
+ barGoLink bar( 1 );
+
+ bar.step();
+
+ sLog.outString();
+ sLog.outString( ">> Loaded %u spell enchant proc event conditions", count );
+ return;
+ }
+
+ barGoLink bar( result->GetRowCount() );
+ do
+ {
+ Field *fields = result->Fetch();
+
+ bar.step();
+
+ uint32 enchantId = fields[0].GetUInt32();
+
+ SpellItemEnchantmentEntry const *ench = sSpellItemEnchantmentStore.LookupEntry(enchantId);
+ if (!ench)
+ {
+ sLog.outErrorDb("Enchancment %u listed in `spell_enchant_proc_data` does not exist", enchantId);
+ continue;
+ }
+
+ SpellEnchantProcEntry spe;
+
+ spe.customChance = fields[1].GetUInt32();
+ spe.PPMChance = fields[2].GetFloat();
+ spe.procEx = fields[3].GetUInt32();
+
+ mSpellEnchantProcEventMap[enchantId] = spe;
+
+ ++count;
+ } while( result->NextRow() );
+
+ delete result;
+
+ sLog.outString( ">> Loaded %u enchant proc data definitions", count);
+}
+
void SpellMgr::LoadSpellRequired()
{
mSpellsReqSpell.clear(); // need for reload case
diff --git a/src/game/SpellMgr.h b/src/game/SpellMgr.h
index be34f4af2eb..f1d551298f0 100644
--- a/src/game/SpellMgr.h
+++ b/src/game/SpellMgr.h
@@ -729,10 +729,6 @@ inline bool IsProfessionOrRidingSkill(uint32 skill)
class SpellMgr
{
- friend struct DoSpellBonusess;
- friend struct DoSpellProcEvent;
- friend struct DoSpellProcItemEnchant;
-
// Constructors
public:
SpellMgr();
@@ -802,7 +798,13 @@ class SpellMgr
SpellBonusMap::const_iterator itr = mSpellBonusMap.find(spellId);
if( itr != mSpellBonusMap.end( ) )
return &itr->second;
-
+ // Not found, try lookup for 1 spell rank if exist
+ if (uint32 rank_1 = GetFirstSpellInChain(spellId))
+ {
+ SpellBonusMap::const_iterator itr2 = mSpellBonusMap.find(rank_1);
+ if( itr2 != mSpellBonusMap.end( ) )
+ return &itr2->second;
+ }
return NULL;
}
@@ -860,26 +862,6 @@ class SpellMgr
SpellsRequiringSpellMap const& GetSpellsRequiringSpell() const { return mSpellsReqSpell; }
- template<typename Worker>
- void doForThisAndHighRanks(uint32 spellid, Worker& worker)
- {
- worker(spellid);
- if(uint32 nextSpellId = GetNextSpellInChain(spellid))
- doForThisAndHighRanks(nextSpellId, worker);
- }
-
- template<typename Worker>
- void doForHighRanks(uint32 spellid, Worker& worker)
- {
- if(uint32 nextSpellId = GetNextSpellInChain(spellid))
- {
- worker(nextSpellId);
- doForHighRanks(nextSpellId, worker);
- }
- }
-
- // Note: not use rank for compare to spell ranks: spell chains isn't linear order
- // Use IsHighRankOfSpell instead
uint8 GetSpellRank(uint32 spell_id) const
{
if(SpellChainNode const* node = GetSpellChainNode(spell_id))