[11789] Remove ApplySpellMod body from header. We can explicitly instantiate possible variants.

Signed-off-by: Schmoozerd <schmoozerd@scriptdev2.com>
This commit is contained in:
Vinolentus 2011-08-07 12:56:13 +04:00 committed by Schmoozerd
parent 989c979eee
commit 3c073c283f
3 changed files with 45 additions and 39 deletions

View file

@ -60,6 +60,7 @@
#include "SocialMgr.h" #include "SocialMgr.h"
#include "AchievementMgr.h" #include "AchievementMgr.h"
#include "Mail.h" #include "Mail.h"
#include "SpellAuras.h"
#include <cmath> #include <cmath>
@ -18620,6 +18621,49 @@ void Player::AddSpellMod(Aura* aura, bool apply)
m_spellMods[mod->m_miscvalue].remove(aura); m_spellMods[mod->m_miscvalue].remove(aura);
} }
template <class T> 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<int32>(uint32 spellId, SpellModOp op, int32 &basevalue, Spell const* spell);
template uint32 Player::ApplySpellMod<uint32>(uint32 spellId, SpellModOp op, uint32 &basevalue, Spell const* spell);
template float Player::ApplySpellMod<float>(uint32 spellId, SpellModOp op, float &basevalue, Spell const* spell);
// send Proficiency // send Proficiency
void Player::SendProficiency(ItemClass itemClass, uint32 itemSubclassMask) void Player::SendProficiency(ItemClass itemClass, uint32 itemSubclassMask)
{ {

View file

@ -38,7 +38,6 @@
#include "BattleGround.h" #include "BattleGround.h"
#include "DBCStores.h" #include "DBCStores.h"
#include "SharedDefines.h" #include "SharedDefines.h"
#include "SpellAuras.h"
#include<string> #include<string>
#include<vector> #include<vector>
@ -2632,41 +2631,4 @@ class MANGOS_DLL_SPEC Player : public Unit
void AddItemsSetItem(Player*player,Item *item); void AddItemsSetItem(Player*player,Item *item);
void RemoveItemsSetItem(Player*player,ItemPrototype const *proto); void RemoveItemsSetItem(Player*player,ItemPrototype const *proto);
// "the bodies of template functions must be made available in a header file"
template <class T> 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 #endif

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "11788" #define REVISION_NR "11789"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__