diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/DataStores/DBCStores.cpp | 105 | ||||
-rw-r--r-- | src/server/game/DataStores/DBCStores.h | 55 | ||||
-rw-r--r-- | src/server/game/DataStores/DBCStructure.h | 15 | ||||
-rw-r--r-- | src/server/game/DataStores/DBCfmt.h | 1 | ||||
-rw-r--r-- | src/server/game/Entities/Player/Player.cpp | 43 | ||||
-rw-r--r-- | src/server/game/Entities/Unit/StatSystem.cpp | 2 | ||||
-rw-r--r-- | src/server/game/Globals/ObjectMgr.cpp | 4 | ||||
-rw-r--r-- | src/server/game/Quests/QuestDef.cpp | 3 | ||||
-rw-r--r-- | src/server/game/Spells/SpellInfo.cpp | 10 |
9 files changed, 155 insertions, 83 deletions
diff --git a/src/server/game/DataStores/DBCStores.cpp b/src/server/game/DataStores/DBCStores.cpp index 325a1d9a6db..a8d2725d023 100644 --- a/src/server/game/DataStores/DBCStores.cpp +++ b/src/server/game/DataStores/DBCStores.cpp @@ -101,25 +101,25 @@ DBCStorage <FactionEntry> sFactionStore(FactionEntryfmt); DBCStorage <FactionTemplateEntry> sFactionTemplateStore(FactionTemplateEntryfmt); DBCStorage <GameObjectDisplayInfoEntry> sGameObjectDisplayInfoStore(GameObjectDisplayInfofmt); +DBCStorage <GameTablesEntry> sGameTablesStore(GameTablesFmt); DBCStorage <GemPropertiesEntry> sGemPropertiesStore(GemPropertiesEntryfmt); DBCStorage <GlyphPropertiesEntry> sGlyphPropertiesStore(GlyphPropertiesfmt); DBCStorage <GlyphSlotEntry> sGlyphSlotStore(GlyphSlotfmt); -DBCStorage <GtBarberShopCostBaseEntry> sGtBarberShopCostBaseStore(GtBarberShopCostBasefmt); -DBCStorage <GtCombatRatingsEntry> sGtCombatRatingsStore(GtCombatRatingsfmt); -DBCStorage <GtChanceToMeleeCritBaseEntry> sGtChanceToMeleeCritBaseStore(GtChanceToMeleeCritBasefmt); -DBCStorage <GtChanceToMeleeCritEntry> sGtChanceToMeleeCritStore(GtChanceToMeleeCritfmt); -DBCStorage <GtChanceToSpellCritBaseEntry> sGtChanceToSpellCritBaseStore(GtChanceToSpellCritBasefmt); -DBCStorage <GtChanceToSpellCritEntry> sGtChanceToSpellCritStore(GtChanceToSpellCritfmt); -DBCStorage <GtNPCManaCostScalerEntry> sGtNPCManaCostScalerStore(GtNPCManaCostScalerfmt); -DBCStorage <GtOCTClassCombatRatingScalarEntry> sGtOCTClassCombatRatingScalarStore(GtOCTClassCombatRatingScalarfmt); -DBCStorage <GtOCTRegenHPEntry> sGtOCTRegenHPStore(GtOCTRegenHPfmt); -//DBCStorage <GtOCTRegenMPEntry> sGtOCTRegenMPStore(GtOCTRegenMPfmt); -- not used currently -DBCStorage <gtOCTHpPerStaminaEntry> sGtOCTHpPerStaminaStore(GtOCTHpPerStaminafmt); -DBCStorage <GtRegenMPPerSptEntry> sGtRegenMPPerSptStore(GtRegenMPPerSptfmt); -DBCStorage <GtSpellScalingEntry> sGtSpellScalingStore(GtSpellScalingfmt); -DBCStorage <GtOCTBaseHPByClassEntry> sGtOCTBaseHPByClassStore(GtOCTBaseHPByClassfmt); -DBCStorage <GtOCTBaseMPByClassEntry> sGtOCTBaseMPByClassStore(GtOCTBaseMPByClassfmt); +GameTable <GtBarberShopCostBaseEntry> sGtBarberShopCostBaseStore(GtBarberShopCostBasefmt); +GameTable <GtCombatRatingsEntry> sGtCombatRatingsStore(GtCombatRatingsfmt); +GameTable <GtChanceToMeleeCritBaseEntry> sGtChanceToMeleeCritBaseStore(GtChanceToMeleeCritBasefmt); +GameTable <GtChanceToMeleeCritEntry> sGtChanceToMeleeCritStore(GtChanceToMeleeCritfmt); +GameTable <GtChanceToSpellCritBaseEntry> sGtChanceToSpellCritBaseStore(GtChanceToSpellCritBasefmt); +GameTable <GtChanceToSpellCritEntry> sGtChanceToSpellCritStore(GtChanceToSpellCritfmt); +GameTable <GtNPCManaCostScalerEntry> sGtNPCManaCostScalerStore(GtNPCManaCostScalerfmt); +GameTable <GtOCTClassCombatRatingScalarEntry> sGtOCTClassCombatRatingScalarStore(GtOCTClassCombatRatingScalarfmt); +GameTable <GtOCTRegenHPEntry> sGtOCTRegenHPStore(GtOCTRegenHPfmt); +GameTable <gtOCTHpPerStaminaEntry> sGtOCTHpPerStaminaStore(GtOCTHpPerStaminafmt); +GameTable <GtRegenMPPerSptEntry> sGtRegenMPPerSptStore(GtRegenMPPerSptfmt); +GameTable <GtSpellScalingEntry> sGtSpellScalingStore(GtSpellScalingfmt); +GameTable <GtOCTBaseHPByClassEntry> sGtOCTBaseHPByClassStore(GtOCTBaseHPByClassfmt); +GameTable <GtOCTBaseMPByClassEntry> sGtOCTBaseMPByClassStore(GtOCTBaseMPByClassfmt); DBCStorage <GuildPerkSpellsEntry> sGuildPerkSpellsStore(GuildPerkSpellsfmt); DBCStorage <ImportPriceArmorEntry> sImportPriceArmorStore(ImportPriceArmorfmt); @@ -287,6 +287,51 @@ inline void LoadDBC(uint32& availableDbcLocales, StoreProblemList& errors, DBCSt delete sql; } +template<class T> +inline void LoadGameTable(StoreProblemList& errors, std::string const& tableName, GameTable<T>& storage, std::string const& dbcPath, std::string const& filename) +{ + // compatibility format and C++ structure sizes + ASSERT(DBCFileLoader::GetFormatRecordSize(storage.GetFormat()) == sizeof(T) || LoadDBC_assert_print(DBCFileLoader::GetFormatRecordSize(storage.GetFormat()), sizeof(T), filename)); + + ++DBCFileCount; + std::string dbcFilename = dbcPath + filename; + + if (storage.Load(dbcFilename.c_str())) + { + bool found = false; + // Find table definition in GameTables.dbc + for (uint32 i = 0; i < sGameTablesStore.GetNumRows(); ++i) + { + GameTablesEntry const* gt = sGameTablesStore.LookupEntry(i); + if (!gt) + continue; + + if (tableName == gt->Name) + { + found = true; + storage.SetGameTableEntry(gt); + break; + } + } + + ASSERT(found, "Game table %s definition not found in GameTables.dbc", tableName.c_str()); + } + else + { + // sort problematic dbc to (1) non compatible and (2) non-existed + if (FILE* f = fopen(dbcFilename.c_str(), "rb")) + { + std::ostringstream stream; + stream << dbcFilename << " exists, and has " << storage.GetFieldCount() << " field(s) (expected " << strlen(storage.GetFormat()) << "). Extracted file might be from wrong client version or a database-update has been forgotten."; + std::string buf = stream.str(); + errors.push_back(buf); + fclose(f); + } + else + errors.push_back(dbcFilename); + } +} + void LoadDBCStores(const std::string& dataPath) { uint32 oldMSTime = getMSTime(); @@ -396,24 +441,10 @@ void LoadDBCStores(const std::string& dataPath) } } + LoadDBC(availableDbcLocales, bad_dbc_files, sGameTablesStore, dbcPath, "GameTables.dbc");//19243 LoadDBC(availableDbcLocales, bad_dbc_files, sGemPropertiesStore, dbcPath, "GemProperties.dbc");//19116 LoadDBC(availableDbcLocales, bad_dbc_files, sGlyphPropertiesStore, dbcPath, "GlyphProperties.dbc");//19116 LoadDBC(availableDbcLocales, bad_dbc_files, sGlyphSlotStore, dbcPath, "GlyphSlot.dbc");//19116 - LoadDBC(availableDbcLocales, bad_dbc_files, sGtBarberShopCostBaseStore, dbcPath, "gtBarberShopCostBase.dbc");//15595 - LoadDBC(availableDbcLocales, bad_dbc_files, sGtCombatRatingsStore, dbcPath, "gtCombatRatings.dbc");//15595 - LoadDBC(availableDbcLocales, bad_dbc_files, sGtChanceToMeleeCritBaseStore, dbcPath, "gtChanceToMeleeCritBase.dbc");//15595 - LoadDBC(availableDbcLocales, bad_dbc_files, sGtChanceToMeleeCritStore, dbcPath, "gtChanceToMeleeCrit.dbc");//15595 - LoadDBC(availableDbcLocales, bad_dbc_files, sGtChanceToSpellCritBaseStore, dbcPath, "gtChanceToSpellCritBase.dbc");//15595 - LoadDBC(availableDbcLocales, bad_dbc_files, sGtChanceToSpellCritStore, dbcPath, "gtChanceToSpellCrit.dbc");//15595 - LoadDBC(availableDbcLocales, bad_dbc_files, sGtNPCManaCostScalerStore, dbcPath, "gtNPCManaCostScaler.dbc"); - LoadDBC(availableDbcLocales, bad_dbc_files, sGtOCTClassCombatRatingScalarStore, dbcPath, "gtOCTClassCombatRatingScalar.dbc");//15595 - //LoadDBC(availableDbcLocales, bad_dbc_files, sGtOCTRegenHPStore, dbcPath, "gtOCTRegenHP.dbc");//15595 - LoadDBC(availableDbcLocales, bad_dbc_files, sGtOCTHpPerStaminaStore, dbcPath, "gtOCTHpPerStamina.dbc");//15595 - //LoadDBC(dbcCount, availableDbcLocales, bad_dbc_files, sGtOCTRegenMPStore, dbcPath, "gtOCTRegenMP.dbc"); -- not used currently - LoadDBC(availableDbcLocales, bad_dbc_files, sGtRegenMPPerSptStore, dbcPath, "gtRegenMPPerSpt.dbc");//15595 - LoadDBC(availableDbcLocales, bad_dbc_files, sGtSpellScalingStore, dbcPath, "gtSpellScaling.dbc");//15595 - LoadDBC(availableDbcLocales, bad_dbc_files, sGtOCTBaseHPByClassStore, dbcPath, "gtOCTBaseHPByClass.dbc");//15595 - LoadDBC(availableDbcLocales, bad_dbc_files, sGtOCTBaseMPByClassStore, dbcPath, "gtOCTBaseMPByClass.dbc");//15595 LoadDBC(availableDbcLocales, bad_dbc_files, sGuildPerkSpellsStore, dbcPath, "GuildPerkSpells.dbc");//19116 LoadDBC(availableDbcLocales, bad_dbc_files, sImportPriceArmorStore, dbcPath, "ImportPriceArmor.dbc"); // 19116 @@ -657,6 +688,20 @@ void LoadDBCStores(const std::string& dataPath) LoadDBC(availableDbcLocales, bad_dbc_files, sWorldMapOverlayStore, dbcPath, "WorldMapOverlay.dbc");//15595 LoadDBC(availableDbcLocales, bad_dbc_files, sWorldSafeLocsStore, dbcPath, "WorldSafeLocs.dbc"); // 19116 + LoadGameTable(bad_dbc_files, "BarberShopCostBase", sGtBarberShopCostBaseStore, dbcPath, "gtBarberShopCostBase.dbc");//15595 + LoadGameTable(bad_dbc_files, "CombatRatings", sGtCombatRatingsStore, dbcPath, "gtCombatRatings.dbc");//15595 + LoadGameTable(bad_dbc_files, "ChanceToMeleeCritBase", sGtChanceToMeleeCritBaseStore, dbcPath, "gtChanceToMeleeCritBase.dbc");//15595 + LoadGameTable(bad_dbc_files, "ChanceToMeleeCrit", sGtChanceToMeleeCritStore, dbcPath, "gtChanceToMeleeCrit.dbc");//15595 + LoadGameTable(bad_dbc_files, "ChanceToSpellCritBase", sGtChanceToSpellCritBaseStore, dbcPath, "gtChanceToSpellCritBase.dbc");//15595 + LoadGameTable(bad_dbc_files, "ChanceToSpellCrit", sGtChanceToSpellCritStore, dbcPath, "gtChanceToSpellCrit.dbc");//15595 + LoadGameTable(bad_dbc_files, "NPCManaCostScaler", sGtNPCManaCostScalerStore, dbcPath, "gtNPCManaCostScaler.dbc"); + LoadGameTable(bad_dbc_files, "OCTClassCombatRatingScalar", sGtOCTClassCombatRatingScalarStore, dbcPath, "gtOCTClassCombatRatingScalar.dbc");//15595 + LoadGameTable(bad_dbc_files, "OCTHPPerStamina", sGtOCTHpPerStaminaStore, dbcPath, "gtOCTHpPerStamina.dbc");//15595 + LoadGameTable(bad_dbc_files, "RegenMPPerSpt", sGtRegenMPPerSptStore, dbcPath, "gtRegenMPPerSpt.dbc");//15595 + LoadGameTable(bad_dbc_files, "SpellScaling", sGtSpellScalingStore, dbcPath, "gtSpellScaling.dbc");//15595 + LoadGameTable(bad_dbc_files, "OCTBaseHPByClass", sGtOCTBaseHPByClassStore, dbcPath, "gtOCTBaseHPByClass.dbc");//15595 + LoadGameTable(bad_dbc_files, "OCTBaseMPByClass", sGtOCTBaseMPByClassStore, dbcPath, "gtOCTBaseMPByClass.dbc");//15595 + // error checks if (bad_dbc_files.size() >= DBCFileCount) { diff --git a/src/server/game/DataStores/DBCStores.h b/src/server/game/DataStores/DBCStores.h index 5bbccf830d6..e62cf5ee1a8 100644 --- a/src/server/game/DataStores/DBCStores.h +++ b/src/server/game/DataStores/DBCStores.h @@ -92,6 +92,34 @@ typedef std::unordered_map<uint32, SpecializationSpellsBySpecEntry> Specializati typedef ChrSpecializationEntry const* ChrSpecializationByIndexArray[MAX_CLASSES][MAX_SPECIALIZATIONS]; typedef std::unordered_map<uint32, TalentEntry const*> TalentBySpellIDMap; +template<class T> +class GameTable +{ +public: + GameTable(char const* format) : _storage(format), _gtEntry(nullptr) { } + + void SetGameTableEntry(GameTablesEntry const* gtEntry) { _gtEntry = gtEntry; } + + T const* EvaluateTable(uint32 row, uint32 column) const + { + ASSERT(row < _gtEntry->NumRows); + ASSERT(column < _gtEntry->NumColumns); + + return _storage.LookupEntry(_gtEntry->NumRows * column + row); + } + + char const* GetFormat() const { return _storage.GetFormat(); } + uint32 GetFieldCount() const { return _storage.GetFieldCount(); } + bool Load(char const* fileName) { return _storage.Load(fileName, nullptr); } + + uint32 GetTableRowCount() const { return _gtEntry->NumRows; } + uint32 GetTableColumnCount() const { return _gtEntry->NumColumns; } + +private: + DBCStorage<T> _storage; + GameTablesEntry const* _gtEntry; +}; + extern DBCStorage <AchievementEntry> sAchievementStore; extern DBCStorage <AchievementCriteriaEntry> sAchievementCriteriaStore; extern DBCStorage <AreaTableEntry> sAreaStore;// recommend access using functions @@ -132,20 +160,19 @@ extern DBCStorage <GemPropertiesEntry> sGemPropertiesStore; extern DBCStorage <GlyphPropertiesEntry> sGlyphPropertiesStore; extern DBCStorage <GlyphSlotEntry> sGlyphSlotStore; -extern DBCStorage <GtBarberShopCostBaseEntry> sGtBarberShopCostBaseStore; -extern DBCStorage <GtCombatRatingsEntry> sGtCombatRatingsStore; -extern DBCStorage <GtChanceToMeleeCritBaseEntry> sGtChanceToMeleeCritBaseStore; -extern DBCStorage <GtChanceToMeleeCritEntry> sGtChanceToMeleeCritStore; -extern DBCStorage <GtChanceToSpellCritBaseEntry> sGtChanceToSpellCritBaseStore; -extern DBCStorage <GtChanceToSpellCritEntry> sGtChanceToSpellCritStore; -extern DBCStorage <GtNPCManaCostScalerEntry> sGtNPCManaCostScalerStore; -extern DBCStorage <GtOCTClassCombatRatingScalarEntry> sGtOCTClassCombatRatingScalarStore; -//extern DBCStorage <GtOCTRegenMPEntry> sGtOCTRegenMPStore; -- not used currently -extern DBCStorage <gtOCTHpPerStaminaEntry> sGtOCTHpPerStaminaStore; -extern DBCStorage <GtRegenMPPerSptEntry> sGtRegenMPPerSptStore; -extern DBCStorage <GtSpellScalingEntry> sGtSpellScalingStore; -extern DBCStorage <GtOCTBaseHPByClassEntry> sGtOCTBaseHPByClassStore; -extern DBCStorage <GtOCTBaseMPByClassEntry> sGtOCTBaseMPByClassStore; +extern GameTable <GtBarberShopCostBaseEntry> sGtBarberShopCostBaseStore; +extern GameTable <GtCombatRatingsEntry> sGtCombatRatingsStore; +extern GameTable <GtChanceToMeleeCritBaseEntry> sGtChanceToMeleeCritBaseStore; +extern GameTable <GtChanceToMeleeCritEntry> sGtChanceToMeleeCritStore; +extern GameTable <GtChanceToSpellCritBaseEntry> sGtChanceToSpellCritBaseStore; +extern GameTable <GtChanceToSpellCritEntry> sGtChanceToSpellCritStore; +extern GameTable <GtNPCManaCostScalerEntry> sGtNPCManaCostScalerStore; +extern GameTable <GtOCTClassCombatRatingScalarEntry> sGtOCTClassCombatRatingScalarStore; +extern GameTable <gtOCTHpPerStaminaEntry> sGtOCTHpPerStaminaStore; +extern GameTable <GtRegenMPPerSptEntry> sGtRegenMPPerSptStore; +extern GameTable <GtSpellScalingEntry> sGtSpellScalingStore; +extern GameTable <GtOCTBaseHPByClassEntry> sGtOCTBaseHPByClassStore; +extern GameTable <GtOCTBaseMPByClassEntry> sGtOCTBaseMPByClassStore; extern DBCStorage <GuildPerkSpellsEntry> sGuildPerkSpellsStore; extern DBCStorage <ImportPriceArmorEntry> sImportPriceArmorStore; extern DBCStorage <ImportPriceQualityEntry> sImportPriceQualityStore; diff --git a/src/server/game/DataStores/DBCStructure.h b/src/server/game/DataStores/DBCStructure.h index f6727221cd9..4c00ac5fa15 100644 --- a/src/server/game/DataStores/DBCStructure.h +++ b/src/server/game/DataStores/DBCStructure.h @@ -1102,6 +1102,14 @@ struct GameObjectDisplayInfoEntry //float OverrideNameScale; // 20 }; +struct GameTablesEntry +{ + //uint32 Index; // 0 - not a real field, not counted for columns + char const* Name; // 1 + uint32 NumRows; // 2 + uint32 NumColumns; // 3 +}; + struct GemPropertiesEntry { uint32 ID; // 0 @@ -1128,11 +1136,6 @@ struct GlyphSlotEntry //uint32 Tooltip; // 2 }; -// All Gt* DBC store data for 100 levels, some by 100 per class/race -#define GT_MAX_LEVEL 100 -// gtOCTClassCombatRatingScalar.dbc stores data for 32 ratings, look at MAX_COMBAT_RATING for real used amount -#define GT_MAX_RATING 32 - struct GtBarberShopCostBaseEntry { //uint32 level; @@ -1364,7 +1367,7 @@ struct ItemRandomPropertiesEntry { uint32 ID; // 0 //char* Name; // 1 - uint32 Enchantment[MAX_ITEM_RANDOM_PROPERTIES]; // 2-6 + uint32 Enchantment[MAX_ITEM_RANDOM_PROPERTIES]; // 2-6 char* Name_lang; // 7 }; diff --git a/src/server/game/DataStores/DBCfmt.h b/src/server/game/DataStores/DBCfmt.h index 9f53cb09ad8..cc14918e111 100644 --- a/src/server/game/DataStores/DBCfmt.h +++ b/src/server/game/DataStores/DBCfmt.h @@ -59,6 +59,7 @@ char const EmotesTextEntryfmt[] = "nxixxxxxxxxxxxxxxxx"; char const FactionEntryfmt[] = "niiiiiiiiiiiiiiiiiiffixsxixx"; char const FactionTemplateEntryfmt[] = "niiiiiiiiiiiii"; char const GameObjectDisplayInfofmt[] = "nixxxxxxxxxxffffffxxx"; +char const GameTablesFmt[] = "dsii"; char const GemPropertiesEntryfmt[] = "nixxii"; char const GlyphPropertiesfmt[] = "niiix"; char const GlyphSlotfmt[] = "nix"; diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 4b2ca3f0f23..eb61468078c 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -5375,11 +5375,11 @@ float Player::GetMeleeCritFromAgility() uint8 level = getLevel(); uint32 pclass = getClass(); - if (level > GT_MAX_LEVEL) - level = GT_MAX_LEVEL; + if (level >= sGtChanceToMeleeCritStore.GetTableRowCount()) + level = sGtChanceToMeleeCritStore.GetTableRowCount() - 1; - GtChanceToMeleeCritBaseEntry const* critBase = sGtChanceToMeleeCritBaseStore.LookupEntry(pclass-1); - GtChanceToMeleeCritEntry const* critRatio = sGtChanceToMeleeCritStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); + GtChanceToMeleeCritBaseEntry const* critBase = sGtChanceToMeleeCritBaseStore.EvaluateTable(pclass - 1, 0); + GtChanceToMeleeCritEntry const* critRatio = sGtChanceToMeleeCritStore.EvaluateTable(level - 1, pclass - 1); if (critBase == NULL || critRatio == NULL) return 0.0f; @@ -5423,11 +5423,11 @@ void Player::GetDodgeFromAgility(float &diminishing, float &nondiminishing) uint8 level = getLevel(); uint32 pclass = getClass(); - if (level > GT_MAX_LEVEL) - level = GT_MAX_LEVEL; + if (level >= sGtChanceToMeleeCritStore.GetTableRowCount()) + level = sGtChanceToMeleeCritStore.GetTableRowCount() - 1; // Dodge per agility is proportional to crit per agility, which is available from DBC files - GtChanceToMeleeCritEntry const* dodgeRatio = sGtChanceToMeleeCritStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); + GtChanceToMeleeCritEntry const* dodgeRatio = sGtChanceToMeleeCritStore.EvaluateTable(level - 1, pclass - 1); if (dodgeRatio == NULL || pclass > MAX_CLASSES) return; @@ -5445,11 +5445,11 @@ float Player::GetSpellCritFromIntellect() uint8 level = getLevel(); uint32 pclass = getClass(); - if (level > GT_MAX_LEVEL) - level = GT_MAX_LEVEL; + if (level >= sGtChanceToSpellCritStore.GetTableRowCount()) + level = sGtChanceToSpellCritStore.GetTableRowCount() - 1; - GtChanceToSpellCritBaseEntry const* critBase = sGtChanceToSpellCritBaseStore.LookupEntry(pclass - 1); - GtChanceToSpellCritEntry const* critRatio = sGtChanceToSpellCritStore.LookupEntry((pclass - 1) * GT_MAX_LEVEL + level - 1); + GtChanceToSpellCritBaseEntry const* critBase = sGtChanceToSpellCritBaseStore.EvaluateTable(pclass - 1, 0); + GtChanceToSpellCritEntry const* critRatio = sGtChanceToSpellCritStore.EvaluateTable(level - 1, pclass - 1); if (critBase == NULL || critRatio == NULL) return 0.0f; @@ -5461,12 +5461,12 @@ float Player::GetRatingMultiplier(CombatRating cr) const { uint8 level = getLevel(); - if (level > GT_MAX_LEVEL) - level = GT_MAX_LEVEL; + if (level >= sGtCombatRatingsStore.GetTableRowCount()) + level = sGtCombatRatingsStore.GetTableRowCount() - 1; - GtCombatRatingsEntry const* Rating = sGtCombatRatingsStore.LookupEntry(cr*GT_MAX_LEVEL+level-1); + GtCombatRatingsEntry const* Rating = sGtCombatRatingsStore.EvaluateTable(level - 1, cr); // gtOCTClassCombatRatingScalarStore.dbc starts with 1, CombatRating with zero, so cr+1 - GtOCTClassCombatRatingScalarEntry const* classRating = sGtOCTClassCombatRatingScalarStore.LookupEntry((getClass()-1)*GT_MAX_RATING+cr+1); + GtOCTClassCombatRatingScalarEntry const* classRating = sGtOCTClassCombatRatingScalarStore.EvaluateTable(cr + 1, getClass() - 1); if (!Rating || !classRating) return 1.0f; // By default use minimum coefficient (not must be called) @@ -5500,11 +5500,10 @@ float Player::OCTRegenMPPerSpirit() uint8 level = getLevel(); uint32 pclass = getClass(); - if (level > GT_MAX_LEVEL) - level = GT_MAX_LEVEL; + if (level >= sGtRegenMPPerSptStore.GetTableRowCount()) + level = sGtRegenMPPerSptStore.GetTableRowCount() - 1; -// GtOCTRegenMPEntry const* baseRatio = sGtOCTRegenMPStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); - GtRegenMPPerSptEntry const* moreRatio = sGtRegenMPPerSptStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); + GtRegenMPPerSptEntry const* moreRatio = sGtRegenMPPerSptStore.EvaluateTable(level - 1, pclass - 1); if (moreRatio == NULL) return 0.0f; @@ -24669,8 +24668,8 @@ uint32 Player::GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 n { uint8 level = getLevel(); - if (level > GT_MAX_LEVEL) - level = GT_MAX_LEVEL; // max level in this dbc + if (level >= sGtBarberShopCostBaseStore.GetTableRowCount()) + level = sGtBarberShopCostBaseStore.GetTableRowCount() - 1; uint8 hairstyle = GetByteValue(PLAYER_BYTES, 2); uint8 haircolor = GetByteValue(PLAYER_BYTES, 3); @@ -24680,7 +24679,7 @@ uint32 Player::GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 n if ((hairstyle == newhairstyle) && (haircolor == newhaircolor) && (facialhair == newfacialhair) && (!newSkin || (newSkin->Data == skincolor))) return 0; - GtBarberShopCostBaseEntry const* bsc = sGtBarberShopCostBaseStore.LookupEntry(level - 1); + GtBarberShopCostBaseEntry const* bsc = sGtBarberShopCostBaseStore.EvaluateTable(level - 1, 0); if (!bsc) // shouldn't happen return 0xFFFFFFFF; diff --git a/src/server/game/Entities/Unit/StatSystem.cpp b/src/server/game/Entities/Unit/StatSystem.cpp index ea15daed587..3cee039ca9d 100644 --- a/src/server/game/Entities/Unit/StatSystem.cpp +++ b/src/server/game/Entities/Unit/StatSystem.cpp @@ -258,7 +258,7 @@ float Player::GetHealthBonusFromStamina() { // Taken from PaperDollFrame.lua - 4.3.4.15595 float ratio = 10.0f; - if (gtOCTHpPerStaminaEntry const* hpBase = sGtOCTHpPerStaminaStore.LookupEntry((getClass() - 1) * GT_MAX_LEVEL + getLevel() - 1)) + if (gtOCTHpPerStaminaEntry const* hpBase = sGtOCTHpPerStaminaStore.EvaluateTable(getLevel() - 1, 0)) ratio = hpBase->ratio; float stamina = GetStat(STAT_STAMINA); diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 793614930b7..aec9a431a08 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -3692,8 +3692,8 @@ void ObjectMgr::GetPlayerClassLevelInfo(uint32 class_, uint8 level, uint32& base if (level > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)) level = sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL); - GtOCTBaseHPByClassEntry const* hp = sGtOCTBaseHPByClassStore.LookupEntry((class_-1) * GT_MAX_LEVEL + level-1); - GtOCTBaseMPByClassEntry const* mp = sGtOCTBaseMPByClassStore.LookupEntry((class_-1) * GT_MAX_LEVEL + level-1); + GtOCTBaseHPByClassEntry const* hp = sGtOCTBaseHPByClassStore.EvaluateTable(level - 1, class_ - 1); + GtOCTBaseMPByClassEntry const* mp = sGtOCTBaseMPByClassStore.EvaluateTable(level - 1, class_ - 1); if (!hp || !mp) { diff --git a/src/server/game/Quests/QuestDef.cpp b/src/server/game/Quests/QuestDef.cpp index 89ca3749a05..f39314ba119 100644 --- a/src/server/game/Quests/QuestDef.cpp +++ b/src/server/game/Quests/QuestDef.cpp @@ -360,9 +360,6 @@ bool Quest::IsAllowedInRaid(Difficulty difficulty) const uint32 Quest::CalculateHonorGain(uint8 level) const { - if (level > GT_MAX_LEVEL) - level = GT_MAX_LEVEL; - uint32 honor = 0; /*if (GetRewHonorAddition() > 0 || GetRewHonorMultiplier() > 0.0f) diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp index ba74ac6841c..ade3c5cf034 100644 --- a/src/server/game/Spells/SpellInfo.cpp +++ b/src/server/game/Spells/SpellInfo.cpp @@ -445,7 +445,7 @@ int32 SpellEffectInfo::CalcValue(Unit const* caster, int32 const* bp, Unit const if (target && _spellInfo->IsPositiveEffect(_effIndex) && (Effect == SPELL_EFFECT_APPLY_AURA)) level = target->getLevel(); - if (GtSpellScalingEntry const* gtScaling = sGtSpellScalingStore.LookupEntry((_spellInfo->ScalingClass != -1 ? _spellInfo->ScalingClass - 1 : MAX_CLASSES - 1) * 100 + level - 1)) + if (GtSpellScalingEntry const* gtScaling = sGtSpellScalingStore.EvaluateTable(level - 1, (_spellInfo->ScalingClass != -1 ? _spellInfo->ScalingClass - 1 : MAX_CLASSES - 1))) { float multiplier = gtScaling->value; if (_spellInfo->CastTimeMax > 0 && _spellInfo->CastTimeMaxLevel > level) @@ -556,8 +556,8 @@ int32 SpellEffectInfo::CalcValue(Unit const* caster, int32 const* bp, Unit const if (canEffectScale) { - GtNPCManaCostScalerEntry const* spellScaler = sGtNPCManaCostScalerStore.LookupEntry(_spellInfo->SpellLevel - 1); - GtNPCManaCostScalerEntry const* casterScaler = sGtNPCManaCostScalerStore.LookupEntry(caster->getLevel() - 1); + GtNPCManaCostScalerEntry const* spellScaler = sGtNPCManaCostScalerStore.EvaluateTable(_spellInfo->SpellLevel - 1, 0); + GtNPCManaCostScalerEntry const* casterScaler = sGtNPCManaCostScalerStore.EvaluateTable(caster->getLevel() - 1, 0); if (spellScaler && casterScaler) value *= casterScaler->ratio / spellScaler->ratio; } @@ -2413,8 +2413,8 @@ int32 SpellInfo::CalcPowerCost(Unit const* caster, SpellSchoolMask schoolMask) c { if (Attributes & SPELL_ATTR0_LEVEL_DAMAGE_CALCULATION) { - GtNPCManaCostScalerEntry const* spellScaler = sGtNPCManaCostScalerStore.LookupEntry(SpellLevel - 1); - GtNPCManaCostScalerEntry const* casterScaler = sGtNPCManaCostScalerStore.LookupEntry(caster->getLevel() - 1); + GtNPCManaCostScalerEntry const* spellScaler = sGtNPCManaCostScalerStore.EvaluateTable(SpellLevel - 1, 0); + GtNPCManaCostScalerEntry const* casterScaler = sGtNPCManaCostScalerStore.EvaluateTable(caster->getLevel() - 1, 0); if (spellScaler && casterScaler) powerCost *= casterScaler->ratio / spellScaler->ratio; } |