From 3c073c283fc04e67efc8f3072a053784e4275d72 Mon Sep 17 00:00:00 2001 From: Vinolentus <655ff4c91d8e57f5@gmail.com> Date: Sun, 7 Aug 2011 12:56:13 +0400 Subject: [PATCH] [11789] Remove ApplySpellMod body from header. We can explicitly instantiate possible variants. Signed-off-by: Schmoozerd --- src/game/Player.cpp | 44 ++++++++++++++++++++++++++++++++++++++++ src/game/Player.h | 38 ---------------------------------- src/shared/revision_nr.h | 2 +- 3 files changed, 45 insertions(+), 39 deletions(-) diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 704c3ef10..ab75294a0 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -60,6 +60,7 @@ #include "SocialMgr.h" #include "AchievementMgr.h" #include "Mail.h" +#include "SpellAuras.h" #include @@ -18620,6 +18621,49 @@ void Player::AddSpellMod(Aura* aura, bool apply) m_spellMods[mod->m_miscvalue].remove(aura); } +template T Player::ApplySpellMod(uint32 spellId, SpellModOp op, T &basevalue, Spell const* spell) +{ + SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellId); + if (!spellInfo) + return 0; + + int32 totalpct = 0; + int32 totalflat = 0; + for (AuraList::iterator itr = m_spellMods[op].begin(); itr != m_spellMods[op].end(); ++itr) + { + Aura *aura = *itr; + + Modifier const* mod = aura->GetModifier(); + + if (!aura->isAffectedOnSpell(spellInfo)) + continue; + + if (mod->m_auraname == SPELL_AURA_ADD_FLAT_MODIFIER) + totalflat += mod->m_amount; + else + { + // skip percent mods for null basevalue (most important for spell mods with charges ) + if (basevalue == T(0)) + continue; + + // special case (skip >10sec spell casts for instant cast setting) + if (mod->m_miscvalue == SPELLMOD_CASTING_TIME + && basevalue >= T(10*IN_MILLISECONDS) && mod->m_amount <= -100) + continue; + + totalpct += mod->m_amount; + } + } + + float diff = (float)basevalue*(float)totalpct/100.0f + (float)totalflat; + basevalue = T((float)basevalue + diff); + return T(diff); +} + +template int32 Player::ApplySpellMod(uint32 spellId, SpellModOp op, int32 &basevalue, Spell const* spell); +template uint32 Player::ApplySpellMod(uint32 spellId, SpellModOp op, uint32 &basevalue, Spell const* spell); +template float Player::ApplySpellMod(uint32 spellId, SpellModOp op, float &basevalue, Spell const* spell); + // send Proficiency void Player::SendProficiency(ItemClass itemClass, uint32 itemSubclassMask) { diff --git a/src/game/Player.h b/src/game/Player.h index 0b5a80b48..94b85a490 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -38,7 +38,6 @@ #include "BattleGround.h" #include "DBCStores.h" #include "SharedDefines.h" -#include "SpellAuras.h" #include #include @@ -2632,41 +2631,4 @@ class MANGOS_DLL_SPEC Player : public Unit void AddItemsSetItem(Player*player,Item *item); void RemoveItemsSetItem(Player*player,ItemPrototype const *proto); -// "the bodies of template functions must be made available in a header file" -template T Player::ApplySpellMod(uint32 spellId, SpellModOp op, T &basevalue, Spell const* spell) -{ - SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId); - if (!spellInfo) return 0; - int32 totalpct = 0; - int32 totalflat = 0; - for (AuraList::iterator itr = m_spellMods[op].begin(); itr != m_spellMods[op].end(); ++itr) - { - Aura *aura = *itr; - - Modifier const* mod = aura->GetModifier(); - - if (!aura->isAffectedOnSpell(spellInfo)) - continue; - - if (mod->m_auraname == SPELL_AURA_ADD_FLAT_MODIFIER) - totalflat += mod->m_amount; - else - { - // skip percent mods for null basevalue (most important for spell mods with charges ) - if (basevalue == T(0)) - continue; - - // special case (skip >10sec spell casts for instant cast setting) - if (mod->m_miscvalue == SPELLMOD_CASTING_TIME && basevalue >= T(10*IN_MILLISECONDS) && mod->m_amount <= -100) - continue; - - totalpct += mod->m_amount; - } - } - - float diff = (float)basevalue*(float)totalpct/100.0f + (float)totalflat; - basevalue = T((float)basevalue + diff); - return T(diff); -} - #endif diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 6f17c0118..72df50e20 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "11788" + #define REVISION_NR "11789" #endif // __REVISION_NR_H__