diff --git a/src/server/game/Entities/Item/Item.cpp b/src/server/game/Entities/Item/Item.cpp index 18bc10eb8..ad1f1374b 100644 --- a/src/server/game/Entities/Item/Item.cpp +++ b/src/server/game/Entities/Item/Item.cpp @@ -962,6 +962,13 @@ bool Item::GemsFitSockets() const return true; } +bool Item::HasSocket() const +{ + // There can only be one socket added, and it's always in slot `PRISMATIC_ENCHANTMENT_SLOT`. + // Built-in sockets Socket from upgrade + return this->GetTemplate()->Socket[0].Color || this->GetEnchantmentId(EnchantmentSlot(PRISMATIC_ENCHANTMENT_SLOT)); +} + uint8 Item::GetGemCountWithID(uint32 GemID) const { uint8 count = 0; diff --git a/src/server/game/Entities/Item/Item.h b/src/server/game/Entities/Item/Item.h index 045b7c41e..fac5cc169 100644 --- a/src/server/game/Entities/Item/Item.h +++ b/src/server/game/Entities/Item/Item.h @@ -246,6 +246,8 @@ public: uint32 GetCount() const { return GetUInt32Value(ITEM_FIELD_STACK_COUNT); } void SetCount(uint32 value) { SetUInt32Value(ITEM_FIELD_STACK_COUNT, value); } uint32 GetMaxStackCount() const { return GetTemplate()->GetMaxStackSize(); } + // Checks if this item has sockets, whether built-in or added by an upgrade. + bool HasSocket() const; uint8 GetGemCountWithID(uint32 GemID) const; uint8 GetGemCountWithLimitCategory(uint32 limitCategory) const; InventoryResult CanBeMergedPartlyWith(ItemTemplate const* proto) const; diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 2d8789f0a..5bb7f6996 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -7992,7 +7992,7 @@ void Player::_ApplyItemMods(Item* item, uint8 slot, bool apply) uint8 attacktype = Player::GetAttackBySlot(slot); - if (proto->Socket[0].Color) //only (un)equipping of items with sockets can influence metagems, so no need to waste time with normal items + if (item->HasSocket()) //only (un)equipping of items with sockets can influence metagems, so no need to waste time with normal items CorrectMetaGemEnchants(slot, apply); if (attacktype < MAX_ATTACK) @@ -22578,7 +22578,7 @@ bool Player::EnchantmentFitsRequirements(uint32 enchantmentcondition, int8 slot) if (i == slot) continue; Item* pItem2 = GetItemByPos(INVENTORY_SLOT_BAG_0, i); - if (pItem2 && !pItem2->IsBroken() && pItem2->GetTemplate()->Socket[0].Color) + if (pItem2 && !pItem2->IsBroken() && pItem2->HasSocket()) { for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot <= PRISMATIC_ENCHANTMENT_SLOT; ++enchant_slot) { @@ -22660,7 +22660,7 @@ void Player::CorrectMetaGemEnchants(uint8 exceptslot, bool apply) Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, slot); - if (!pItem || !pItem->GetTemplate()->Socket[0].Color) + if (!pItem || !pItem->HasSocket()) continue; for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT + 3; ++enchant_slot)