Skip to content

Commit 115dffd

Browse files
roc13xShauren
authored andcommitted
Core/Items: Implement ItemLevelSelector.db2 (TrinityCore#20325)
ItemLevelSelector replaced ITEM_BONUS_ITEM_LEVEL_OVERRIDE in 7.2
1 parent 6eb9973 commit 115dffd

File tree

9 files changed

+72
-26
lines changed

9 files changed

+72
-26
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--
2+
-- Table structure for table `item_level_selector`
3+
--
4+
DROP TABLE IF EXISTS `item_level_selector`;
5+
CREATE TABLE `item_level_selector` (
6+
`ID` int(10) unsigned NOT NULL DEFAULT '0',
7+
`ItemLevel` smallint(5) unsigned NOT NULL DEFAULT '0',
8+
`VerifiedBuild` smallint(6) NOT NULL DEFAULT '0',
9+
PRIMARY KEY (`ID`)
10+
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

src/server/database/Database/Implementation/HotfixDatabase.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,9 @@ void HotfixDatabaseConnection::DoPrepareStatements()
490490
"RequiredCurrency2, RequiredCurrency3, RequiredCurrency4, RequiredCurrency5, RequiredArenaSlot, RequiredFactionId, RequiredFactionStanding, "
491491
"RequirementFlags, RequiredAchievement FROM item_extended_cost ORDER BY ID DESC", CONNECTION_SYNCH);
492492

493+
// ItemLevelSelector.db2
494+
PrepareStatement(HOTFIX_SEL_ITEM_LEVEL_SELECTOR, "SELECT ID, ItemLevel FROM item_level_selector ORDER BY ID DESC", CONNECTION_SYNCH);
495+
493496
// ItemLimitCategory.db2
494497
PrepareStatement(HOTFIX_SEL_ITEM_LIMIT_CATEGORY, "SELECT ID, Name, Quantity, Flags FROM item_limit_category ORDER BY ID DESC", CONNECTION_SYNCH);
495498
PREPARE_LOCALE_STMT(HOTFIX_SEL_ITEM_LIMIT_CATEGORY, "SELECT ID, Name_lang FROM item_limit_category_locale WHERE locale = ?", CONNECTION_SYNCH);

src/server/database/Database/Implementation/HotfixDatabase.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,8 @@ enum HotfixDatabaseStatements : uint32
274274

275275
HOTFIX_SEL_ITEM_EXTENDED_COST,
276276

277+
HOTFIX_SEL_ITEM_LEVEL_SELECTOR,
278+
277279
HOTFIX_SEL_ITEM_LIMIT_CATEGORY,
278280
HOTFIX_SEL_ITEM_LIMIT_CATEGORY_LOCALE,
279281

src/server/game/DataStores/DB2LoadInfo.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2356,6 +2356,20 @@ struct ItemExtendedCostLoadInfo
23562356
}
23572357
};
23582358

