aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2014-12-14 16:11:33 +0100
committerShauren <shauren.trinity@gmail.com>2014-12-14 16:11:33 +0100
commit25ff9daab1f0e96db128ef85fe2dbbc8ca34468b (patch)
tree0149572eaa13a0f9d8fc1d86b5ffa5144476a1cb
parentee496b96a177f638701ac16f6af3325c31846013 (diff)
Core/Spells: Optimized spell effect info loading
-rw-r--r--src/server/game/DataStores/DBCfmt.h2
-rw-r--r--src/server/game/Spells/SpellInfo.cpp5
-rw-r--r--src/server/game/Spells/SpellMgr.cpp9
3 files changed, 12 insertions, 4 deletions
diff --git a/src/server/game/DataStores/DBCfmt.h b/src/server/game/DataStores/DBCfmt.h
index 6fca0f37608..c92d3babb25 100644
--- a/src/server/game/DataStores/DBCfmt.h
+++ b/src/server/game/DataStores/DBCfmt.h
@@ -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";
diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp
index faebf1dcfa4..b9dc74f081f 100644
--- a/src/server/game/Spells/SpellInfo.cpp
+++ b/src/server/game/Spells/SpellInfo.cpp
@@ -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;
diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp
index 4ba129b4946..f4b9ea394e7 100644
--- a/src/server/game/Spells/SpellMgr.cpp
+++ b/src/server/game/Spells/SpellMgr.cpp
@@ -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)