Core/Spells: Prevent adding sockets to items that have 3 sockets in item_template or already had a socket added to them

This commit is contained in:
Shauren
2013-12-23 14:25:34 +01:00
parent 107af52853
commit a316b86a79
+26 -6
View File
@@ -6123,19 +6123,39 @@ SpellCastResult Spell::CheckItems()
}
}
SpellItemEnchantmentEntry const* pEnchant = sSpellItemEnchantmentStore.LookupEntry(m_spellInfo->Effects[i].MiscValue);
SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(m_spellInfo->Effects[i].MiscValue);
// do not allow adding usable enchantments to items that have use effect already
if (pEnchant && isItemUsable)
if (enchantEntry)
{
for (uint8 s = 0; s < MAX_ITEM_ENCHANTMENT_EFFECTS; ++s)
if (pEnchant->type[s] == ITEM_ENCHANTMENT_TYPE_USE_SPELL)
return SPELL_FAILED_ON_USE_ENCHANT;
{
switch (enchantEntry->type[s])
{
case ITEM_ENCHANTMENT_TYPE_USE_SPELL:
if (isItemUsable)
return SPELL_FAILED_ON_USE_ENCHANT;
break;
case ITEM_ENCHANTMENT_TYPE_PRISMATIC_SOCKET:
{
uint32 numSockets = 0;
for (uint32 socket = 0; socket < MAX_ITEM_PROTO_SOCKETS; ++socket)
if (targetItem->GetTemplate()->Socket[socket].Color)
++numSockets;
if (numSockets == MAX_ITEM_PROTO_SOCKETS || targetItem->GetEnchantmentId(PRISMATIC_ENCHANTMENT_SLOT))
return SPELL_FAILED_MAX_SOCKETS;
break;
}
}
}
}
// Not allow enchant in trade slot for some enchant type
if (targetItem->GetOwner() != m_caster)
{
if (!pEnchant)
if (!enchantEntry)
return SPELL_FAILED_ERROR;
if (pEnchant->slot & ENCHANTMENT_CAN_SOULBOUND)
if (enchantEntry->slot & ENCHANTMENT_CAN_SOULBOUND)
return SPELL_FAILED_NOT_TRADEABLE;
}
break;