diff options
-rw-r--r-- | src/server/game/DataStores/DBCStores.cpp | 10 | ||||
-rw-r--r-- | src/server/game/DataStores/DBCStores.h | 1 | ||||
-rw-r--r-- | src/server/game/Entities/Player/Player.cpp | 17 | ||||
-rw-r--r-- | src/server/game/Spells/SpellMgr.cpp | 17 | ||||
-rw-r--r-- | src/server/scripts/Commands/cs_learn.cpp | 14 |
5 files changed, 29 insertions, 30 deletions
diff --git a/src/server/game/DataStores/DBCStores.cpp b/src/server/game/DataStores/DBCStores.cpp index eb6ca3c3a49..2997c8b8af0 100644 --- a/src/server/game/DataStores/DBCStores.cpp +++ b/src/server/game/DataStores/DBCStores.cpp @@ -18,6 +18,7 @@ #include "DBCStores.h" #include "DBCFileLoader.h" #include "DBCfmt.h" +#include "Containers.h" #include "Errors.h" #include "IteratorPair.h" #include "Log.h" @@ -156,7 +157,9 @@ DBCStorage <ScalingStatValuesEntry> sScalingStatValuesStore(ScalingStatValuesfmt DBCStorage <SkillLineEntry> sSkillLineStore(SkillLinefmt); DBCStorage <SkillLineAbilityEntry> sSkillLineAbilityStore(SkillLineAbilityfmt); DBCStorage <SkillRaceClassInfoEntry> sSkillRaceClassInfoStore(SkillRaceClassInfofmt); +std::unordered_map<uint32, std::vector<SkillLineAbilityEntry const*>> SkillLineAbilitiesBySkill; SkillRaceClassInfoMap SkillRaceClassInfoBySkill; + DBCStorage <SkillTiersEntry> sSkillTiersStore(SkillTiersfmt); DBCStorage <SoundEntriesEntry> sSoundEntriesStore(SoundEntriesfmt); @@ -497,6 +500,8 @@ void LoadDBCStores(const std::string& dataPath) sPetFamilySpellsStore[cFamily->ID].insert(spellInfo->ID); } } + + SkillLineAbilitiesBySkill[skillLine->SkillLine].push_back(skillLine); } // Create Spelldifficulty searcher @@ -937,6 +942,11 @@ uint32 GetDefaultMapLight(uint32 mapId) return 0; } +std::vector<SkillLineAbilityEntry const*> const* GetSkillLineAbilitiesBySkill(uint32 skillLine) +{ + return Trinity::Containers::MapGetValuePtr(SkillLineAbilitiesBySkill, skillLine); +} + SkillRaceClassInfoEntry const* GetSkillRaceClassInfo(uint32 skill, uint8 race, uint8 class_) { SkillRaceClassInfoBounds bounds = SkillRaceClassInfoBySkill.equal_range(skill); diff --git a/src/server/game/DataStores/DBCStores.h b/src/server/game/DataStores/DBCStores.h index f3974d09307..0ac62982c18 100644 --- a/src/server/game/DataStores/DBCStores.h +++ b/src/server/game/DataStores/DBCStores.h @@ -81,6 +81,7 @@ TC_GAME_API uint32 GetDefaultMapLight(uint32 mapId); typedef std::unordered_multimap<uint32, SkillRaceClassInfoEntry const*> SkillRaceClassInfoMap; typedef std::pair<SkillRaceClassInfoMap::iterator, SkillRaceClassInfoMap::iterator> SkillRaceClassInfoBounds; +TC_GAME_API std::vector<SkillLineAbilityEntry const*> const* GetSkillLineAbilitiesBySkill(uint32 skill); TC_GAME_API SkillRaceClassInfoEntry const* GetSkillRaceClassInfo(uint32 skill, uint8 race, uint8 class_); TC_GAME_API ResponseCodes ValidateName(std::wstring const& name, LocaleConstant locale); diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 1a6763e059c..8fb15a50f76 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -6021,10 +6021,9 @@ void Player::SetSkill(uint32 id, uint16 step, uint16 newVal, uint16 maxVal) mSkillStatus.erase(itr); // remove all spells that related to this skill - for (uint32 j = 0; j < sSkillLineAbilityStore.GetNumRows(); ++j) - if (SkillLineAbilityEntry const* pAbility = sSkillLineAbilityStore.LookupEntry(j)) - if (pAbility->SkillLine == id) - RemoveSpell(sSpellMgr->GetFirstSpellInChain(pAbility->Spell)); + if (std::vector<SkillLineAbilityEntry const*> const* skillLineAbilities = GetSkillLineAbilitiesBySkill(id)) + for (SkillLineAbilityEntry const* skillLineAbility : *skillLineAbilities) + RemoveSpell(sSpellMgr->GetFirstSpellInChain(skillLineAbility->Spell)); } } else if (newVal) //add @@ -23153,12 +23152,12 @@ void Player::LearnSkillRewardedSpells(uint32 skillId, uint32 skillValue) { uint32 raceMask = GetRaceMask(); uint32 classMask = GetClassMask(); - for (uint32 j = 0; j < sSkillLineAbilityStore.GetNumRows(); ++j) - { - SkillLineAbilityEntry const* ability = sSkillLineAbilityStore.LookupEntry(j); - if (!ability || ability->SkillLine != skillId) - continue; + std::vector<SkillLineAbilityEntry const*> const* skillLineAbilities = GetSkillLineAbilitiesBySkill(skillId); + if (!skillLineAbilities) + return; + for (SkillLineAbilityEntry const* ability : *skillLineAbilities) + { if (!sSpellMgr->GetSpellInfo(ability->Spell)) continue; diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index c0a2a1ba80b..b7c1e3159ef 100644 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -2197,19 +2197,12 @@ void SpellMgr::LoadPetLevelupSpellMap() if (!creatureFamily->SkillLine[j]) continue; - for (uint32 k = 0; k < sSkillLineAbilityStore.GetNumRows(); ++k) - { - SkillLineAbilityEntry const* skillLine = sSkillLineAbilityStore.LookupEntry(k); - if (!skillLine) - continue; - - //if (skillLine->skillId != creatureFamily->SkillLine[0] && - // (!creatureFamily->SkillLine[1] || skillLine->skillId != creatureFamily->SkillLine[1])) - // continue; - - if (skillLine->SkillLine != creatureFamily->SkillLine[j]) - continue; + std::vector<SkillLineAbilityEntry const*> const* skillLineAbilities = GetSkillLineAbilitiesBySkill(creatureFamily->SkillLine[j]); + if (!skillLineAbilities) + continue; + for (SkillLineAbilityEntry const* skillLine : *skillLineAbilities) + { if (skillLine->AcquireMethod != SKILL_LINE_ABILITY_LEARNED_ON_SKILL_LEARN) continue; diff --git a/src/server/scripts/Commands/cs_learn.cpp b/src/server/scripts/Commands/cs_learn.cpp index 86e625f9d1b..57fe66a981f 100644 --- a/src/server/scripts/Commands/cs_learn.cpp +++ b/src/server/scripts/Commands/cs_learn.cpp @@ -435,16 +435,12 @@ public: { uint32 classmask = player->GetClassMask(); - for (uint32 j = 0; j < sSkillLineAbilityStore.GetNumRows(); ++j) - { - SkillLineAbilityEntry const* skillLine = sSkillLineAbilityStore.LookupEntry(j); - if (!skillLine) - continue; - - // wrong skill - if (skillLine->SkillLine != skillId) - continue; + std::vector<SkillLineAbilityEntry const*> const* skillLineAbilities = GetSkillLineAbilitiesBySkill(skillId); + if (!skillLineAbilities) + return; + for (SkillLineAbilityEntry const* skillLine : *skillLineAbilities) + { // not high rank if (skillLine->SupercededBySpell) continue; |