[10273] Avoid some redundent and recursive calls to SpellMgr singleton.

This commit is contained in:
VladimirMangos 2010-07-26 16:34:25 +04:00
parent 730b4deaaf
commit 6a4cae890e
4 changed files with 29 additions and 19 deletions

View file

@ -1255,8 +1255,10 @@ void SpellMgr::LoadSpellProcEvents()
struct DoSpellProcItemEnchant
{
DoSpellProcItemEnchant(float _ppm) : ppm(_ppm) {}
void operator() (uint32 spell_id) { sSpellMgr.mSpellProcItemEnchantMap[spell_id] = ppm; }
DoSpellProcItemEnchant(SpellProcItemEnchantMap& _procMap, float _ppm) : procMap(_procMap), ppm(_ppm) {}
void operator() (uint32 spell_id) { procMap[spell_id] = ppm; }
SpellProcItemEnchantMap& procMap;
float ppm;
};
@ -1311,7 +1313,7 @@ void SpellMgr::LoadSpellProcItemEnchant()
mSpellProcItemEnchantMap[entry] = ppmRate;
// also add to high ranks
DoSpellProcItemEnchant worker(ppmRate);
DoSpellProcItemEnchant worker(mSpellProcItemEnchantMap, ppmRate);
doForHighRanks(entry,worker);
++count;
@ -1325,8 +1327,10 @@ void SpellMgr::LoadSpellProcItemEnchant()
struct DoSpellBonuses
{
DoSpellBonuses(SpellBonusEntry const& _spellBonus) : spellBonus(_spellBonus) {}
void operator() (uint32 spell_id) { sSpellMgr.mSpellBonusMap[spell_id] = spellBonus; }
DoSpellBonuses(SpellBonusMap& _spellBonusMap, SpellBonusEntry const& _spellBonus) : spellBonusMap(spellBonusMap), spellBonus(_spellBonus) {}
void operator() (uint32 spell_id) { spellBonusMap[spell_id] = spellBonus; }
SpellBonusMap& spellBonusMap;
SpellBonusEntry const& spellBonus;
};
@ -1468,7 +1472,7 @@ void SpellMgr::LoadSpellBonuses()
mSpellBonusMap[entry] = sbe;
// also add to high ranks
DoSpellBonuses worker(sbe);
DoSpellBonuses worker(mSpellBonusMap, sbe);
doForHighRanks(entry,worker);
++count;
@ -1643,16 +1647,16 @@ bool SpellMgr::IsRankSpellDueToSpell(SpellEntry const *spellInfo_1,uint32 spellI
return GetFirstSpellInChain(spellInfo_1->Id)==GetFirstSpellInChain(spellId_2);
}
bool SpellMgr::canStackSpellRanks(SpellEntry const *spellInfo)
bool SpellMgr::canStackSpellRanksInSpellBook(SpellEntry const *spellInfo) const
{
if(IsPassiveSpell(spellInfo)) // ranked passive spell
if (IsPassiveSpell(spellInfo)) // ranked passive spell
return false;
if(spellInfo->powerType != POWER_MANA && spellInfo->powerType != POWER_HEALTH)
if (spellInfo->powerType != POWER_MANA && spellInfo->powerType != POWER_HEALTH)
return false;
if(IsProfessionOrRidingSpell(spellInfo->Id))
if (IsProfessionOrRidingSpell(spellInfo->Id))
return false;
if(sSpellMgr.IsSkillBonusSpell(spellInfo->Id))
if (IsSkillBonusSpell(spellInfo->Id))
return false;
// All stance spells. if any better way, change it.
@ -2926,7 +2930,7 @@ void SpellMgr::LoadPetLevelupSpellMap()
sLog.outString( ">> Loaded %u pet levelup and default spells for %u families", count, family_count );
}
bool LoadPetDefaultSpells_helper(CreatureInfo const* cInfo, PetDefaultSpellsEntry& petDefSpells)
bool SpellMgr::LoadPetDefaultSpells_helper(CreatureInfo const* cInfo, PetDefaultSpellsEntry& petDefSpells)
{
// skip empty list;
bool have_spell = false;
@ -2942,7 +2946,7 @@ bool LoadPetDefaultSpells_helper(CreatureInfo const* cInfo, PetDefaultSpellsEntr
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 ? GetPetLevelupSpellList(cInfo->family) : NULL)
{
for(int j = 0; j < MAX_CREATURE_SPELL_DATA_SLOT; ++j)
{