diff options
author | megamage <none@none> | 2009-02-15 11:58:27 -0600 |
---|---|---|
committer | megamage <none@none> | 2009-02-15 11:58:27 -0600 |
commit | 97ac3aba05cfc56c6c8a7c5dbfb7071b02239181 (patch) | |
tree | 283dc5898154b7b1654e193657d32ea1f94bdfcf /src/game/Item.cpp | |
parent | 419b74952002c0605ca829227f55a6354d8bd1c8 (diff) |
Implemented limit category check for item/gem at equip or gem inserting. Author: VladimirMangos
--HG--
branch : trunk
Diffstat (limited to 'src/game/Item.cpp')
-rw-r--r-- | src/game/Item.cpp | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/src/game/Item.cpp b/src/game/Item.cpp index e8280711143..2cb1fe3caa4 100644 --- a/src/game/Item.cpp +++ b/src/game/Item.cpp @@ -806,7 +806,7 @@ void Item::ClearEnchantment(EnchantmentSlot slot) bool Item::GemsFitSockets() const { bool fits = true; - for(uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT+3; ++enchant_slot) + for(uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT+MAX_GEM_SOCKETS; ++enchant_slot) { uint8 SocketColor = GetProto()->Socket[enchant_slot-SOCK_ENCHANTMENT_SLOT].Color; @@ -846,7 +846,7 @@ bool Item::GemsFitSockets() const uint8 Item::GetGemCountWithID(uint32 GemID) const { uint8 count = 0; - for(uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT+3; ++enchant_slot) + for(uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT+MAX_GEM_SOCKETS; ++enchant_slot) { uint32 enchant_id = GetEnchantmentId(EnchantmentSlot(enchant_slot)); if(!enchant_id) @@ -862,6 +862,29 @@ uint8 Item::GetGemCountWithID(uint32 GemID) const return count; } +uint8 Item::GetGemCountWithLimitCategory(uint32 limitCategory) const +{ + uint8 count = 0; + for(uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT+MAX_GEM_SOCKETS; ++enchant_slot) + { + uint32 enchant_id = GetEnchantmentId(EnchantmentSlot(enchant_slot)); + if(!enchant_id) + continue; + + SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id); + if(!enchantEntry) + continue; + + ItemPrototype const* gemProto = ObjectMgr::GetItemPrototype(enchantEntry->GemID); + if(!gemProto) + continue; + + if(gemProto->ItemLimitCategory==limitCategory) + ++count; + } + return count; +} + bool Item::IsLimitedToAnotherMapOrZone( uint32 cur_mapId, uint32 cur_zoneId) const { ItemPrototype const* proto = GetProto(); |