diff options
| author | Shauren <shauren.trinity@gmail.com> | 2015-03-08 13:31:57 +0100 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2015-03-08 13:31:57 +0100 |
| commit | 0ba2e0d5ee416a2daf89d53877984fb0cf27ca9b (patch) | |
| tree | 0cb086bb038bf7d3164b9c25dab9ecd1bf93cad6 /src/server/game/DataStores | |
| parent | 9ffeb58d094ddba9bffb33a79b33ade9af9f5c00 (diff) | |
Core/Spells: Implemented multiple spell power costs
Diffstat (limited to 'src/server/game/DataStores')
| -rw-r--r-- | src/server/game/DataStores/DB2Stores.cpp | 63 | ||||
| -rw-r--r-- | src/server/game/DataStores/DB2Stores.h | 6 | ||||
| -rw-r--r-- | src/server/game/DataStores/DB2Structure.h | 9 | ||||
| -rw-r--r-- | src/server/game/DataStores/DB2fmt.h | 1 |
4 files changed, 74 insertions, 5 deletions
diff --git a/src/server/game/DataStores/DB2Stores.cpp b/src/server/game/DataStores/DB2Stores.cpp index f6fb39fea75..3efb2297c93 100644 --- a/src/server/game/DataStores/DB2Stores.cpp +++ b/src/server/game/DataStores/DB2Stores.cpp @@ -50,6 +50,7 @@ DB2Storage<SpellClassOptionsEntry> sSpellClassOptionsStore("SpellClassO DB2Storage<SpellLearnSpellEntry> sSpellLearnSpellStore("SpellLearnSpell.db2", SpellLearnSpellFormat, HOTFIX_SEL_SPELL_LEARN_SPELL); DB2Storage<SpellMiscEntry> sSpellMiscStore("SpellMisc.db2", SpellMiscFormat, HOTFIX_SEL_SPELL_MISC); DB2Storage<SpellPowerEntry> sSpellPowerStore("SpellPower.db2", SpellPowerFormat, HOTFIX_SEL_SPELL_POWER); +DB2Storage<SpellPowerDifficultyEntry> sSpellPowerDifficultyStore("SpellPowerDifficulty.db2", SpellPowerDifficultyFormat, HOTFIX_SEL_SPELL_POWER_DIFFICULTY); DB2Storage<SpellReagentsEntry> sSpellReagentsStore("SpellReagents.db2", SpellReagentsFormat, HOTFIX_SEL_SPELL_REAGENTS); DB2Storage<SpellRuneCostEntry> sSpellRuneCostStore("SpellRuneCost.db2", SpellRuneCostFormat, HOTFIX_SEL_SPELL_RUNE_COST); DB2Storage<SpellTotemsEntry> sSpellTotemsStore("SpellTotems.db2", SpellTotemsFormat, HOTFIX_SEL_SPELL_TOTEMS); @@ -57,7 +58,6 @@ DB2Storage<TaxiNodesEntry> sTaxiNodesStore("TaxiNodes.db2", Tax DB2Storage<TaxiPathEntry> sTaxiPathStore("TaxiPath.db2", TaxiPathFormat, HOTFIX_SEL_TAXI_PATH); DB2Storage<TaxiPathNodeEntry> sTaxiPathNodeStore("TaxiPathNode.db2", TaxiPathNodeFormat, HOTFIX_SEL_TAXI_PATH_NODE); -SpellPowerBySpellIDMap sSpellPowerBySpellIDStore; TaxiMask sTaxiNodesMask; TaxiMask sOldContinentsNodesMask; TaxiMask sHordeTaxiNodesMask; @@ -199,7 +199,24 @@ void DB2Manager::LoadStores(std::string const& dataPath) _phasesByGroup[group->PhaseGroupID].insert(phase->ID); for (SpellPowerEntry const* power : sSpellPowerStore) - sSpellPowerBySpellIDStore[power->SpellID] = power; + { + if (SpellPowerDifficultyEntry const* powerDifficulty = sSpellPowerDifficultyStore.LookupEntry(power->ID)) + { + std::vector<SpellPowerEntry const*>& powers = _spellPowerDifficulties[power->SpellID][powerDifficulty->DifficultyID]; + if (powers.size() <= powerDifficulty->PowerIndex) + powers.resize(powerDifficulty->PowerIndex + 1); + + powers[powerDifficulty->PowerIndex] = power; + } + else + { + std::vector<SpellPowerEntry const*>& powers = _spellPowers[power->SpellID]; + if (powers.size() <= power->PowerIndex) + powers.resize(power->PowerIndex + 1); + + powers[power->PowerIndex] = power; + } + } for (TaxiPathEntry const* entry : sTaxiPathStore) sTaxiPathSetBySource[entry->From][entry->To] = TaxiPathBySourceAndDestination(entry->ID, entry->Cost); @@ -475,3 +492,45 @@ std::set<uint32> DB2Manager::GetPhasesForGroup(uint32 group) const return std::set<uint32>(); } + +std::vector<SpellPowerEntry const*> DB2Manager::GetSpellPowers(uint32 spellId, Difficulty difficulty /*= DIFFICULTY_NONE*/, bool* hasDifficultyPowers /*= nullptr*/) const +{ + std::vector<SpellPowerEntry const*> powers; + + auto difficultyItr = _spellPowerDifficulties.find(spellId); + if (difficultyItr != _spellPowerDifficulties.end()) + { + if (hasDifficultyPowers) + *hasDifficultyPowers = true; + + DifficultyEntry const* difficultyEntry = sDifficultyStore.LookupEntry(difficulty); + while (difficultyEntry) + { + auto powerDifficultyItr = difficultyItr->second.find(difficultyEntry->ID); + if (powerDifficultyItr != difficultyItr->second.end()) + { + if (powerDifficultyItr->second.size() > powers.size()) + powers.resize(powerDifficultyItr->second.size()); + + for (SpellPowerEntry const* difficultyPower : powerDifficultyItr->second) + if (!powers[difficultyPower->PowerIndex]) + powers[difficultyPower->PowerIndex] = difficultyPower; + } + + difficultyEntry = sDifficultyStore.LookupEntry(difficultyEntry->FallbackDifficultyID); + } + } + + auto itr = _spellPowers.find(spellId); + if (itr != _spellPowers.end()) + { + if (itr->second.size() > powers.size()) + powers.resize(itr->second.size()); + + for (SpellPowerEntry const* power : itr->second) + if (!powers[power->PowerIndex]) + powers[power->PowerIndex] = power; + } + + return powers; +} diff --git a/src/server/game/DataStores/DB2Stores.h b/src/server/game/DataStores/DB2Stores.h index 3dff3d2a4c0..8fdf23ec58c 100644 --- a/src/server/game/DataStores/DB2Stores.h +++ b/src/server/game/DataStores/DB2Stores.h @@ -44,7 +44,6 @@ extern DB2Storage<SpellTotemsEntry> sSpellTotemsStore; extern DB2Storage<TaxiNodesEntry> sTaxiNodesStore; extern DB2Storage<TaxiPathEntry> sTaxiPathStore; -extern SpellPowerBySpellIDMap sSpellPowerBySpellIDStore; extern TaxiMask sTaxiNodesMask; extern TaxiMask sOldContinentsNodesMask; extern TaxiMask sHordeTaxiNodesMask; @@ -75,6 +74,8 @@ public: typedef std::unordered_map<uint32, std::set<ItemBonusTreeNodeEntry const*>> ItemBonusTreeContainer; typedef std::unordered_map<uint32, MountEntry const*> MountContainer; typedef std::unordered_map<uint32, std::set<uint32>> PhaseGroupContainer; + typedef std::unordered_map<uint32, std::vector<SpellPowerEntry const*>> SpellPowerContainer; + typedef std::unordered_map<uint32, std::unordered_map<uint32, std::vector<SpellPowerEntry const*>>> SpellPowerDifficultyContainer; static DB2Manager& Instance() { @@ -97,6 +98,7 @@ public: uint32 GetItemDisplayId(uint32 itemId, uint32 appearanceModId) const; MountEntry const* GetMount(uint32 spellId) const; std::set<uint32> GetPhasesForGroup(uint32 group) const; + std::vector<SpellPowerEntry const*> GetSpellPowers(uint32 spellId, Difficulty difficulty = DIFFICULTY_NONE, bool* hasDifficultyPowers = nullptr) const; private: StorageMap _stores; @@ -110,6 +112,8 @@ private: ItemToBonusTreeContainer _itemToBonusTree; MountContainer _mountsBySpellId; PhaseGroupContainer _phasesByGroup; + SpellPowerContainer _spellPowers; + SpellPowerDifficultyContainer _spellPowerDifficulties; }; #define sDB2Manager DB2Manager::Instance() diff --git a/src/server/game/DataStores/DB2Structure.h b/src/server/game/DataStores/DB2Structure.h index 6c333b70682..e52acc0e2c3 100644 --- a/src/server/game/DataStores/DB2Structure.h +++ b/src/server/game/DataStores/DB2Structure.h @@ -405,6 +405,13 @@ struct SpellPowerEntry float HealthCostPercentage; // 13 }; +struct SpellPowerDifficultyEntry +{ + uint32 SpellPowerID; // 0 + uint32 DifficultyID; // 1 + uint32 PowerIndex; // 2 +}; + #define MAX_SPELL_REAGENTS 8 struct SpellReagentsEntry @@ -471,8 +478,6 @@ struct TaxiPathNodeEntry #pragma pack(pop) -typedef std::map<uint32, SpellPowerEntry const*> SpellPowerBySpellIDMap; - struct TaxiPathBySourceAndDestination { TaxiPathBySourceAndDestination() : ID(0), price(0) { } diff --git a/src/server/game/DataStores/DB2fmt.h b/src/server/game/DataStores/DB2fmt.h index 1920f2b90b4..baab3cf9302 100644 --- a/src/server/game/DataStores/DB2fmt.h +++ b/src/server/game/DataStores/DB2fmt.h @@ -45,6 +45,7 @@ char const SpellClassOptionsFormat[] = "niiiiii"; char const SpellLearnSpellFormat[] = "niii"; char const SpellMiscFormat[] = "niiiiiiiiiiiiiiiiifiiiiif"; char const SpellPowerFormat[] = "niiiiiiiiiffif"; +char const SpellPowerDifficultyFormat[] = "nii"; char const SpellReagentsFormat[] = "niiiiiiiiiiiiiiiiii"; char const SpellRuneCostFormat[] = "niiiii"; char const SpellTotemsFormat[] = "niiii"; |
