Core/Items: Fixed socket bonus checks (and reduce differences between branches)

Port From (https://github.com/TrinityCore/TrinityCore/commit/6024b307e0bc975678ee4801036058ea63168938)
This commit is contained in:
hondacrx
2024-02-03 17:42:39 -05:00
parent 1d4a30cc2d
commit 57f934295f
+16 -10
View File
@@ -1119,24 +1119,30 @@ namespace Game.Entities
public bool GemsFitSockets() public bool GemsFitSockets()
{ {
uint gemSlot = 0; for (uint gemSlot = 0; gemSlot < ItemConst.MaxGemSockets; ++gemSlot)
foreach (SocketedGem gemData in m_itemData.Gems)
{ {
SocketColor SocketColor = GetTemplate().GetSocketColor(gemSlot); SocketColor socketColor = GetTemplate().GetSocketColor(gemSlot);
if (SocketColor == 0) // no socket slot if (socketColor == 0) // no socket slot
continue; continue;
if (gemSlot >= m_itemData.Gems.Size()) // no gems on this socket
return false;
SocketColor GemColor = 0; SocketColor GemColor = 0;
ItemTemplate gemProto = Global.ObjectMgr.GetItemTemplate(gemData.ItemId); uint gemid = m_itemData.Gems[(int)gemSlot].ItemId;
if (gemProto != null) if (gemid != 0)
{ {
GemPropertiesRecord gemProperty = CliDB.GemPropertiesStorage.LookupByKey(gemProto.GetGemProperties()); ItemTemplate gemProto = Global.ObjectMgr.GetItemTemplate(gemid);
if (gemProperty != null) if (gemProto != null)
GemColor = gemProperty.Type; {
GemPropertiesRecord gemProperty = CliDB.GemPropertiesStorage.LookupByKey(gemProto.GetGemProperties());
if (gemProperty != null)
GemColor = gemProperty.Type;
}
} }
if (!GemColor.HasAnyFlag(ItemConst.SocketColorToGemTypeMask[(int)SocketColor])) // bad gem color on this socket if (!GemColor.HasAnyFlag(ItemConst.SocketColorToGemTypeMask[(int)socketColor])) // bad gem color on this socket
return false; return false;
} }
return true; return true;