2359+
struct ItemLevelSelectorLoadInfo
2360+
{
2361+
static DB2LoadInfo const* Instance()
2362+
{
2363+
static DB2FieldMeta const fields[] =
2364+
{
2365+
{ false, FT_INT, "ID" },
2366+
{ false, FT_SHORT, "ItemLevel" },
2367+
};
2368+
static DB2LoadInfo const loadInfo(&fields[0], std::extent<decltype(fields)>::value, ItemLevelSelectorMeta::Instance(), HOTFIX_SEL_ITEM_LEVEL_SELECTOR);
2369+
return &loadInfo;
2370+
}
2371+
};
2372+
23592373
struct ItemLimitCategoryLoadInfo
23602374
{
23612375
static DB2LoadInfo const* Instance()

src/server/game/DataStores/DB2Stores.cpp

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ DB2Storage<ItemDisenchantLootEntry> sItemDisenchantLootStore("ItemDi
140140
DB2Storage<ItemEffectEntry> sItemEffectStore("ItemEffect.db2", ItemEffectLoadInfo::Instance());
141141
DB2Storage<ItemEntry> sItemStore("Item.db2", ItemLoadInfo::Instance());
142142
DB2Storage<ItemExtendedCostEntry> sItemExtendedCostStore("ItemExtendedCost.db2", ItemExtendedCostLoadInfo::Instance());
143+
DB2Storage<ItemLevelSelectorEntry> sItemLevelSelectorStore("ItemLevelSelector.db2", ItemLevelSelectorLoadInfo::Instance());
143144
DB2Storage<ItemLimitCategoryEntry> sItemLimitCategoryStore("ItemLimitCategory.db2", ItemLimitCategoryLoadInfo::Instance());
144145
DB2Storage<ItemModifiedAppearanceEntry> sItemModifiedAppearanceStore("ItemModifiedAppearance.db2", ItemModifiedAppearanceLoadInfo::Instance());
145146
DB2Storage<ItemPriceBaseEntry> sItemPriceBaseStore("ItemPriceBase.db2", ItemPriceBaseLoadInfo::Instance());
@@ -548,6 +549,7 @@ void DB2Manager::LoadStores(std::string const& dataPath, uint32 defaultLocale)
548549
LOAD_DB2(sItemEffectStore);
549550
LOAD_DB2(sItemStore);
550551
LOAD_DB2(sItemExtendedCostStore);
552+
LOAD_DB2(sItemLevelSelectorStore);
551553
LOAD_DB2(sItemLimitCategoryStore);
552554
LOAD_DB2(sItemModifiedAppearanceStore);
553555
LOAD_DB2(sItemPriceBaseStore);
@@ -1499,6 +1501,11 @@ uint32 DB2Manager::GetItemBonusListForItemLevelDelta(int16 delta) const
14991501
std::set<uint32> DB2Manager::GetItemBonusTree(uint32 itemId, uint32 itemBonusTreeMod) const
15001502
{
15011503
std::set<uint32> bonusListIDs;
1504+
1505+
ItemSparseEntry const* proto = sItemSparseStore.LookupEntry(itemId);
1506+
if (!proto)
1507+
return bonusListIDs;
1508+
15021509
auto itemIdRange = _itemToBonusTree.equal_range(itemId);
15031510
if (itemIdRange.first == itemIdRange.second)
15041511
return bonusListIDs;
@@ -1510,8 +1517,26 @@ std::set<uint32> DB2Manager::GetItemBonusTree(uint32 itemId, uint32 itemBonusTre
15101517
continue;
15111518

15121519
for (ItemBonusTreeNodeEntry const* bonusTreeNode : treeItr->second)
1513-
if (bonusTreeNode->BonusTreeModID == itemBonusTreeMod)
1520+
{
1521+
if (bonusTreeNode->BonusTreeModID != itemBonusTreeMod)
1522+
continue;
1523+
1524+
if (bonusTreeNode->BonusListID)
1525+
{
15141526
bonusListIDs.insert(bonusTreeNode->BonusListID);
1527+
}
1528+
else if (bonusTreeNode->ItemLevelSelectorID)
1529+
{
1530+
ItemLevelSelectorEntry const* selector = sItemLevelSelectorStore.LookupEntry(bonusTreeNode->ItemLevelSelectorID);
1531+
if (!selector)
1532+
continue;
1533+
1534+
int16 delta = int16(selector->ItemLevel) - proto->ItemLevel;
1535+
1536+
if (uint32 bonus = GetItemBonusListForItemLevelDelta(delta))
1537+
bonusListIDs.insert(bonus);
1538+
}
1539+
}
15151540
}
15161541

15171542
return bonusListIDs;

src/server/game/DataStores/DB2Structure.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,6 +1458,12 @@ struct ItemExtendedCostEntry
14581458
uint8 RequiredAchievement;
14591459
};
14601460

1461+
struct ItemLevelSelectorEntry
1462+
{
1463+
uint32 ID;
1464+
uint16 ItemLevel;
1465+
};
1466+
14611467
struct ItemLimitCategoryEntry
14621468
{
14631469
uint32 ID;

src/server/game/DataStores/DBCEnums.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ enum ItemBonusType
713713
ITEM_BONUS_SCALING_STAT_DISTRIBUTION = 11,
714714
ITEM_BONUS_DISENCHANT_LOOT_ID = 12,
715715
ITEM_BONUS_SCALING_STAT_DISTRIBUTION_2 = 13,
716-
ITEM_BONUS_ITEM_LEVEL_OVERRIDE = 14,
716+
ITEM_BONUS_ITEM_LEVEL_CAN_INCREASE = 14, // Displays a + next to item level indicating it can warforge
717717
ITEM_BONUS_RANDOM_ENCHANTMENT = 15, // Responsible for showing "<Random additional stats>" or "+%d Rank Random Minor Trait" in the tooltip before item is obtained
718718
ITEM_BONUS_BONDING = 16,
719719
ITEM_BONUS_RELIC_TYPE = 17

src/server/game/Entities/Item/Item.cpp

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2170,21 +2170,18 @@ uint32 Item::GetItemLevel(Player const* owner) const
21702170
return MIN_ITEM_LEVEL;
21712171

21722172
uint32 itemLevel = stats->GetBaseItemLevel();
2173-
if (_bonusData.HasItemLevelBonus || !_bonusData.ItemLevelOverride)
2173+
if (ScalingStatDistributionEntry const* ssd = sScalingStatDistributionStore.LookupEntry(GetScalingStatDistribution()))
21742174
{
2175-
if (ScalingStatDistributionEntry const* ssd = sScalingStatDistributionStore.LookupEntry(GetScalingStatDistribution()))
2176-
{
2177-
uint32 level = owner->getLevel();
2178-
if (uint32 fixedLevel = GetModifier(ITEM_MODIFIER_SCALING_STAT_DISTRIBUTION_FIXED_LEVEL))
2179-
level = fixedLevel;
2180-
if (uint32 heirloomIlvl = uint32(sDB2Manager.GetCurveValueAt(ssd->ItemLevelCurveID, level)))
2181-
itemLevel = heirloomIlvl;
2182-
}
2183-
2184-
itemLevel += _bonusData.ItemLevelBonus;
2175+
uint32 level = owner->getLevel();
2176+
if (uint32 fixedLevel = GetModifier(ITEM_MODIFIER_SCALING_STAT_DISTRIBUTION_FIXED_LEVEL))
2177+
level = fixedLevel;
2178+
else
2179+
level = std::min(std::max(level, ssd->MinLevel), ssd->MaxLevel);
2180+
if (uint32 heirloomIlvl = uint32(sDB2Manager.GetCurveValueAt(ssd->ItemLevelCurveID, level)))
2181+
itemLevel = heirloomIlvl;
21852182
}
2186-
else
2187-
itemLevel = _bonusData.ItemLevelOverride;
2183+
2184+
itemLevel += _bonusData.ItemLevelBonus;
21882185

21892186
if (ItemUpgradeEntry const* upgrade = sItemUpgradeStore.LookupEntry(GetModifier(ITEM_MODIFIER_UPGRADE_ID)))
21902187
itemLevel += upgrade->ItemLevelBonus;
@@ -2509,13 +2506,11 @@ void BonusData::Initialize(ItemTemplate const* proto)
25092506
AppearanceModID = 0;
25102507
RepairCostMultiplier = 1.0f;
25112508
ScalingStatDistribution = proto->GetScalingStatDistribution();
2512-
ItemLevelOverride = 0;
25132509
RelicType = -1;
25142510
HasItemLevelBonus = false;
25152511

25162512
_state.AppearanceModPriority = std::numeric_limits<int32>::max();
25172513
_state.ScalingStatDistributionPriority = std::numeric_limits<int32>::max();
2518-
_state.ItemLevelOverridePriority = std::numeric_limits<int32>::max();
25192514
_state.HasQualityBonus = false;
25202515
}
25212516

@@ -2599,13 +2594,6 @@ void BonusData::AddBonus(uint32 type, int32 const (&values)[2])
25992594
_state.ScalingStatDistributionPriority = values[1];
26002595
}
26012596
break;
2602-
case ITEM_BONUS_ITEM_LEVEL_OVERRIDE:
2603-
if (values[1] < _state.ItemLevelOverridePriority)
2604-
{
2605-
ItemLevelOverride = static_cast<uint32>(values[0]);
2606-
_state.ItemLevelOverridePriority = values[1];
2607-
}
2608-
break;
26092597
case ITEM_BONUS_BONDING:
26102598
Bonding = ItemBondingType(values[0]);
26112599
break;

src/server/game/Entities/Item/Item.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ struct BonusData
8686
uint32 AppearanceModID;
8787
float RepairCostMultiplier;
8888
uint32 ScalingStatDistribution;
89-
uint32 ItemLevelOverride;
9089
uint32 GemItemLevelBonus[MAX_ITEM_PROTO_SOCKETS];
9190
int32 GemRelicType[MAX_ITEM_PROTO_SOCKETS];
9291
uint16 GemRelicRankBonus[MAX_ITEM_PROTO_SOCKETS];
@@ -102,7 +101,6 @@ struct BonusData
102101
{
103102
int32 AppearanceModPriority;
104103
int32 ScalingStatDistributionPriority;
105-
int32 ItemLevelOverridePriority;
106104
bool HasQualityBonus;
107105
} _state;
108106
};

0 commit comments

Comments
 (0)