mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 07:37:01 +00:00
Use enum InventoryResult as return type for few functions.
This commit is contained in:
parent
23a861e4a6
commit
730a907252
18 changed files with 184 additions and 185 deletions
|
|
@ -8924,20 +8924,20 @@ uint8 Player::FindEquipSlot( ItemPrototype const* proto, uint32 slot, bool swap
|
|||
return NULL_SLOT;
|
||||
}
|
||||
|
||||
uint8 Player::CanUnequipItems( uint32 item, uint32 count ) const
|
||||
InventoryResult Player::CanUnequipItems( uint32 item, uint32 count ) const
|
||||
{
|
||||
Item *pItem;
|
||||
uint32 tempcount = 0;
|
||||
|
||||
uint8 res = EQUIP_ERR_OK;
|
||||
InventoryResult res = EQUIP_ERR_OK;
|
||||
|
||||
for(int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_BAG_END; ++i)
|
||||
{
|
||||
pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i );
|
||||
if( pItem && pItem->GetEntry() == item )
|
||||
{
|
||||
uint8 ires = CanUnequipItem(INVENTORY_SLOT_BAG_0 << 8 | i, false);
|
||||
if(ires==EQUIP_ERR_OK)
|
||||
InventoryResult ires = CanUnequipItem(INVENTORY_SLOT_BAG_0 << 8 | i, false);
|
||||
if(ires == EQUIP_ERR_OK)
|
||||
{
|
||||
tempcount += pItem->GetCount();
|
||||
if( tempcount >= count )
|
||||
|
|
@ -9486,7 +9486,7 @@ bool Player::HasItemOrGemWithLimitCategoryEquipped( uint32 limitCategory, uint32
|
|||
return false;
|
||||
}
|
||||
|
||||
uint8 Player::_CanTakeMoreSimilarItems(uint32 entry, uint32 count, Item* pItem, uint32* no_space_count) const
|
||||
InventoryResult Player::_CanTakeMoreSimilarItems(uint32 entry, uint32 count, Item* pItem, uint32* no_space_count) const
|
||||
{
|
||||
ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(entry);
|
||||
if (!pProto)
|
||||
|
|
@ -9566,7 +9566,7 @@ bool Player::HasItemTotemCategory( uint32 TotemCategory ) const
|
|||
return false;
|
||||
}
|
||||
|
||||
uint8 Player::_CanStoreItem_InSpecificSlot( uint8 bag, uint8 slot, ItemPosCountVec &dest, ItemPrototype const *pProto, uint32& count, bool swap, Item* pSrcItem ) const
|
||||
InventoryResult Player::_CanStoreItem_InSpecificSlot( uint8 bag, uint8 slot, ItemPosCountVec &dest, ItemPrototype const *pProto, uint32& count, bool swap, Item* pSrcItem ) const
|
||||
{
|
||||
Item* pItem2 = GetItemByPos( bag, slot );
|
||||
|
||||
|
|
@ -9617,7 +9617,7 @@ uint8 Player::_CanStoreItem_InSpecificSlot( uint8 bag, uint8 slot, ItemPosCountV
|
|||
else
|
||||
{
|
||||
// can be merged at least partly
|
||||
uint8 res = pItem2->CanBeMergedPartlyWith(pProto);
|
||||
InventoryResult res = pItem2->CanBeMergedPartlyWith(pProto);
|
||||
if (res != EQUIP_ERR_OK)
|
||||
return res;
|
||||
|
||||
|
|
@ -9637,10 +9637,10 @@ uint8 Player::_CanStoreItem_InSpecificSlot( uint8 bag, uint8 slot, ItemPosCountV
|
|||
return EQUIP_ERR_OK;
|
||||
}
|
||||
|
||||
uint8 Player::_CanStoreItem_InBag( uint8 bag, ItemPosCountVec &dest, ItemPrototype const *pProto, uint32& count, bool merge, bool non_specialized, Item* pSrcItem, uint8 skip_bag, uint8 skip_slot ) const
|
||||
InventoryResult Player::_CanStoreItem_InBag( uint8 bag, ItemPosCountVec &dest, ItemPrototype const *pProto, uint32& count, bool merge, bool non_specialized, Item* pSrcItem, uint8 skip_bag, uint8 skip_slot ) const
|
||||
{
|
||||
// skip specific bag already processed in first called _CanStoreItem_InBag
|
||||
if (bag==skip_bag)
|
||||
if (bag == skip_bag)
|
||||
return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG;
|
||||
|
||||
// skip nonexistent bag or self targeted bag
|
||||
|
|
@ -9704,7 +9704,7 @@ uint8 Player::_CanStoreItem_InBag( uint8 bag, ItemPosCountVec &dest, ItemPrototy
|
|||
return EQUIP_ERR_OK;
|
||||
}
|
||||
|
||||
uint8 Player::_CanStoreItem_InInventorySlots( uint8 slot_begin, uint8 slot_end, ItemPosCountVec &dest, ItemPrototype const *pProto, uint32& count, bool merge, Item* pSrcItem, uint8 skip_bag, uint8 skip_slot ) const
|
||||
InventoryResult Player::_CanStoreItem_InInventorySlots( uint8 slot_begin, uint8 slot_end, ItemPosCountVec &dest, ItemPrototype const *pProto, uint32& count, bool merge, Item* pSrcItem, uint8 skip_bag, uint8 skip_slot ) const
|
||||
{
|
||||
for(uint32 j = slot_begin; j < slot_end; ++j)
|
||||
{
|
||||
|
|
@ -9715,7 +9715,7 @@ uint8 Player::_CanStoreItem_InInventorySlots( uint8 slot_begin, uint8 slot_end,
|
|||
Item* pItem2 = GetItemByPos( INVENTORY_SLOT_BAG_0, j );
|
||||
|
||||
// ignore move item (this slot will be empty at move)
|
||||
if (pItem2==pSrcItem)
|
||||
if (pItem2 == pSrcItem)
|
||||
pItem2 = NULL;
|
||||
|
||||
// if merge skip empty, if !merge skip non-empty
|
||||
|
|
@ -9751,7 +9751,7 @@ uint8 Player::_CanStoreItem_InInventorySlots( uint8 slot_begin, uint8 slot_end,
|
|||
return EQUIP_ERR_OK;
|
||||
}
|
||||
|
||||
uint8 Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, uint32 entry, uint32 count, Item *pItem, bool swap, uint32* no_space_count ) const
|
||||
InventoryResult Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, uint32 entry, uint32 count, Item *pItem, bool swap, uint32* no_space_count ) const
|
||||
{
|
||||
DEBUG_LOG( "STORAGE: CanStoreItem bag = %u, slot = %u, item = %u, count = %u", bag, slot, entry, count);
|
||||
|
||||
|
|
@ -9783,10 +9783,10 @@ uint8 Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, uint3
|
|||
|
||||
// check count of items (skip for auto move for same player from bank)
|
||||
uint32 no_similar_count = 0; // can't store this amount similar items
|
||||
uint8 res = _CanTakeMoreSimilarItems(entry,count,pItem,&no_similar_count);
|
||||
if (res!=EQUIP_ERR_OK)
|
||||
InventoryResult res = _CanTakeMoreSimilarItems(entry,count,pItem,&no_similar_count);
|
||||
if (res != EQUIP_ERR_OK)
|
||||
{
|
||||
if (count==no_similar_count)
|
||||
if (count == no_similar_count)
|
||||
{
|
||||
if (no_space_count)
|
||||
*no_space_count = no_similar_count;
|
||||
|
|
@ -9799,16 +9799,16 @@ uint8 Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, uint3
|
|||
if (bag != NULL_BAG && slot != NULL_SLOT)
|
||||
{
|
||||
res = _CanStoreItem_InSpecificSlot(bag,slot,dest,pProto,count,swap,pItem);
|
||||
if (res!=EQUIP_ERR_OK)
|
||||
if (res != EQUIP_ERR_OK)
|
||||
{
|
||||
if (no_space_count)
|
||||
*no_space_count = count + no_similar_count;
|
||||
return res;
|
||||
}
|
||||
|
||||
if (count==0)
|
||||
if (count == 0)
|
||||
{
|
||||
if (no_similar_count==0)
|
||||
if (no_similar_count == 0)
|
||||
return EQUIP_ERR_OK;
|
||||
|
||||
if (no_space_count)
|
||||
|
|
@ -9828,16 +9828,16 @@ uint8 Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, uint3
|
|||
if (bag == INVENTORY_SLOT_BAG_0) // inventory
|
||||
{
|
||||
res = _CanStoreItem_InInventorySlots(KEYRING_SLOT_START,CURRENCYTOKEN_SLOT_END,dest,pProto,count,true,pItem,bag,slot);
|
||||
if (res!=EQUIP_ERR_OK)
|
||||
if (res != EQUIP_ERR_OK)
|
||||
{
|
||||
if (no_space_count)
|
||||
*no_space_count = count + no_similar_count;
|
||||
return res;
|
||||
}
|
||||
|
||||
if (count==0)
|
||||
if (count == 0)
|
||||
{
|
||||
if (no_similar_count==0)
|
||||
if (no_similar_count == 0)
|
||||
return EQUIP_ERR_OK;
|
||||
|
||||
if (no_space_count)
|
||||
|
|
@ -9846,16 +9846,16 @@ uint8 Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, uint3
|
|||
}
|
||||
|
||||
res = _CanStoreItem_InInventorySlots(INVENTORY_SLOT_ITEM_START,INVENTORY_SLOT_ITEM_END,dest,pProto,count,true,pItem,bag,slot);
|
||||
if (res!=EQUIP_ERR_OK)
|
||||
if (res != EQUIP_ERR_OK)
|
||||
{
|
||||
if (no_space_count)
|
||||
*no_space_count = count + no_similar_count;
|
||||
return res;
|
||||
}
|
||||
|
||||
if (count==0)
|
||||
if (count == 0)
|
||||
{
|
||||
if (no_similar_count==0)
|
||||
if (no_similar_count == 0)
|
||||
return EQUIP_ERR_OK;
|
||||
|
||||
if (no_space_count)
|
||||
|
|
@ -9867,19 +9867,19 @@ uint8 Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, uint3
|
|||
{
|
||||
// we need check 2 time (specialized/non_specialized), use NULL_BAG to prevent skipping bag
|
||||
res = _CanStoreItem_InBag(bag,dest,pProto,count,true,false,pItem,NULL_BAG,slot);
|
||||
if (res!=EQUIP_ERR_OK)
|
||||
if (res != EQUIP_ERR_OK)
|
||||
res = _CanStoreItem_InBag(bag,dest,pProto,count,true,true,pItem,NULL_BAG,slot);
|
||||
|
||||
if (res!=EQUIP_ERR_OK)
|
||||
if (res != EQUIP_ERR_OK)
|
||||
{
|
||||
if (no_space_count)
|
||||
*no_space_count = count + no_similar_count;
|
||||
return res;
|
||||
}
|
||||
|
||||
if (count==0)
|
||||
if (count == 0)
|
||||
{
|
||||
if (no_similar_count==0)
|
||||
if (no_similar_count == 0)
|
||||
return EQUIP_ERR_OK;
|
||||
|
||||
if (no_space_count)
|
||||
|
|
@ -9904,7 +9904,7 @@ uint8 Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, uint3
|
|||
return res;
|
||||
}
|
||||
|
||||
if (count==0)
|
||||
if (count == 0)
|
||||
{
|
||||
if (no_similar_count==0)
|
||||
return EQUIP_ERR_OK;
|
||||
|
|
@ -9915,16 +9915,16 @@ uint8 Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, uint3
|
|||
}
|
||||
|
||||
res = _CanStoreItem_InInventorySlots(CURRENCYTOKEN_SLOT_START,CURRENCYTOKEN_SLOT_END,dest,pProto,count,false,pItem,bag,slot);
|
||||
if (res!=EQUIP_ERR_OK)
|
||||
if (res != EQUIP_ERR_OK)
|
||||
{
|
||||
if (no_space_count)
|
||||
*no_space_count = count + no_similar_count;
|
||||
return res;
|
||||
}
|
||||
|
||||
if (count==0)
|
||||
if (count == 0)
|
||||
{
|
||||
if (no_similar_count==0)
|
||||
if (no_similar_count == 0)
|
||||
return EQUIP_ERR_OK;
|
||||
|
||||
if (no_space_count)
|
||||
|
|
@ -9942,9 +9942,9 @@ uint8 Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, uint3
|
|||
return res;
|
||||
}
|
||||
|
||||
if (count==0)
|
||||
if (count == 0)
|
||||
{
|
||||
if (no_similar_count==0)
|
||||
if (no_similar_count == 0)
|
||||
return EQUIP_ERR_OK;
|
||||
|
||||
if (no_space_count)
|
||||
|
|
@ -9954,16 +9954,16 @@ uint8 Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, uint3
|
|||
}
|
||||
|
||||
res = _CanStoreItem_InInventorySlots(INVENTORY_SLOT_ITEM_START,INVENTORY_SLOT_ITEM_END,dest,pProto,count,false,pItem,bag,slot);
|
||||
if (res!=EQUIP_ERR_OK)
|
||||
if (res != EQUIP_ERR_OK)
|
||||
{
|
||||
if (no_space_count)
|
||||
*no_space_count = count + no_similar_count;
|
||||
return res;
|
||||
}
|
||||
|
||||
if (count==0)
|
||||
if (count == 0)
|
||||
{
|
||||
if (no_similar_count==0)
|
||||
if (no_similar_count == 0)
|
||||
return EQUIP_ERR_OK;
|
||||
|
||||
if (no_space_count)
|
||||
|
|
@ -9974,19 +9974,19 @@ uint8 Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, uint3
|
|||
else // equipped bag
|
||||
{
|
||||
res = _CanStoreItem_InBag(bag,dest,pProto,count,false,false,pItem,NULL_BAG,slot);
|
||||
if (res!=EQUIP_ERR_OK)
|
||||
if (res != EQUIP_ERR_OK)
|
||||
res = _CanStoreItem_InBag(bag,dest,pProto,count,false,true,pItem,NULL_BAG,slot);
|
||||
|
||||
if (res!=EQUIP_ERR_OK)
|
||||
if (res != EQUIP_ERR_OK)
|
||||
{
|
||||
if (no_space_count)
|
||||
*no_space_count = count + no_similar_count;
|
||||
return res;
|
||||
}
|
||||
|
||||
if (count==0)
|
||||
if (count == 0)
|
||||
{
|
||||
if (no_similar_count==0)
|
||||
if (no_similar_count == 0)
|
||||
return EQUIP_ERR_OK;
|
||||
|
||||
if (no_space_count)
|
||||
|
|
@ -10002,16 +10002,16 @@ uint8 Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, uint3
|
|||
if (pProto->Stackable != 1)
|
||||
{
|
||||
res = _CanStoreItem_InInventorySlots(KEYRING_SLOT_START,CURRENCYTOKEN_SLOT_END,dest,pProto,count,true,pItem,bag,slot);
|
||||
if (res!=EQUIP_ERR_OK)
|
||||
if (res != EQUIP_ERR_OK)
|
||||
{
|
||||
if (no_space_count)
|
||||
*no_space_count = count + no_similar_count;
|
||||
return res;
|
||||
}
|
||||
|
||||
if (count==0)
|
||||
if (count == 0)
|
||||
{
|
||||
if (no_similar_count==0)
|
||||
if (no_similar_count == 0)
|
||||
return EQUIP_ERR_OK;
|
||||
|
||||
if (no_space_count)
|
||||
|
|
@ -10020,16 +10020,16 @@ uint8 Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, uint3
|
|||
}
|
||||
|
||||
res = _CanStoreItem_InInventorySlots(INVENTORY_SLOT_ITEM_START,INVENTORY_SLOT_ITEM_END,dest,pProto,count,true,pItem,bag,slot);
|
||||
if (res!=EQUIP_ERR_OK)
|
||||
if (res != EQUIP_ERR_OK)
|
||||
{
|
||||
if (no_space_count)
|
||||
*no_space_count = count + no_similar_count;
|
||||
return res;
|
||||
}
|
||||
|
||||
if (count==0)
|
||||
if (count == 0)
|
||||
{
|
||||
if (no_similar_count==0)
|
||||
if (no_similar_count == 0)
|
||||
return EQUIP_ERR_OK;
|
||||
|
||||
if (no_space_count)
|
||||
|
|
@ -10042,12 +10042,12 @@ uint8 Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, uint3
|
|||
for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i)
|
||||
{
|
||||
res = _CanStoreItem_InBag(i,dest,pProto,count,true,false,pItem,bag,slot);
|
||||
if (res!=EQUIP_ERR_OK)
|
||||
if (res != EQUIP_ERR_OK)
|
||||
continue;
|
||||
|
||||
if (count==0)
|
||||
if (count == 0)
|
||||
{
|
||||
if (no_similar_count==0)
|
||||
if (no_similar_count == 0)
|
||||
return EQUIP_ERR_OK;
|
||||
|
||||
if (no_space_count)
|
||||
|
|
@ -10060,10 +10060,10 @@ uint8 Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, uint3
|
|||
for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i)
|
||||
{
|
||||
res = _CanStoreItem_InBag(i,dest,pProto,count,true,true,pItem,bag,slot);
|
||||
if (res!=EQUIP_ERR_OK)
|
||||
if (res != EQUIP_ERR_OK)
|
||||
continue;
|
||||
|
||||
if (count==0)
|
||||
if (count == 0)
|
||||
{
|
||||
if (no_similar_count==0)
|
||||
return EQUIP_ERR_OK;
|
||||
|
|
@ -10082,16 +10082,16 @@ uint8 Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, uint3
|
|||
{
|
||||
uint32 keyringSize = GetMaxKeyringSize();
|
||||
res = _CanStoreItem_InInventorySlots(KEYRING_SLOT_START,KEYRING_SLOT_START+keyringSize,dest,pProto,count,false,pItem,bag,slot);
|
||||
if (res!=EQUIP_ERR_OK)
|
||||
if (res != EQUIP_ERR_OK)
|
||||
{
|
||||
if (no_space_count)
|
||||
*no_space_count = count + no_similar_count;
|
||||
return res;
|
||||
}
|
||||
|
||||
if (count==0)
|
||||
if (count == 0)
|
||||
{
|
||||
if (no_similar_count==0)
|
||||
if (no_similar_count == 0)
|
||||
return EQUIP_ERR_OK;
|
||||
|
||||
if (no_space_count)
|
||||
|
|
@ -10102,16 +10102,16 @@ uint8 Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, uint3
|
|||
else if (pProto->BagFamily & BAG_FAMILY_MASK_CURRENCY_TOKENS)
|
||||
{
|
||||
res = _CanStoreItem_InInventorySlots(CURRENCYTOKEN_SLOT_START,CURRENCYTOKEN_SLOT_END,dest,pProto,count,false,pItem,bag,slot);
|
||||
if (res!=EQUIP_ERR_OK)
|
||||
if (res != EQUIP_ERR_OK)
|
||||
{
|
||||
if (no_space_count)
|
||||
*no_space_count = count + no_similar_count;
|
||||
return res;
|
||||
}
|
||||
|
||||
if (count==0)
|
||||
if (count == 0)
|
||||
{
|
||||
if (no_similar_count==0)
|
||||
if (no_similar_count == 0)
|
||||
return EQUIP_ERR_OK;
|
||||
|
||||
if (no_space_count)
|
||||
|
|
@ -10123,10 +10123,10 @@ uint8 Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, uint3
|
|||
for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i)
|
||||
{
|
||||
res = _CanStoreItem_InBag(i,dest,pProto,count,false,false,pItem,bag,slot);
|
||||
if (res!=EQUIP_ERR_OK)
|
||||
if (res != EQUIP_ERR_OK)
|
||||
continue;
|
||||
|
||||
if (count==0)
|
||||
if (count == 0)
|
||||
{
|
||||
if (no_similar_count==0)
|
||||
return EQUIP_ERR_OK;
|
||||
|
|
@ -10144,14 +10144,14 @@ uint8 Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, uint3
|
|||
|
||||
// search free slot
|
||||
res = _CanStoreItem_InInventorySlots(INVENTORY_SLOT_ITEM_START,INVENTORY_SLOT_ITEM_END,dest,pProto,count,false,pItem,bag,slot);
|
||||
if (res!=EQUIP_ERR_OK)
|
||||
if (res != EQUIP_ERR_OK)
|
||||
{
|
||||
if (no_space_count)
|
||||
*no_space_count = count + no_similar_count;
|
||||
return res;
|
||||
}
|
||||
|
||||
if (count==0)
|
||||
if (count == 0)
|
||||
{
|
||||
if (no_similar_count==0)
|
||||
return EQUIP_ERR_OK;
|
||||
|
|
@ -10164,12 +10164,12 @@ uint8 Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, uint3
|
|||
for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i)
|
||||
{
|
||||
res = _CanStoreItem_InBag(i,dest,pProto,count,false,true,pItem,bag,slot);
|
||||
if (res!=EQUIP_ERR_OK)
|
||||
if (res != EQUIP_ERR_OK)
|
||||
continue;
|
||||
|
||||
if (count==0)
|
||||
if (count == 0)
|
||||
{
|
||||
if (no_similar_count==0)
|
||||
if (no_similar_count == 0)
|
||||
return EQUIP_ERR_OK;
|
||||
|
||||
if (no_space_count)
|
||||
|
|
@ -10185,7 +10185,7 @@ uint8 Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, uint3
|
|||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
uint8 Player::CanStoreItems( Item **pItems,int count) const
|
||||
InventoryResult Player::CanStoreItems( Item **pItems,int count) const
|
||||
{
|
||||
Item *pItem2;
|
||||
|
||||
|
|
@ -10272,7 +10272,7 @@ uint8 Player::CanStoreItems( Item **pItems,int count) const
|
|||
ItemPrototype const *pBagProto;
|
||||
|
||||
// item is 'one item only'
|
||||
uint8 res = CanTakeMoreSimilarItems(pItem);
|
||||
InventoryResult res = CanTakeMoreSimilarItems(pItem);
|
||||
if (res != EQUIP_ERR_OK)
|
||||
return res;
|
||||
|
||||
|
|
@ -10444,13 +10444,13 @@ uint8 Player::CanStoreItems( Item **pItems,int count) const
|
|||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
uint8 Player::CanEquipNewItem( uint8 slot, uint16 &dest, uint32 item, bool swap ) const
|
||||
InventoryResult Player::CanEquipNewItem( uint8 slot, uint16 &dest, uint32 item, bool swap ) const
|
||||
{
|
||||
dest = 0;
|
||||
Item *pItem = Item::CreateItem( item, 1, this );
|
||||
if (pItem)
|
||||
{
|
||||
uint8 result = CanEquipItem(slot, dest, pItem, swap );
|
||||
InventoryResult result = CanEquipItem(slot, dest, pItem, swap );
|
||||
delete pItem;
|
||||
return result;
|
||||
}
|
||||
|
|
@ -10458,7 +10458,7 @@ uint8 Player::CanEquipNewItem( uint8 slot, uint16 &dest, uint32 item, bool swap
|
|||
return EQUIP_ERR_ITEM_NOT_FOUND;
|
||||
}
|
||||
|
||||
uint8 Player::CanEquipItem( uint8 slot, uint16 &dest, Item *pItem, bool swap, bool not_loading ) const
|
||||
InventoryResult Player::CanEquipItem( uint8 slot, uint16 &dest, Item *pItem, bool swap, bool not_loading ) const
|
||||
{
|
||||
dest = 0;
|
||||
if (pItem)
|
||||
|
|
@ -10475,7 +10475,7 @@ uint8 Player::CanEquipItem( uint8 slot, uint16 &dest, Item *pItem, bool swap, bo
|
|||
return EQUIP_ERR_DONT_OWN_THAT_ITEM;
|
||||
|
||||
// check count of items (skip for auto move for same player from bank)
|
||||
uint8 res = CanTakeMoreSimilarItems(pItem);
|
||||
InventoryResult res = CanTakeMoreSimilarItems(pItem);
|
||||
if (res != EQUIP_ERR_OK)
|
||||
return res;
|
||||
|
||||
|
|
@ -10520,14 +10520,14 @@ uint8 Player::CanEquipItem( uint8 slot, uint16 &dest, Item *pItem, bool swap, bo
|
|||
if (eslot == NULL_SLOT)
|
||||
return EQUIP_ERR_ITEM_CANT_BE_EQUIPPED;
|
||||
|
||||
uint8 msg = CanUseItem(pItem , not_loading);
|
||||
InventoryResult msg = CanUseItem(pItem , not_loading);
|
||||
if (msg != EQUIP_ERR_OK)
|
||||
return msg;
|
||||
if (!swap && GetItemByPos(INVENTORY_SLOT_BAG_0, eslot))
|
||||
return EQUIP_ERR_NO_EQUIPMENT_SLOT_AVAILABLE;
|
||||
|
||||
// if swap ignore item (equipped also)
|
||||
if (uint8 res2 = CanEquipUniqueItem(pItem, swap ? eslot : NULL_SLOT))
|
||||
if (InventoryResult res2 = CanEquipUniqueItem(pItem, swap ? eslot : NULL_SLOT))
|
||||
return res2;
|
||||
|
||||
// check unique-equipped special item classes
|
||||
|
|
@ -10600,7 +10600,7 @@ uint8 Player::CanEquipItem( uint8 slot, uint16 &dest, Item *pItem, bool swap, bo
|
|||
return !swap ? EQUIP_ERR_ITEM_NOT_FOUND : EQUIP_ERR_ITEMS_CANT_BE_SWAPPED;
|
||||
}
|
||||
|
||||
uint8 Player::CanUnequipItem( uint16 pos, bool swap ) const
|
||||
InventoryResult Player::CanUnequipItem( uint16 pos, bool swap ) const
|
||||
{
|
||||
// Applied only to equipped items and bank bags
|
||||
if (!IsEquipmentPos(pos) && !IsBagPos(pos))
|
||||
|
|
@ -10645,7 +10645,7 @@ uint8 Player::CanUnequipItem( uint16 pos, bool swap ) const
|
|||
return EQUIP_ERR_OK;
|
||||
}
|
||||
|
||||
uint8 Player::CanBankItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, Item *pItem, bool swap, bool not_loading ) const
|
||||
InventoryResult Player::CanBankItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, Item *pItem, bool swap, bool not_loading ) const
|
||||
{
|
||||
if (!pItem)
|
||||
return swap ? EQUIP_ERR_ITEMS_CANT_BE_SWAPPED : EQUIP_ERR_ITEM_NOT_FOUND;
|
||||
|
|
@ -10665,7 +10665,7 @@ uint8 Player::CanBankItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, Item *p
|
|||
return EQUIP_ERR_DONT_OWN_THAT_ITEM;
|
||||
|
||||
// check count of items (skip for auto move for same player from bank)
|
||||
uint8 res = CanTakeMoreSimilarItems(pItem);
|
||||
InventoryResult res = CanTakeMoreSimilarItems(pItem);
|
||||
if (res != EQUIP_ERR_OK)
|
||||
return res;
|
||||
|
||||
|
|
@ -10827,7 +10827,7 @@ uint8 Player::CanBankItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, Item *p
|
|||
return EQUIP_ERR_BANK_FULL;
|
||||
}
|
||||
|
||||
uint8 Player::CanUseItem( Item *pItem, bool not_loading ) const
|
||||
InventoryResult Player::CanUseItem( Item *pItem, bool not_loading ) const
|
||||
{
|
||||
if (pItem)
|
||||
{
|
||||
|
|
@ -10845,7 +10845,7 @@ uint8 Player::CanUseItem( Item *pItem, bool not_loading ) const
|
|||
if (pItem->IsBindedNotWith(this))
|
||||
return EQUIP_ERR_DONT_OWN_THAT_ITEM;
|
||||
|
||||
uint8 msg = CanUseItem(pProto);
|
||||
InventoryResult msg = CanUseItem(pProto);
|
||||
if (msg != EQUIP_ERR_OK)
|
||||
return msg;
|
||||
|
||||
|
|
@ -10896,7 +10896,7 @@ uint8 Player::CanUseItem( Item *pItem, bool not_loading ) const
|
|||
return EQUIP_ERR_ITEM_NOT_FOUND;
|
||||
}
|
||||
|
||||
uint8 Player::CanUseItem( ItemPrototype const *pProto ) const
|
||||
InventoryResult Player::CanUseItem( ItemPrototype const *pProto ) const
|
||||
{
|
||||
// Used by group, function NeedBeforeGreed, to know if a prototype can be used by a player
|
||||
|
||||
|
|
@ -10930,7 +10930,7 @@ uint8 Player::CanUseItem( ItemPrototype const *pProto ) const
|
|||
return EQUIP_ERR_ITEM_NOT_FOUND;
|
||||
}
|
||||
|
||||
uint8 Player::CanUseAmmo( uint32 item ) const
|
||||
InventoryResult Player::CanUseAmmo( uint32 item ) const
|
||||
{
|
||||
DEBUG_LOG( "STORAGE: CanUseAmmo item = %u", item);
|
||||
if( !isAlive() )
|
||||
|
|
@ -10943,7 +10943,7 @@ uint8 Player::CanUseAmmo( uint32 item ) const
|
|||
if( pProto->InventoryType!= INVTYPE_AMMO )
|
||||
return EQUIP_ERR_ONLY_AMMO_CAN_GO_HERE;
|
||||
|
||||
uint8 msg = CanUseItem(pProto);
|
||||
InventoryResult msg = CanUseItem(pProto);
|
||||
if (msg != EQUIP_ERR_OK)
|
||||
return msg;
|
||||
|
||||
|
|
@ -10972,7 +10972,7 @@ void Player::SetAmmo( uint32 item )
|
|||
// check ammo
|
||||
if (item)
|
||||
{
|
||||
uint8 msg = CanUseAmmo( item );
|
||||
InventoryResult msg = CanUseAmmo( item );
|
||||
if (msg != EQUIP_ERR_OK)
|
||||
{
|
||||
SendEquipError(msg, NULL, NULL, item);
|
||||
|
|
@ -11791,7 +11791,7 @@ void Player::SplitItem( uint16 src, uint16 dst, uint32 count )
|
|||
pSrcItem->SetCount( pSrcItem->GetCount() - count );
|
||||
|
||||
ItemPosCountVec dest;
|
||||
uint8 msg = CanStoreItem( dstbag, dstslot, dest, pNewItem, false );
|
||||
InventoryResult msg = CanStoreItem( dstbag, dstslot, dest, pNewItem, false );
|
||||
if (msg != EQUIP_ERR_OK)
|
||||
{
|
||||
delete pNewItem;
|
||||
|
|
@ -11811,7 +11811,7 @@ void Player::SplitItem( uint16 src, uint16 dst, uint32 count )
|
|||
pSrcItem->SetCount( pSrcItem->GetCount() - count );
|
||||
|
||||
ItemPosCountVec dest;
|
||||
uint8 msg = CanBankItem( dstbag, dstslot, dest, pNewItem, false );
|
||||
InventoryResult msg = CanBankItem( dstbag, dstslot, dest, pNewItem, false );
|
||||
if( msg != EQUIP_ERR_OK )
|
||||
{
|
||||
delete pNewItem;
|
||||
|
|
@ -11831,7 +11831,7 @@ void Player::SplitItem( uint16 src, uint16 dst, uint32 count )
|
|||
pSrcItem->SetCount( pSrcItem->GetCount() - count );
|
||||
|
||||
uint16 dest;
|
||||
uint8 msg = CanEquipItem( dstslot, dest, pNewItem, false );
|
||||
InventoryResult msg = CanEquipItem( dstslot, dest, pNewItem, false );
|
||||
if (msg != EQUIP_ERR_OK)
|
||||
{
|
||||
delete pNewItem;
|
||||
|
|
@ -11876,7 +11876,7 @@ void Player::SwapItem( uint16 src, uint16 dst )
|
|||
if (IsEquipmentPos(src) || IsBagPos(src))
|
||||
{
|
||||
// bags can be swapped with empty bag slots, or with empty bag (items move possibility checked later)
|
||||
uint8 msg = CanUnequipItem( src, !IsBagPos ( src ) || IsBagPos ( dst ) || (pDstItem && pDstItem->IsBag() && ((Bag*)pDstItem)->IsEmpty()));
|
||||
InventoryResult msg = CanUnequipItem( src, !IsBagPos ( src ) || IsBagPos ( dst ) || (pDstItem && pDstItem->IsBag() && ((Bag*)pDstItem)->IsEmpty()));
|
||||
if (msg != EQUIP_ERR_OK)
|
||||
{
|
||||
SendEquipError( msg, pSrcItem, pDstItem );
|
||||
|
|
@ -11906,7 +11906,7 @@ void Player::SwapItem( uint16 src, uint16 dst )
|
|||
if(IsEquipmentPos ( dst ) || IsBagPos ( dst ))
|
||||
{
|
||||
// bags can be swapped with empty bag slots, or with empty bag (items move possibility checked later)
|
||||
uint8 msg = CanUnequipItem( dst, !IsBagPos ( dst ) || IsBagPos ( src ) || (pSrcItem->IsBag() && ((Bag*)pSrcItem)->IsEmpty()));
|
||||
InventoryResult msg = CanUnequipItem( dst, !IsBagPos ( dst ) || IsBagPos ( src ) || (pSrcItem->IsBag() && ((Bag*)pSrcItem)->IsEmpty()));
|
||||
if(msg != EQUIP_ERR_OK)
|
||||
{
|
||||
SendEquipError( msg, pSrcItem, pDstItem );
|
||||
|
|
@ -11924,7 +11924,7 @@ void Player::SwapItem( uint16 src, uint16 dst )
|
|||
if( IsInventoryPos( dst ) )
|
||||
{
|
||||
ItemPosCountVec dest;
|
||||
uint8 msg = CanStoreItem( dstbag, dstslot, dest, pSrcItem, false );
|
||||
InventoryResult msg = CanStoreItem( dstbag, dstslot, dest, pSrcItem, false );
|
||||
if( msg != EQUIP_ERR_OK )
|
||||
{
|
||||
SendEquipError( msg, pSrcItem, NULL );
|
||||
|
|
@ -11937,7 +11937,7 @@ void Player::SwapItem( uint16 src, uint16 dst )
|
|||
else if( IsBankPos ( dst ) )
|
||||
{
|
||||
ItemPosCountVec dest;
|
||||
uint8 msg = CanBankItem( dstbag, dstslot, dest, pSrcItem, false);
|
||||
InventoryResult msg = CanBankItem( dstbag, dstslot, dest, pSrcItem, false);
|
||||
if( msg != EQUIP_ERR_OK )
|
||||
{
|
||||
SendEquipError( msg, pSrcItem, NULL );
|
||||
|
|
@ -11950,7 +11950,7 @@ void Player::SwapItem( uint16 src, uint16 dst )
|
|||
else if( IsEquipmentPos ( dst ) )
|
||||
{
|
||||
uint16 dest;
|
||||
uint8 msg = CanEquipItem( dstslot, dest, pSrcItem, false );
|
||||
InventoryResult msg = CanEquipItem( dstslot, dest, pSrcItem, false );
|
||||
if( msg != EQUIP_ERR_OK )
|
||||
{
|
||||
SendEquipError( msg, pSrcItem, NULL );
|
||||
|
|
@ -11968,7 +11968,7 @@ void Player::SwapItem( uint16 src, uint16 dst )
|
|||
// attempt merge to / fill target item
|
||||
if(!pSrcItem->IsBag() && !pDstItem->IsBag())
|
||||
{
|
||||
uint8 msg;
|
||||
InventoryResult msg;
|
||||
ItemPosCountVec sDest;
|
||||
uint16 eDest;
|
||||
if( IsInventoryPos( dst ) )
|
||||
|
|
@ -12014,7 +12014,7 @@ void Player::SwapItem( uint16 src, uint16 dst )
|
|||
}
|
||||
|
||||
// impossible merge/fill, do real swap
|
||||
uint8 msg;
|
||||
InventoryResult msg;
|
||||
|
||||
// check src->dest move possibility
|
||||
ItemPosCountVec sDest;
|
||||
|
|
@ -12096,7 +12096,6 @@ void Player::SwapItem( uint16 src, uint16 dst )
|
|||
++count;
|
||||
}
|
||||
|
||||
|
||||
if (count > emptyBag->GetBagSize())
|
||||
{
|
||||
// too small targeted bag
|
||||
|
|
@ -12231,7 +12230,7 @@ void Player::RemoveItemFromBuyBackSlot( uint32 slot, bool del )
|
|||
}
|
||||
}
|
||||
|
||||
void Player::SendEquipError( uint8 msg, Item* pItem, Item *pItem2, uint32 itemid /*= 0*/ ) const
|
||||
void Player::SendEquipError( InventoryResult msg, Item* pItem, Item *pItem2, uint32 itemid /*= 0*/ ) const
|
||||
{
|
||||
DEBUG_LOG( "WORLD: Sent SMSG_INVENTORY_CHANGE_FAILURE (%u)", msg);
|
||||
WorldPacket data(SMSG_INVENTORY_CHANGE_FAILURE, 1+8+8+1);
|
||||
|
|
@ -12274,7 +12273,7 @@ void Player::SendEquipError( uint8 msg, Item* pItem, Item *pItem2, uint32 itemid
|
|||
GetSession()->SendPacket(&data);
|
||||
}
|
||||
|
||||
void Player::SendBuyError( uint8 msg, Creature* pCreature, uint32 item, uint32 param )
|
||||
void Player::SendBuyError( BuyResult msg, Creature* pCreature, uint32 item, uint32 param )
|
||||
{
|
||||
DEBUG_LOG( "WORLD: Sent SMSG_BUY_FAILED" );
|
||||
WorldPacket data( SMSG_BUY_FAILED, (8+4+4+1) );
|
||||
|
|
@ -12286,7 +12285,7 @@ void Player::SendBuyError( uint8 msg, Creature* pCreature, uint32 item, uint32 p
|
|||
GetSession()->SendPacket(&data);
|
||||
}
|
||||
|
||||
void Player::SendSellError( uint8 msg, Creature* pCreature, uint64 guid, uint32 param )
|
||||
void Player::SendSellError( SellResult msg, Creature* pCreature, uint64 guid, uint32 param )
|
||||
{
|
||||
DEBUG_LOG( "WORLD: Sent SMSG_SELL_ITEM" );
|
||||
WorldPacket data( SMSG_SELL_ITEM,(8+8+(param?4:0)+1)); // last check 2.0.10
|
||||
|
|
@ -13657,7 +13656,7 @@ bool Player::CanRewardQuest(Quest const *pQuest, uint32 reward, bool msg) const
|
|||
if (pQuest->RewChoiceItemId[reward])
|
||||
{
|
||||
ItemPosCountVec dest;
|
||||
uint8 res = CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, pQuest->RewChoiceItemId[reward], pQuest->RewChoiceItemCount[reward] );
|
||||
InventoryResult res = CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, pQuest->RewChoiceItemId[reward], pQuest->RewChoiceItemCount[reward] );
|
||||
if (res != EQUIP_ERR_OK)
|
||||
{
|
||||
SendEquipError(res, NULL, NULL, pQuest->RewChoiceItemId[reward]);
|
||||
|
|
@ -13673,7 +13672,7 @@ bool Player::CanRewardQuest(Quest const *pQuest, uint32 reward, bool msg) const
|
|||
if (pQuest->RewItemId[i])
|
||||
{
|
||||
ItemPosCountVec dest;
|
||||
uint8 res = CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, pQuest->RewItemId[i], pQuest->RewItemCount[i] );
|
||||
InventoryResult res = CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, pQuest->RewItemId[i], pQuest->RewItemCount[i] );
|
||||
if (res != EQUIP_ERR_OK)
|
||||
{
|
||||
SendEquipError(res, NULL, NULL);
|
||||
|
|
@ -14376,7 +14375,7 @@ bool Player::CanGiveQuestSourceItem( Quest const *pQuest, ItemPosCountVec* dest
|
|||
if( count <= 0 )
|
||||
count = 1;
|
||||
|
||||
uint8 msg;
|
||||
InventoryResult msg;
|
||||
if (!dest)
|
||||
{
|
||||
ItemPosCountVec destTemp;
|
||||
|
|
@ -14428,7 +14427,7 @@ bool Player::TakeQuestSourceItem( uint32 quest_id, bool msg )
|
|||
|
||||
// exist one case when destroy source quest item not possible:
|
||||
// non un-equippable item (equipped non-empty bag, for example)
|
||||
uint8 res = CanUnequipItems(srcitem,count);
|
||||
InventoryResult res = CanUnequipItems(srcitem,count);
|
||||
if(res != EQUIP_ERR_OK)
|
||||
{
|
||||
if(msg)
|
||||
|
|
@ -15003,7 +15002,7 @@ void Player::SendQuestReward( Quest const *pQuest, uint32 XP, Object * questGive
|
|||
GetSession()->SendPacket( &data );
|
||||
}
|
||||
|
||||
void Player::SendQuestFailed( uint32 quest_id, InventoryChangeFailure reason)
|
||||
void Player::SendQuestFailed( uint32 quest_id, InventoryResult reason)
|
||||
{
|
||||
if( quest_id )
|
||||
{
|
||||
|
|
@ -19196,7 +19195,7 @@ bool Player::BuyItemFromVendorSlot(ObjectGuid vendorGuid, uint32 vendorslot, uin
|
|||
if ((bag == NULL_BAG && slot == NULL_SLOT) || IsInventoryPos(bag, slot))
|
||||
{
|
||||
ItemPosCountVec dest;
|
||||
uint8 msg = CanStoreNewItem(bag, slot, dest, item, totalCount);
|
||||
InventoryResult msg = CanStoreNewItem(bag, slot, dest, item, totalCount);
|
||||
if (msg != EQUIP_ERR_OK)
|
||||
{
|
||||
SendEquipError(msg, NULL, NULL, item);
|
||||
|
|
@ -19219,7 +19218,7 @@ bool Player::BuyItemFromVendorSlot(ObjectGuid vendorGuid, uint32 vendorslot, uin
|
|||
}
|
||||
|
||||
uint16 dest;
|
||||
uint8 msg = CanEquipNewItem(slot, dest, item, false);
|
||||
InventoryResult msg = CanEquipNewItem(slot, dest, item, false);
|
||||
if (msg != EQUIP_ERR_OK)
|
||||
{
|
||||
SendEquipError(msg, NULL, NULL, item);
|
||||
|
|
@ -21474,7 +21473,7 @@ void Player::AutoStoreLoot(Loot& loot, bool broadcast, uint8 bag, uint8 slot)
|
|||
LootItem* lootItem = loot.LootItemInSlot(i,this);
|
||||
|
||||
ItemPosCountVec dest;
|
||||
uint8 msg = CanStoreNewItem (bag,slot,dest,lootItem->itemid,lootItem->count);
|
||||
InventoryResult msg = CanStoreNewItem(bag,slot,dest,lootItem->itemid,lootItem->count);
|
||||
if(msg != EQUIP_ERR_OK && slot != NULL_SLOT)
|
||||
msg = CanStoreNewItem( bag, NULL_SLOT,dest,lootItem->itemid,lootItem->count);
|
||||
if( msg != EQUIP_ERR_OK && bag != NULL_BAG)
|
||||
|
|
@ -21652,12 +21651,12 @@ uint32 Player::GetPhaseMaskForSpawn() const
|
|||
return PHASEMASK_NORMAL;
|
||||
}
|
||||
|
||||
uint8 Player::CanEquipUniqueItem(Item* pItem, uint8 eslot, uint32 limit_count) const
|
||||
InventoryResult Player::CanEquipUniqueItem(Item* pItem, uint8 eslot, uint32 limit_count) const
|
||||
{
|
||||
ItemPrototype const* pProto = pItem->GetProto();
|
||||
|
||||
// proto based limitations
|
||||
if(uint8 res = CanEquipUniqueItem(pProto,eslot,limit_count))
|
||||
if(InventoryResult res = CanEquipUniqueItem(pProto,eslot,limit_count))
|
||||
return res;
|
||||
|
||||
// check unique-equipped on gems
|
||||
|
|
@ -21678,14 +21677,14 @@ uint8 Player::CanEquipUniqueItem(Item* pItem, uint8 eslot, uint32 limit_count) c
|
|||
uint32 gem_limit_count = !pItem->IsEquipped() && pGem->ItemLimitCategory
|
||||
? pItem->GetGemCountWithLimitCategory(pGem->ItemLimitCategory) : 1;
|
||||
|
||||
if(uint8 res = CanEquipUniqueItem(pGem, eslot,gem_limit_count))
|
||||
if(InventoryResult res = CanEquipUniqueItem(pGem, eslot,gem_limit_count))
|
||||
return res;
|
||||
}
|
||||
|
||||
return EQUIP_ERR_OK;
|
||||
}
|
||||
|
||||
uint8 Player::CanEquipUniqueItem( ItemPrototype const* itemProto, uint8 except_slot, uint32 limit_count) const
|
||||
InventoryResult Player::CanEquipUniqueItem( ItemPrototype const* itemProto, uint8 except_slot, uint32 limit_count) const
|
||||
{
|
||||
// check unique-equipped on item
|
||||
if (itemProto->Flags & ITEM_FLAG_UNIQUE_EQUIPPED)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue