mirror of
https://github.com/mangosfour/server.git
synced 2025-12-16 04:37:00 +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
|
|
@ -195,36 +195,29 @@ Item* Bag::GetItemByLimitedCategory(uint32 limitedCategory) const
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 Bag::GetItemCount( uint32 item, Item* eItem ) const
|
uint32 Bag::GetItemCount(uint32 item, Item* eItem) const
|
||||||
{
|
{
|
||||||
Item *pItem;
|
|
||||||
uint32 count = 0;
|
uint32 count = 0;
|
||||||
for(uint32 i=0; i < GetBagSize(); ++i)
|
for(uint32 i=0; i < GetBagSize(); ++i)
|
||||||
{
|
if (m_bagslot[i])
|
||||||
pItem = m_bagslot[i];
|
if (m_bagslot[i] != eItem && m_bagslot[i]->GetEntry() == item)
|
||||||
if( pItem && pItem != eItem && pItem->GetEntry() == item )
|
count += m_bagslot[i]->GetCount();
|
||||||
count += pItem->GetCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(eItem && eItem->GetProto()->GemProperties)
|
if (eItem && eItem->GetProto()->GemProperties)
|
||||||
{
|
|
||||||
for(uint32 i=0; i < GetBagSize(); ++i)
|
for(uint32 i=0; i < GetBagSize(); ++i)
|
||||||
{
|
if (m_bagslot[i])
|
||||||
pItem = m_bagslot[i];
|
if (m_bagslot[i] != eItem && m_bagslot[i]->GetProto()->Socket[0].Color)
|
||||||
if( pItem && pItem != eItem && pItem->GetProto()->Socket[0].Color )
|
count += m_bagslot[i]->GetGemCountWithID(item);
|
||||||
count += pItem->GetGemCountWithID(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 Bag::GetItemCountWithLimitCategory(uint32 limitCategory) const
|
uint32 Bag::GetItemCountWithLimitCategory(uint32 limitCategory, Item* eItem) const
|
||||||
{
|
{
|
||||||
uint32 count = 0;
|
uint32 count = 0;
|
||||||
for(uint32 i = 0; i < GetBagSize(); ++i)
|
for(uint32 i = 0; i < GetBagSize(); ++i)
|
||||||
if (m_bagslot[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();
|
count += m_bagslot[i]->GetCount();
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
|
|
|
||||||
|
|
@ -45,8 +45,8 @@ class Bag : public Item
|
||||||
Item* GetItemByPos( uint8 slot ) const;
|
Item* GetItemByPos( uint8 slot ) const;
|
||||||
Item* GetItemByEntry( uint32 item ) const;
|
Item* GetItemByEntry( uint32 item ) const;
|
||||||
Item* GetItemByLimitedCategory(uint32 limitedCategory) const;
|
Item* GetItemByLimitedCategory(uint32 limitedCategory) const;
|
||||||
uint32 GetItemCount( uint32 item, Item* eItem = NULL ) 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;
|
uint8 GetSlotByItemGUID(uint64 guid) const;
|
||||||
bool IsEmpty() const;
|
bool IsEmpty() const;
|
||||||
|
|
|
||||||
|
|
@ -8857,7 +8857,7 @@ uint8 Player::CanUnequipItems( uint32 item, uint32 count ) const
|
||||||
return res;
|
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;
|
uint32 count = 0;
|
||||||
for(int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; ++i)
|
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;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 Player::GetItemCountWithLimitCategory( uint32 limitCategory ) const
|
uint32 Player::GetItemCountWithLimitCategory( uint32 limitCategory, Item* skipItem) const
|
||||||
{
|
{
|
||||||
uint32 count = 0;
|
uint32 count = 0;
|
||||||
for(int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; ++i)
|
for(int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; ++i)
|
||||||
if (Item *pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, 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();
|
count += pItem->GetCount();
|
||||||
|
|
||||||
for(int i = KEYRING_SLOT_START; i < CURRENCYTOKEN_SLOT_END; ++i)
|
for(int i = KEYRING_SLOT_START; i < CURRENCYTOKEN_SLOT_END; ++i)
|
||||||
if (Item *pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, 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();
|
count += pItem->GetCount();
|
||||||
|
|
||||||
for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i)
|
for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i)
|
||||||
if (Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, 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)
|
for(int i = BANK_SLOT_ITEM_START; i < BANK_SLOT_ITEM_END; ++i)
|
||||||
if (Item *pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, 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();
|
count += pItem->GetCount();
|
||||||
|
|
||||||
for(int i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; ++i)
|
for(int i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; ++i)
|
||||||
if (Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, i))
|
if (Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, i))
|
||||||
count += pBag->GetItemCountWithLimitCategory(limitCategory);
|
count += pBag->GetItemCountWithLimitCategory(limitCategory, skipItem);
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
@ -9348,24 +9348,24 @@ bool Player::HasItemOrGemWithLimitCategoryEquipped( uint32 limitCategory, uint32
|
||||||
return false;
|
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);
|
ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(entry);
|
||||||
if( !pProto )
|
if (!pProto)
|
||||||
{
|
{
|
||||||
if(no_space_count)
|
if (no_space_count)
|
||||||
*no_space_count = count;
|
*no_space_count = count;
|
||||||
return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS;
|
return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// no maximum
|
// 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 (curcount + count > uint32(pProto->MaxCount))
|
||||||
{
|
{
|
||||||
if(no_space_count)
|
if (no_space_count)
|
||||||
*no_space_count = count +curcount - pProto->MaxCount;
|
*no_space_count = count +curcount - pProto->MaxCount;
|
||||||
return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS;
|
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)
|
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 (curcount + count > uint32(limitEntry->maxCount))
|
||||||
{
|
{
|
||||||
if(no_space_count)
|
if (no_space_count)
|
||||||
*no_space_count = count + curcount - limitEntry->maxCount;
|
*no_space_count = count + curcount - limitEntry->maxCount;
|
||||||
return EQUIP_ERR_ITEM_MAX_LIMIT_CATEGORY_COUNT_EXCEEDED_IS;
|
return EQUIP_ERR_ITEM_MAX_LIMIT_CATEGORY_COUNT_EXCEEDED_IS;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1237,9 +1237,9 @@ class MANGOS_DLL_SPEC Player : public Unit
|
||||||
|
|
||||||
void SetVirtualItemSlot( uint8 i, Item* item);
|
void SetVirtualItemSlot( uint8 i, Item* item);
|
||||||
void SetSheath( SheathState sheathed ); // overwrite Unit version
|
void SetSheath( SheathState sheathed ); // overwrite Unit version
|
||||||
uint8 FindEquipSlot( ItemPrototype const* proto, uint32 slot, bool swap ) const;
|
uint8 FindEquipSlot(ItemPrototype const* proto, uint32 slot, bool swap) const;
|
||||||
uint32 GetItemCount( uint32 item, bool inBankAlso = false, Item* skipItem = NULL ) 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* GetItemByGuid(ObjectGuid uint64) const;
|
||||||
Item* GetItemByEntry(uint32 item) const; // only for special cases
|
Item* GetItemByEntry(uint32 item) const; // only for special cases
|
||||||
Item* GetItemByLimitedCategory(uint32 limitedCategory) const;
|
Item* GetItemByLimitedCategory(uint32 limitedCategory) const;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "10714"
|
#define REVISION_NR "10715"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue