Core/Globals: cache SpellSpecific and AuraState information instead of computing them each time they're needed

This commit is contained in:
roc13x
2017-05-04 00:12:11 +01:00
parent c6aa63536e
commit 0b2e5adeb1
5 changed files with 30 additions and 0 deletions

View File

@@ -1028,6 +1028,9 @@ SpellInfo::SpellInfo(SpellEntry const* spellEntry, SpellEffectEntry const** effe
ChainEntry = NULL;
ExplicitTargetMask = 0;
_spellSpecific = SPELL_SPECIFIC_NORMAL;
_auraState = AURA_STATE_NONE;
}
SpellInfo::~SpellInfo()

View File

@@ -560,11 +560,17 @@ public:
bool _IsPositiveEffect(uint8 effIndex, bool deep) const;
bool _IsPositiveSpell() const;
static bool _IsPositiveTarget(uint32 targetA, uint32 targetB);
void _LoadSpellSpecific();
void _LoadAuraState();
void _LoadImmunityInfo();
// unloading helpers
void _UnloadImplicitTargetConditionLists();
private:
SpellSpecificType _spellSpecific;
AuraStateType _auraState;
ImmunityInfo _immunityInfo[MAX_SPELL_EFFECTS];
};

View File

@@ -3821,6 +3821,23 @@ void SpellMgr::LoadSpellInfoCorrections()
TC_LOG_INFO("server.loading", ">> Loaded SpellInfo corrections in %u ms", GetMSTimeDiffToNow(oldMSTime));
}
void SpellMgr::LoadSpellInfoSpellSpecificAndAuraState()
{
uint32 oldMSTime = getMSTime();
for (SpellInfo* spellInfo : mSpellInfoMap)
{
if (!spellInfo)
continue;
// AuraState depends on SpellSpecific
spellInfo->_LoadSpellSpecific();
spellInfo->_LoadAuraState();
}
TC_LOG_INFO("server.loading", ">> Loaded SpellInfo SpellSpecific and AuraState in %u ms", GetMSTimeDiffToNow(oldMSTime));
}
void SpellMgr::LoadSpellInfoImmunities()
{
uint32 oldMSTime = getMSTime();

View File

@@ -684,6 +684,7 @@ class TC_GAME_API SpellMgr
void UnloadSpellInfoImplicitTargetConditionLists();
void LoadSpellInfoCustomAttributes();
void LoadSpellInfoCorrections();
void LoadSpellInfoSpellSpecificAndAuraState();
void LoadSpellInfoImmunities();
private:

View File

@@ -1506,6 +1506,9 @@ void World::SetInitialWorldSettings()
TC_LOG_INFO("server.loading", "Loading SpellInfo custom attributes...");
sSpellMgr->LoadSpellInfoCustomAttributes();
TC_LOG_INFO("server.loading", "Loading SpellInfo SpellSpecific and AuraState...");
sSpellMgr->LoadSpellInfoSpellSpecificAndAuraState();
TC_LOG_INFO("server.loading", "Loading SpellInfo immunity infos...");
sSpellMgr->LoadSpellInfoImmunities();