[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

@ -195,36 +195,29 @@ Item* Bag::GetItemByLimitedCategory(uint32 limitedCategory) const
return NULL;
}
uint32 Bag::GetItemCount( uint32 item, Item* eItem ) 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)
{
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

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

View file

@ -8857,7 +8857,7 @@ uint8 Player::CanUnequipItems( uint32 item, uint32 count ) const
return res;
}
uint32 Player::GetItemCount( uint32 item, bool inBankAlso, Item* skipItem ) const
uint32 Player::GetItemCount(uint32 item, bool inBankAlso, Item* skipItem) const
{
uint32 count = 0;
for(int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; ++i)
@ -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;
}
@ -9348,24 +9348,24 @@ bool Player::HasItemOrGemWithLimitCategoryEquipped( uint32 limitCategory, uint32
return false;
}
uint8 Player::_CanTakeMoreSimilarItems(uint32 entry, uint32 count, Item* pItem, uint32* no_space_count ) const
uint8 Player::_CanTakeMoreSimilarItems(uint32 entry, uint32 count, Item* pItem, uint32* no_space_count) const
{
ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(entry);
if( !pProto )
if (!pProto)
{
if(no_space_count)
if (no_space_count)
*no_space_count = count;
return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS;
}
// no maximum
if(pProto->MaxCount > 0)
if (pProto->MaxCount > 0)
{
uint32 curcount = GetItemCount(pProto->ItemId,true,pItem);
uint32 curcount = GetItemCount(pProto->ItemId, true, pItem);
if (curcount + count > uint32(pProto->MaxCount))
{
if(no_space_count)
if (no_space_count)
*no_space_count = count +curcount - pProto->MaxCount;
return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS;
}
@ -9384,11 +9384,11 @@ 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))
{
if(no_space_count)
if (no_space_count)
*no_space_count = count + curcount - limitEntry->maxCount;
return EQUIP_ERR_ITEM_MAX_LIMIT_CATEGORY_COUNT_EXCEEDED_IS;
}

View file

@ -1237,9 +1237,9 @@ class MANGOS_DLL_SPEC Player : public Unit
void SetVirtualItemSlot( uint8 i, Item* item);
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;
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, 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__