[10715] Fixed move in inventory items with ItemLimitCategory.

This commit is contained in:
VladimirMangos 2010-11-10 05:41:50 +03:00
parent bfec27707a
commit 4dc943aaa8
5 changed files with 31 additions and 38 deletions

View file

@ -197,34 +197,27 @@ Item* Bag::GetItemByLimitedCategory(uint32 limitedCategory) const
uint32 Bag::GetItemCount(uint32 item, Item* eItem) const
{
Item *pItem;
uint32 count = 0;
for(uint32 i=0; i < GetBagSize(); ++i)
{
pItem = m_bagslot[i];
if( pItem && pItem != eItem && pItem->GetEntry() == item )
count += pItem->GetCount();
}
if (m_bagslot[i])
if (m_bagslot[i] != eItem && m_bagslot[i]->GetEntry() == item)
count += m_bagslot[i]->GetCount();
if (eItem && eItem->GetProto()->GemProperties)
{
for(uint32 i=0; i < GetBagSize(); ++i)
{
pItem = m_bagslot[i];
if( pItem && pItem != eItem && pItem->GetProto()->Socket[0].Color )
count += pItem->GetGemCountWithID(item);
}
}
if (m_bagslot[i])
if (m_bagslot[i] != eItem && m_bagslot[i]->GetProto()->Socket[0].Color)
count += m_bagslot[i]->GetGemCountWithID(item);
return count;
}
uint32 Bag::GetItemCountWithLimitCategory(uint32 limitCategory) const
uint32 Bag::GetItemCountWithLimitCategory(uint32 limitCategory, Item* eItem) const
{
uint32 count = 0;
for(uint32 i = 0; i < GetBagSize(); ++i)
if (m_bagslot[i])
if (m_bagslot[i]->GetProto()->ItemLimitCategory == limitCategory )
if (m_bagslot[i] != eItem && m_bagslot[i]->GetProto()->ItemLimitCategory == limitCategory )
count += m_bagslot[i]->GetCount();
return count;

View file

@ -46,7 +46,7 @@ class Bag : public Item
Item* GetItemByEntry( uint32 item ) const;
Item* GetItemByLimitedCategory(uint32 limitedCategory) const;
uint32 GetItemCount(uint32 item, Item* eItem = NULL) const;
uint32 GetItemCountWithLimitCategory(uint32 limitCategory) const;
uint32 GetItemCountWithLimitCategory(uint32 limitCategory, Item* eItem = NULL) const;
uint8 GetSlotByItemGUID(uint64 guid) const;
bool IsEmpty() const;

View file

@ -8918,31 +8918,31 @@ uint32 Player::GetItemCount( uint32 item, bool inBankAlso, Item* skipItem ) cons
return count;
}
uint32 Player::GetItemCountWithLimitCategory( uint32 limitCategory ) const
uint32 Player::GetItemCountWithLimitCategory( uint32 limitCategory, Item* skipItem) const
{
uint32 count = 0;
for(int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; ++i)
if (Item *pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i))
if (pItem->GetProto()->ItemLimitCategory == limitCategory)
if (pItem->GetProto()->ItemLimitCategory == limitCategory && pItem != skipItem)
count += pItem->GetCount();
for(int i = KEYRING_SLOT_START; i < CURRENCYTOKEN_SLOT_END; ++i)
if (Item *pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i))
if (pItem->GetProto()->ItemLimitCategory == limitCategory)
if (pItem->GetProto()->ItemLimitCategory == limitCategory && pItem != skipItem)
count += pItem->GetCount();
for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i)
if (Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, i))
count += pBag->GetItemCountWithLimitCategory(limitCategory);
count += pBag->GetItemCountWithLimitCategory(limitCategory, skipItem);
for(int i = BANK_SLOT_ITEM_START; i < BANK_SLOT_ITEM_END; ++i)
if (Item *pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i))
if (pItem->GetProto()->ItemLimitCategory == limitCategory)
if (pItem->GetProto()->ItemLimitCategory == limitCategory && pItem != skipItem)
count += pItem->GetCount();
for(int i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; ++i)
if (Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, i))
count += pBag->GetItemCountWithLimitCategory(limitCategory);
count += pBag->GetItemCountWithLimitCategory(limitCategory, skipItem);
return count;
}
@ -9384,7 +9384,7 @@ uint8 Player::_CanTakeMoreSimilarItems(uint32 entry, uint32 count, Item* pItem,
if (limitEntry->mode == ITEM_LIMIT_CATEGORY_MODE_HAVE)
{
uint32 curcount = GetItemCountWithLimitCategory(pProto->ItemLimitCategory);
uint32 curcount = GetItemCountWithLimitCategory(pProto->ItemLimitCategory, pItem);
if (curcount + count > uint32(limitEntry->maxCount))
{

View file

@ -1239,7 +1239,7 @@ class MANGOS_DLL_SPEC Player : public Unit
void SetSheath( SheathState sheathed ); // overwrite Unit version
uint8 FindEquipSlot(ItemPrototype const* proto, uint32 slot, bool swap) const;
uint32 GetItemCount(uint32 item, bool inBankAlso = false, Item* skipItem = NULL) const;
uint32 GetItemCountWithLimitCategory(uint32 limitCategory) const;
uint32 GetItemCountWithLimitCategory(uint32 limitCategory, Item* skipItem = NULL) const;
Item* GetItemByGuid(ObjectGuid uint64) const;
Item* GetItemByEntry(uint32 item) const; // only for special cases
Item* GetItemByLimitedCategory(uint32 limitedCategory) const;

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "10714"
#define REVISION_NR "10715"
#endif // __REVISION_NR_H__