aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2012-09-15 22:02:17 +0200
committerShauren <shauren.trinity@gmail.com>2012-09-15 22:02:17 +0200
commita51ab0abc4298ca55e90aa67be68380555114296 (patch)
tree935f8a32ecd4b85c9a9ce758884369467f7be834 /src
parent966283168cd49688def320a96c062bd21b848e9a (diff)
Core/Spells
* Removed unneeded ported helper functions and use our own * Corrected filling pet spells
Diffstat (limited to 'src')
-rw-r--r--src/server/game/DataStores/DBCStores.cpp108
-rwxr-xr-xsrc/server/game/DataStores/DBCStores.h3
-rw-r--r--src/server/game/DataStores/DBCStructure.h46
-rw-r--r--src/server/game/Spells/SpellInfo.cpp20
-rw-r--r--src/server/game/Spells/SpellInfo.h4
-rw-r--r--src/server/game/Spells/SpellMgr.cpp31
6 files changed, 73 insertions, 139 deletions
diff --git a/src/server/game/DataStores/DBCStores.cpp b/src/server/game/DataStores/DBCStores.cpp
index 22c450e33d5..9ecc41732f0 100644
--- a/src/server/game/DataStores/DBCStores.cpp
+++ b/src/server/game/DataStores/DBCStores.cpp
@@ -195,11 +195,6 @@ DBCStorage <SpellCooldownsEntry> sSpellCooldownsStore(SpellCooldownsEntryfmt);
DBCStorage <SpellAuraOptionsEntry> sSpellAuraOptionsStore(SpellAuraOptionsEntryfmt);
DBCStorage <SpellAuraRestrictionsEntry> sSpellAuraRestrictionsStore(SpellAuraRestrictionsEntryfmt);
DBCStorage <SpellCastingRequirementsEntry> sSpellCastingRequirementsStore(SpellCastingRequirementsEntryfmt);
-
-SpellEffectMap sSpellEffectMap;
-SpellReagentMap sSpellReagentMap;
-SpellTotemMap sSpellTotemMap;
-
DBCStorage <SpellCastTimesEntry> sSpellCastTimesStore(SpellCastTimefmt);
DBCStorage <SpellCategoriesEntry> sSpellCategoriesStore(SpellCategoriesEntryfmt);
DBCStorage <SpellEffectEntry> sSpellEffectStore(SpellEffectEntryfmt);
@@ -503,40 +498,6 @@ void LoadDBCStores(const std::string& dataPath)
sSpellCategoryStore[spell->Category].insert(i);
}
- for (uint32 j = 0; j < sSkillLineAbilityStore.GetNumRows(); ++j)
- {
- SkillLineAbilityEntry const *skillLine = sSkillLineAbilityStore.LookupEntry(j);
-
- if (!skillLine)
- continue;
-
- SpellEntry const* spellInfo = sSpellStore.LookupEntry(skillLine->spellId);
- if (spellInfo && spellInfo->Attributes & SPELL_ATTR0_PASSIVE)
- {
- for (uint32 i = 1; i < sCreatureFamilyStore.GetNumRows(); ++i)
- {
- SpellLevelsEntry const* levels = sSpellLevelsStore.LookupEntry(i);
- if (!levels)
- continue;
-
- CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(i);
- if (!cFamily)
- continue;
-
- if (skillLine->skillId != cFamily->skillLine[0] && skillLine->skillId != cFamily->skillLine[1])
- continue;
- if (levels->spellLevel)
- continue;
-
- if (skillLine->learnOnGetSkill != ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL)
- continue;
-
- sPetFamilySpellsStore[i].insert(spellInfo->Id);
- }
- }
- }
-
-
LoadDBC(availableDbcLocales, bad_dbc_files, sSpellReagentsStore, dbcPath,"SpellReagents.dbc");//14545
LoadDBC(availableDbcLocales, bad_dbc_files, sSpellScalingStore, dbcPath,"SpellScaling.dbc");//14545
LoadDBC(availableDbcLocales, bad_dbc_files, sSpellTotemsStore, dbcPath,"SpellTotems.dbc");//14545
@@ -550,16 +511,8 @@ void LoadDBCStores(const std::string& dataPath)
LoadDBC(availableDbcLocales, bad_dbc_files, sSpellAuraOptionsStore, dbcPath,"SpellAuraOptions.dbc");//14545
LoadDBC(availableDbcLocales, bad_dbc_files, sSpellAuraRestrictionsStore, dbcPath,"SpellAuraRestrictions.dbc");//14545
LoadDBC(availableDbcLocales, bad_dbc_files, sSpellCastingRequirementsStore, dbcPath,"SpellCastingRequirements.dbc");//14545
-
LoadDBC(availableDbcLocales, bad_dbc_files, sSpellCategoriesStore, dbcPath,"SpellCategories.dbc");//14545
LoadDBC(availableDbcLocales, bad_dbc_files, sSpellEffectStore, dbcPath,"SpellEffect.dbc");//14545
-
- for(uint32 i = 1; i < sSpellEffectStore.GetNumRows(); ++i)
- {
- if(SpellEffectEntry const *spellEffect = sSpellEffectStore.LookupEntry(i))
- sSpellEffectMap[spellEffect->EffectSpellId].effects[spellEffect->EffectIndex] = spellEffect;
- }
-
LoadDBC(availableDbcLocales, bad_dbc_files, sSpellCastTimesStore, dbcPath, "SpellCastTimes.dbc");//14545
LoadDBC(availableDbcLocales, bad_dbc_files, sSpellDifficultyStore, dbcPath, "SpellDifficulty.dbc"/*, &CustomSpellDifficultyfmt, &CustomSpellDifficultyIndex*/);//14545
LoadDBC(availableDbcLocales, bad_dbc_files, sSpellDurationStore, dbcPath, "SpellDuration.dbc");//14545
@@ -574,6 +527,40 @@ void LoadDBCStores(const std::string& dataPath)
//LoadDBC(availableDbcLocales, bad_dbc_files, sStableSlotPricesStore, dbcPath, "StableSlotPrices.dbc");
LoadDBC(availableDbcLocales, bad_dbc_files, sSummonPropertiesStore, dbcPath, "SummonProperties.dbc");//14545
+ // Must be done when sSkillLineAbilityStore, sSpellStore, sSpellLevelsStore and sCreatureFamilyStore are all loaded
+ for (uint32 j = 0; j < sSkillLineAbilityStore.GetNumRows(); ++j)
+ {
+ SkillLineAbilityEntry const *skillLine = sSkillLineAbilityStore.LookupEntry(j);
+ if (!skillLine)
+ continue;
+
+ SpellEntry const* spellInfo = sSpellStore.LookupEntry(skillLine->spellId);
+ if (!spellInfo)
+ continue;
+
+ SpellLevelsEntry const* levels = sSpellLevelsStore.LookupEntry(spellInfo->SpellLevelsId);
+ if (spellInfo->SpellLevelsId && (!levels || levels->spellLevel))
+ continue;
+
+ if (spellInfo && spellInfo->Attributes & SPELL_ATTR0_PASSIVE)
+ {
+ for (uint32 i = 1; i < sCreatureFamilyStore.GetNumRows(); ++i)
+ {
+ CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(i);
+ if (!cFamily)
+ continue;
+
+ if (skillLine->skillId != cFamily->skillLine[0] && skillLine->skillId != cFamily->skillLine[1])
+ continue;
+
+ if (skillLine->learnOnGetSkill != ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL)
+ continue;
+
+ sPetFamilySpellsStore[i].insert(spellInfo->Id);
+ }
+ }
+ }
+
LoadDBC(availableDbcLocales, bad_dbc_files, sTalentStore, dbcPath, "Talent.dbc");//14545
// Create Spelldifficulty searcher
@@ -801,33 +788,6 @@ char const* GetPetName(uint32 petfamily, uint32 /*dbclang*/)
return pet_family->Name ? pet_family->Name : NULL;
}
-SpellEffectEntry const* GetSpellEffectEntry(uint32 spellId, uint32 effect)
-{
- SpellEffectMap::const_iterator itr = sSpellEffectMap.find(spellId);
- if(itr == sSpellEffectMap.end())
- return NULL;
-
- return itr->second.effects[effect];
-}
-
-SpellReagentsEntry const* GetSpellReagentEntry(uint32 spellId, uint8 reagent)
-{
- SpellReagentMap::const_iterator itr = sSpellReagentMap.find(spellId);
- if(itr == sSpellReagentMap.end())
- return NULL;
-
- return itr->second.reagents[reagent];
-}
-
-SpellTotemsEntry const* GetSpellTotemEntry(uint32 spellId, uint8 totem)
-{
- SpellTotemMap::const_iterator itr = sSpellTotemMap.find(spellId);
- if(itr == sSpellTotemMap.end())
- return NULL;
-
- return itr->second.totems[totem];
-}
-
TalentSpellPos const* GetTalentSpellPos(uint32 spellId)
{
TalentSpellPosMap::const_iterator itr = sTalentSpellPosMap.find(spellId);
diff --git a/src/server/game/DataStores/DBCStores.h b/src/server/game/DataStores/DBCStores.h
index 9e8dc76d832..174cf5c4dfb 100755
--- a/src/server/game/DataStores/DBCStores.h
+++ b/src/server/game/DataStores/DBCStores.h
@@ -31,9 +31,6 @@ SimpleFactionsList const* GetFactionTeamList(uint32 faction);
char const* GetPetName(uint32 petfamily, uint32 dbclang);
uint32 GetTalentSpellCost(uint32 spellId);
TalentSpellPos const* GetTalentSpellPos(uint32 spellId);
-SpellEffectEntry const* GetSpellEffectEntry(uint32 spellId, uint32 effect);
-SpellReagentsEntry const* GetSpellReagentEntry(uint32 spellId, uint8 reagent);
-SpellTotemsEntry const* GetSpellTotemEntry(uint32 spellId, uint8 totem);
int32 GetAreaFlagByAreaID(uint32 area_id); // -1 if not found
AreaTableEntry const* GetAreaEntryByAreaID(uint32 area_id);
diff --git a/src/server/game/DataStores/DBCStructure.h b/src/server/game/DataStores/DBCStructure.h
index 552c4d81472..ded0ff65a94 100644
--- a/src/server/game/DataStores/DBCStructure.h
+++ b/src/server/game/DataStores/DBCStructure.h
@@ -1750,18 +1750,6 @@ struct SpellTotemsEntry
uint32 Totem[MAX_SPELL_TOTEMS]; // 2 m_totem
};
-struct SpellTotem
-{
- SpellTotem()
- {
- totems[0] = NULL;
- totems[1] = NULL;
- }
- SpellTotemsEntry const* totems[MAX_SPELL_TOTEMS];
-};
-
-typedef std::map<uint32, SpellTotem> SpellTotemMap;
-
// Spell.dbc
struct SpellEntry
{
@@ -1812,9 +1800,6 @@ struct SpellEntry
uint32 SpellTargetRestrictionsId; // 45 SpellTargetRestrictions.dbc
uint32 SpellTotemsId; // 46 SpellTotems.dbc
//uint32 ResearchProject; // 47 ResearchProject.dbc
-
- // struct access functions
- SpellEffectEntry const* GetSpellEffect(uint32 eff) const;
};
// SpellCategories.dbc
@@ -1994,24 +1979,6 @@ struct SpellReagentsEntry
uint32 ReagentCount[MAX_SPELL_REAGENTS]; // 62-69 m_reagentCount
};
-struct SpellReagent
-{
- SpellReagent()
- {
- reagents[0] = NULL;
- reagents[1] = NULL;
- reagents[2] = NULL;
- reagents[3] = NULL;
- reagents[4] = NULL;
- reagents[5] = NULL;
- reagents[6] = NULL;
- reagents[7] = NULL;
- }
- SpellReagentsEntry const* reagents[MAX_SPELL_REAGENTS];
-};
-
-typedef std::map<uint32, SpellReagent> SpellReagentMap;
-
// SpellScaling.dbc
struct SpellScalingEntry
{
@@ -2403,19 +2370,6 @@ struct TalentSpellPos
typedef std::map<uint32, TalentSpellPos> TalentSpellPosMap;
-struct SpellEffect
-{
- SpellEffect()
- {
- effects[0] = NULL;
- effects[1] = NULL;
- effects[2] = NULL;
- }
- SpellEffectEntry const* effects[3];
-};
-
-typedef std::map<uint32, SpellEffect> SpellEffectMap;
-
struct TaxiPathBySourceAndDestination
{
TaxiPathBySourceAndDestination() : ID(0), price(0) {}
diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp
index 28e865fdcdc..c497ee6203a 100644
--- a/src/server/game/Spells/SpellInfo.cpp
+++ b/src/server/game/Spells/SpellInfo.cpp
@@ -317,13 +317,12 @@ SpellImplicitTargetInfo::StaticData SpellImplicitTargetInfo::_data[TOTAL_SPELL_
{TARGET_OBJECT_TYPE_DEST, TARGET_REFERENCE_TYPE_NONE, TARGET_SELECT_CATEGORY_NYI, TARGET_CHECK_DEFAULT, TARGET_DIR_NONE}, // 110 TARGET_DEST_UNK_110
};
-SpellEffectInfo::SpellEffectInfo(SpellEntry const* spellEntry, SpellInfo const* spellInfo, uint8 effIndex)
+SpellEffectInfo::SpellEffectInfo(SpellEntry const* spellEntry, SpellInfo const* spellInfo, uint8 effIndex, SpellEffectEntry const* _effect)
{
- SpellEffectEntry const* _effect = spellEntry->GetSpellEffect(effIndex);
SpellScalingEntry const* scaling = spellInfo->GetSpellScaling();
_spellInfo = spellInfo;
- _effIndex = effIndex;
+ _effIndex = _effect ? _effect->EffectIndex : effIndex;
Effect = _effect ? _effect->Effect : 0;
ApplyAuraName = _effect ? _effect->EffectApplyAuraName : 0;
Amplitude = _effect ? _effect->EffectAmplitude : 0;
@@ -345,9 +344,9 @@ SpellEffectInfo::SpellEffectInfo(SpellEntry const* spellEntry, SpellInfo const*
TriggerSpell = _effect ? _effect->EffectTriggerSpell : 0;
SpellClassMask = _effect ? _effect->EffectSpellClassMask : flag96(0);
ImplicitTargetConditions = NULL;
- ScalingMultiplier = scaling ? scaling->Multiplier[effIndex] : 0.0f;
- DeltaScalingMultiplier = scaling ? scaling->RandomMultiplier[effIndex] : 0.0f;
- ComboScalingMultiplier = scaling ? scaling->OtherMultiplier[effIndex] : 0.0f;
+ ScalingMultiplier = scaling ? scaling->Multiplier[_effIndex] : 0.0f;
+ DeltaScalingMultiplier = scaling ? scaling->RandomMultiplier[_effIndex] : 0.0f;
+ ComboScalingMultiplier = scaling ? scaling->OtherMultiplier[_effIndex] : 0.0f;
}
bool SpellEffectInfo::IsEffect() const
@@ -754,7 +753,7 @@ SpellEffectInfo::StaticData SpellEffectInfo::_data[TOTAL_SPELL_EFFECTS] =
{EFFECT_IMPLICIT_TARGET_EXPLICIT, TARGET_OBJECT_TYPE_UNIT}, // 164 SPELL_EFFECT_REMOVE_AURA
};
-SpellInfo::SpellInfo(SpellEntry const* spellEntry)
+SpellInfo::SpellInfo(SpellEntry const* spellEntry, SpellEffectEntry const** effects)
{
Id = spellEntry->Id;
Attributes = spellEntry->Attributes;
@@ -801,7 +800,7 @@ SpellInfo::SpellInfo(SpellEntry const* spellEntry)
// SpellDifficultyEntry
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
- Effects[i] = SpellEffectInfo(spellEntry, this, i);
+ Effects[i] = SpellEffectInfo(spellEntry, this, i, effects[i]);
// SpellScalingEntry
SpellScalingEntry const* _scaling = GetSpellScaling();
@@ -2687,11 +2686,6 @@ SpellCooldownsEntry const* SpellInfo::GetSpellCooldowns() const
return SpellCooldownsId ? sSpellCooldownsStore.LookupEntry(SpellCooldownsId) : NULL;
}
-SpellEffectEntry const* SpellEntry::GetSpellEffect(uint32 eff) const
-{
- return GetSpellEffectEntry(Id, eff);
-}
-
void SpellInfo::_UnloadImplicitTargetConditionLists()
{
// find the same instances of ConditionList and delete them.
diff --git a/src/server/game/Spells/SpellInfo.h b/src/server/game/Spells/SpellInfo.h
index 9dcf0140933..d8115569f25 100644
--- a/src/server/game/Spells/SpellInfo.h
+++ b/src/server/game/Spells/SpellInfo.h
@@ -257,7 +257,7 @@ public:
float ComboScalingMultiplier;
SpellEffectInfo() {}
- SpellEffectInfo(SpellEntry const* spellEntry, SpellInfo const* spellInfo, uint8 effIndex);
+ SpellEffectInfo(SpellEntry const* spellEntry, SpellInfo const* spellInfo, uint8 effIndex, SpellEffectEntry const* effect);
bool IsEffect() const;
bool IsEffect(SpellEffects effectName) const;
@@ -413,7 +413,7 @@ public:
SpellShapeshiftEntry const* GetSpellShapeshift() const;
SpellTotemsEntry const* GetSpellTotems() const;
- SpellInfo(SpellEntry const* spellEntry);
+ SpellInfo(SpellEntry const* spellEntry, SpellEffectEntry const** effects);
~SpellInfo();
bool HasEffect(SpellEffects effect) const;
diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp
index c3d5f5c68c1..82a712209ec 100644
--- a/src/server/game/Spells/SpellMgr.cpp
+++ b/src/server/game/Spells/SpellMgr.cpp
@@ -2630,10 +2630,39 @@ void SpellMgr::LoadSpellInfoStore()
UnloadSpellInfoStore();
mSpellInfoMap.resize(sSpellStore.GetNumRows(), NULL);
+ // Temporary structure to hold spell effect entries for faster loading
+ struct SpellEffectArray
+ {
+ SpellEffectArray()
+ {
+ effects[0] = NULL;
+ effects[1] = NULL;
+ effects[2] = NULL;
+ }
+
+ SpellEffectEntry const* effects[MAX_SPELL_EFFECTS];
+
+ SpellEffectEntry const*& operator[](int index)
+ {
+ return effects[index];
+ }
+ };
+
+ std::map<uint32, SpellEffectArray> effectsBySpell;
+
+ for (uint32 i = 0; i < sSpellEffectStore.GetNumRows(); ++i)
+ {
+ SpellEffectEntry const* effect = sSpellEffectStore.LookupEntry(i);
+ if (!effect)
+ continue;
+
+ effectsBySpell[effect->EffectSpellId][effect->EffectIndex] = effect;
+ }
+
for (uint32 i = 0; i < sSpellStore.GetNumRows(); ++i)
{
if (SpellEntry const* spellEntry = sSpellStore.LookupEntry(i))
- mSpellInfoMap[i] = new SpellInfo(spellEntry);
+ mSpellInfoMap[i] = new SpellInfo(spellEntry, effectsBySpell[i].effects);
}
sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded spell info store in %u ms", GetMSTimeDiffToNow(oldMSTime));