Core/Spells: Optimized spell effect info loading

This commit is contained in:
Shauren
2014-12-14 16:11:33 +01:00
parent ee496b96a1
commit 25ff9daab1
3 changed files with 12 additions and 4 deletions

View File

@@ -130,7 +130,7 @@ char const SpellCastTimefmt[] = "nixx";
char const SpellCategoriesEntryfmt[] = "diiiiiiiix";
char const SpellCategoryfmt[] = "nixxxx";
char const SpellDurationfmt[] = "niii";
char const SpellEffectEntryfmt[] = "niifiiiffiiiiiifiifiiiiifiiiiif";
char const SpellEffectEntryfmt[] = "iiifiiiffiiiiiifiifiiiiifiiiiif";
const std::string CustomSpellEffectEntryfmt = "ppppppppppppppappppppppppp";
const std::string CustomSpellEffectEntryIndex = "Id";
char const SpellEntryfmt[] = "nsxxxiiiiiiiiiiiiiiiiiii";

View File

@@ -3088,7 +3088,12 @@ SpellEffectInfoVector SpellInfo::GetEffectsForDifficulty(uint32 difficulty) cons
{
// overwrite any existing effect from DIFFICULTY_NONE
if (effect)
{
if (effect->EffectIndex >= effList.size())
effList.resize(effect->EffectIndex + 1);
effList[effect->EffectIndex] = effect;
}
}
// if we found any effect in our difficulty then stop searching
break;

View File

@@ -2760,15 +2760,18 @@ void SpellMgr::LoadSpellInfoStore()
SpellEffectEntry const* effect = sSpellEffectStore.LookupEntry(i);
if (!effect)
continue;
if (effect->EffectIndex >= MAX_SPELL_EFFECTS)
{
TC_LOG_ERROR("server.loading", "Spell %u has invalid EffectIndex %u, max is %u, skipped", i, effect->EffectIndex, uint32(MAX_SPELL_EFFECTS));
continue;
}
effectsBySpell[effect->SpellID][effect->DifficultyID].resize(MAX_SPELL_EFFECTS);
effectsBySpell[effect->SpellID][effect->DifficultyID][effect->EffectIndex] = effect;
SpellEffectEntryVector& effectsForDifficulty = effectsBySpell[effect->SpellID][effect->DifficultyID];
if (effectsForDifficulty.size() <= effect->EffectIndex)
effectsForDifficulty.resize(effect->EffectIndex + 1);
effectsForDifficulty[effect->EffectIndex] = effect;
}
for (uint32 i = 0; i < sSpellStore.GetNumRows(); ++i)