mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 10:37:02 +00:00
[10715] Fixed move in inventory items with ItemLimitCategory.
This commit is contained in:
parent
bfec27707a
commit
4dc943aaa8
5 changed files with 31 additions and 38 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue