[8092] No, one more not safe place found.

Patch inspired bug report connected with alt.patch written by Machiavelli.
This commit is contained in:
VladimirMangos 2009-06-29 13:19:42 +04:00
parent ac7a7417fe
commit f80f45e3c4
2 changed files with 151 additions and 148 deletions

View file

@ -8701,39 +8701,42 @@ uint8 Player::_CanStoreItem_InSpecificSlot( uint8 bag, uint8 slot, ItemPosCountV
Item* pItem2 = GetItemByPos( bag, slot ); Item* pItem2 = GetItemByPos( bag, slot );
// ignore move item (this slot will be empty at move) // ignore move item (this slot will be empty at move)
if(pItem2==pSrcItem) if (pItem2==pSrcItem)
pItem2 = NULL; pItem2 = NULL;
uint32 need_space; uint32 need_space;
// empty specific slot - check item fit to slot // empty specific slot - check item fit to slot
if( !pItem2 || swap ) if (!pItem2 || swap)
{ {
if( bag == INVENTORY_SLOT_BAG_0 ) if (bag == INVENTORY_SLOT_BAG_0)
{ {
// keyring case // keyring case
if(slot >= KEYRING_SLOT_START && slot < KEYRING_SLOT_START+GetMaxKeyringSize() && !(pProto->BagFamily & BAG_FAMILY_MASK_KEYS)) if (slot >= KEYRING_SLOT_START && slot < KEYRING_SLOT_START+GetMaxKeyringSize() && !(pProto->BagFamily & BAG_FAMILY_MASK_KEYS))
return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG;
// currencytoken case // currencytoken case
if(slot >= CURRENCYTOKEN_SLOT_START && slot < CURRENCYTOKEN_SLOT_END && !(pProto->BagFamily & BAG_FAMILY_MASK_CURRENCY_TOKENS)) if (slot >= CURRENCYTOKEN_SLOT_START && slot < CURRENCYTOKEN_SLOT_END && !(pProto->BagFamily & BAG_FAMILY_MASK_CURRENCY_TOKENS))
return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG;
// prevent cheating // prevent cheating
if(slot >= BUYBACK_SLOT_START && slot < BUYBACK_SLOT_END || slot >= PLAYER_SLOT_END) if (slot >= BUYBACK_SLOT_START && slot < BUYBACK_SLOT_END || slot >= PLAYER_SLOT_END)
return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG;
} }
else else
{ {
Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, bag ); Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, bag );
if( !pBag ) if (!pBag)
return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG;
ItemPrototype const* pBagProto = pBag->GetProto(); ItemPrototype const* pBagProto = pBag->GetProto();
if( !pBagProto ) if (!pBagProto)
return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG;
if( !ItemCanGoIntoBag(pProto,pBagProto) ) if (slot >= pBagProto->ContainerSlots)
return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG;
if (!ItemCanGoIntoBag(pProto,pBagProto))
return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG;
} }
@ -8744,22 +8747,22 @@ uint8 Player::_CanStoreItem_InSpecificSlot( uint8 bag, uint8 slot, ItemPosCountV
else else
{ {
// check item type // check item type
if(pItem2->GetEntry() != pProto->ItemId) if (pItem2->GetEntry() != pProto->ItemId)
return EQUIP_ERR_ITEM_CANT_STACK; return EQUIP_ERR_ITEM_CANT_STACK;
// check free space // check free space
if(pItem2->GetCount() >= pProto->GetMaxStackSize()) if (pItem2->GetCount() >= pProto->GetMaxStackSize())
return EQUIP_ERR_ITEM_CANT_STACK; return EQUIP_ERR_ITEM_CANT_STACK;
// free stack space or infinity // free stack space or infinity
need_space = pProto->GetMaxStackSize() - pItem2->GetCount(); need_space = pProto->GetMaxStackSize() - pItem2->GetCount();
} }
if(need_space > count) if (need_space > count)
need_space = count; need_space = count;
ItemPosCount newPosition = ItemPosCount((bag << 8) | slot, need_space); ItemPosCount newPosition = ItemPosCount((bag << 8) | slot, need_space);
if(!newPosition.isContainedIn(dest)) if (!newPosition.isContainedIn(dest))
{ {
dest.push_back(newPosition); dest.push_back(newPosition);
count -= need_space; count -= need_space;
@ -8770,55 +8773,55 @@ uint8 Player::_CanStoreItem_InSpecificSlot( uint8 bag, uint8 slot, ItemPosCountV
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 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
{ {
// skip specific bag already processed in first called _CanStoreItem_InBag // 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; return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG;
Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, bag ); Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, bag );
if( !pBag ) if (!pBag)
return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG;
ItemPrototype const* pBagProto = pBag->GetProto(); ItemPrototype const* pBagProto = pBag->GetProto();
if( !pBagProto ) if (!pBagProto)
return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG;
// specialized bag mode or non-specilized // specialized bag mode or non-specilized
if( non_specialized != (pBagProto->Class == ITEM_CLASS_CONTAINER && pBagProto->SubClass == ITEM_SUBCLASS_CONTAINER) ) if (non_specialized != (pBagProto->Class == ITEM_CLASS_CONTAINER && pBagProto->SubClass == ITEM_SUBCLASS_CONTAINER))
return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG;
if( !ItemCanGoIntoBag(pProto,pBagProto) ) if (!ItemCanGoIntoBag(pProto,pBagProto))
return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG;
for(uint32 j = 0; j < pBag->GetBagSize(); ++j) for(uint32 j = 0; j < pBag->GetBagSize(); ++j)
{ {
// skip specific slot already processed in first called _CanStoreItem_InSpecificSlot // skip specific slot already processed in first called _CanStoreItem_InSpecificSlot
if(j==skip_slot) if (j==skip_slot)
continue; continue;
Item* pItem2 = GetItemByPos( bag, j ); Item* pItem2 = GetItemByPos( bag, j );
// ignore move item (this slot will be empty at move) // ignore move item (this slot will be empty at move)
if(pItem2==pSrcItem) if (pItem2==pSrcItem)
pItem2 = NULL; pItem2 = NULL;
// if merge skip empty, if !merge skip non-empty // if merge skip empty, if !merge skip non-empty
if((pItem2!=NULL)!=merge) if ((pItem2!=NULL)!=merge)
continue; continue;
if( pItem2 ) if (pItem2)
{ {
if(pItem2->GetEntry() == pProto->ItemId && pItem2->GetCount() < pProto->GetMaxStackSize()) if (pItem2->GetEntry() == pProto->ItemId && pItem2->GetCount() < pProto->GetMaxStackSize())
{ {
uint32 need_space = pProto->GetMaxStackSize() - pItem2->GetCount(); uint32 need_space = pProto->GetMaxStackSize() - pItem2->GetCount();
if(need_space > count) if(need_space > count)
need_space = count; need_space = count;
ItemPosCount newPosition = ItemPosCount((bag << 8) | j, need_space); ItemPosCount newPosition = ItemPosCount((bag << 8) | j, need_space);
if(!newPosition.isContainedIn(dest)) if (!newPosition.isContainedIn(dest))
{ {
dest.push_back(newPosition); dest.push_back(newPosition);
count -= need_space; count -= need_space;
if(count==0) if (count==0)
return EQUIP_ERR_OK; return EQUIP_ERR_OK;
} }
} }
@ -8826,16 +8829,16 @@ uint8 Player::_CanStoreItem_InBag( uint8 bag, ItemPosCountVec &dest, ItemPrototy
else else
{ {
uint32 need_space = pProto->GetMaxStackSize(); uint32 need_space = pProto->GetMaxStackSize();
if(need_space > count) if (need_space > count)
need_space = count; need_space = count;
ItemPosCount newPosition = ItemPosCount((bag << 8) | j, need_space); ItemPosCount newPosition = ItemPosCount((bag << 8) | j, need_space);
if(!newPosition.isContainedIn(dest)) if (!newPosition.isContainedIn(dest))
{ {
dest.push_back(newPosition); dest.push_back(newPosition);
count -= need_space; count -= need_space;
if(count==0) if (count==0)
return EQUIP_ERR_OK; return EQUIP_ERR_OK;
} }
} }
@ -8848,33 +8851,33 @@ uint8 Player::_CanStoreItem_InInventorySlots( uint8 slot_begin, uint8 slot_end,
for(uint32 j = slot_begin; j < slot_end; ++j) for(uint32 j = slot_begin; j < slot_end; ++j)
{ {
// skip specific slot already processed in first called _CanStoreItem_InSpecificSlot // skip specific slot already processed in first called _CanStoreItem_InSpecificSlot
if(INVENTORY_SLOT_BAG_0==skip_bag && j==skip_slot) if (INVENTORY_SLOT_BAG_0==skip_bag && j==skip_slot)
continue; continue;
Item* pItem2 = GetItemByPos( INVENTORY_SLOT_BAG_0, j ); Item* pItem2 = GetItemByPos( INVENTORY_SLOT_BAG_0, j );
// ignore move item (this slot will be empty at move) // ignore move item (this slot will be empty at move)
if(pItem2==pSrcItem) if (pItem2==pSrcItem)
pItem2 = NULL; pItem2 = NULL;
// if merge skip empty, if !merge skip non-empty // if merge skip empty, if !merge skip non-empty
if((pItem2!=NULL)!=merge) if ((pItem2!=NULL)!=merge)
continue; continue;
if( pItem2 ) if (pItem2)
{ {
if(pItem2->GetEntry() == pProto->ItemId && pItem2->GetCount() < pProto->GetMaxStackSize()) if (pItem2->GetEntry() == pProto->ItemId && pItem2->GetCount() < pProto->GetMaxStackSize())
{ {
uint32 need_space = pProto->GetMaxStackSize() - pItem2->GetCount(); uint32 need_space = pProto->GetMaxStackSize() - pItem2->GetCount();
if(need_space > count) if (need_space > count)
need_space = count; need_space = count;
ItemPosCount newPosition = ItemPosCount((INVENTORY_SLOT_BAG_0 << 8) | j, need_space); ItemPosCount newPosition = ItemPosCount((INVENTORY_SLOT_BAG_0 << 8) | j, need_space);
if(!newPosition.isContainedIn(dest)) if (!newPosition.isContainedIn(dest))
{ {
dest.push_back(newPosition); dest.push_back(newPosition);
count -= need_space; count -= need_space;
if(count==0) if (count==0)
return EQUIP_ERR_OK; return EQUIP_ERR_OK;
} }
} }
@ -8882,16 +8885,16 @@ uint8 Player::_CanStoreItem_InInventorySlots( uint8 slot_begin, uint8 slot_end,
else else
{ {
uint32 need_space = pProto->GetMaxStackSize(); uint32 need_space = pProto->GetMaxStackSize();
if(need_space > count) if (need_space > count)
need_space = count; need_space = count;
ItemPosCount newPosition = ItemPosCount((INVENTORY_SLOT_BAG_0 << 8) | j, need_space); ItemPosCount newPosition = ItemPosCount((INVENTORY_SLOT_BAG_0 << 8) | j, need_space);
if(!newPosition.isContainedIn(dest)) if (!newPosition.isContainedIn(dest))
{ {
dest.push_back(newPosition); dest.push_back(newPosition);
count -= need_space; count -= need_space;
if(count==0) if (count==0)
return EQUIP_ERR_OK; return EQUIP_ERR_OK;
} }
} }
@ -8904,16 +8907,16 @@ uint8 Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, uint3
sLog.outDebug( "STORAGE: CanStoreItem bag = %u, slot = %u, item = %u, count = %u", bag, slot, entry, count); sLog.outDebug( "STORAGE: CanStoreItem bag = %u, slot = %u, item = %u, count = %u", bag, slot, entry, count);
ItemPrototype const *pProto = objmgr.GetItemPrototype(entry); ItemPrototype const *pProto = objmgr.GetItemPrototype(entry);
if( !pProto ) if (!pProto)
{ {
if(no_space_count) if (no_space_count)
*no_space_count = count; *no_space_count = count;
return swap ? EQUIP_ERR_ITEMS_CANT_BE_SWAPPED :EQUIP_ERR_ITEM_NOT_FOUND; return swap ? EQUIP_ERR_ITEMS_CANT_BE_SWAPPED :EQUIP_ERR_ITEM_NOT_FOUND;
} }
if(pItem && pItem->IsBindedNotWith(this)) if (pItem && pItem->IsBindedNotWith(this))
{ {
if(no_space_count) if (no_space_count)
*no_space_count = count; *no_space_count = count;
return EQUIP_ERR_DONT_OWN_THAT_ITEM; return EQUIP_ERR_DONT_OWN_THAT_ITEM;
} }
@ -8921,11 +8924,11 @@ uint8 Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, uint3
// check count of items (skip for auto move for same player from bank) // 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 uint32 no_similar_count = 0; // can't store this amount similar items
uint8 res = _CanTakeMoreSimilarItems(entry,count,pItem,&no_similar_count); uint8 res = _CanTakeMoreSimilarItems(entry,count,pItem,&no_similar_count);
if(res!=EQUIP_ERR_OK) if (res!=EQUIP_ERR_OK)
{ {
if(count==no_similar_count) if (count==no_similar_count)
{ {
if(no_space_count) if (no_space_count)
*no_space_count = no_similar_count; *no_space_count = no_similar_count;
return res; return res;
} }
@ -8933,22 +8936,22 @@ uint8 Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, uint3
} }
// in specific slot // in specific slot
if( bag != NULL_BAG && slot != NULL_SLOT ) if (bag != NULL_BAG && slot != NULL_SLOT)
{ {
res = _CanStoreItem_InSpecificSlot(bag,slot,dest,pProto,count,swap,pItem); res = _CanStoreItem_InSpecificSlot(bag,slot,dest,pProto,count,swap,pItem);
if(res!=EQUIP_ERR_OK) if (res!=EQUIP_ERR_OK)
{ {
if(no_space_count) if (no_space_count)
*no_space_count = count + no_similar_count; *no_space_count = count + no_similar_count;
return res; return res;
} }
if(count==0) if (count==0)
{ {
if(no_similar_count==0) if (no_similar_count==0)
return EQUIP_ERR_OK; return EQUIP_ERR_OK;
if(no_space_count) if (no_space_count)
*no_space_count = count + no_similar_count; *no_space_count = count + no_similar_count;
return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS;
} }
@ -8957,45 +8960,45 @@ uint8 Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, uint3
// not specific slot or have space for partly store only in specific slot // not specific slot or have space for partly store only in specific slot
// in specific bag // in specific bag
if( bag != NULL_BAG ) if (bag != NULL_BAG)
{ {
// search stack in bag for merge to // search stack in bag for merge to
if( pProto->Stackable != 1 ) if (pProto->Stackable != 1)
{ {
if( bag == INVENTORY_SLOT_BAG_0 ) // inventory if (bag == INVENTORY_SLOT_BAG_0) // inventory
{ {
res = _CanStoreItem_InInventorySlots(KEYRING_SLOT_START,CURRENCYTOKEN_SLOT_END,dest,pProto,count,true,pItem,bag,slot); 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) if (no_space_count)
*no_space_count = count + no_similar_count; *no_space_count = count + no_similar_count;
return res; return res;
} }
if(count==0) if (count==0)
{ {
if(no_similar_count==0) if (no_similar_count==0)
return EQUIP_ERR_OK; return EQUIP_ERR_OK;
if(no_space_count) if (no_space_count)
*no_space_count = count + no_similar_count; *no_space_count = count + no_similar_count;
return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS;
} }
res = _CanStoreItem_InInventorySlots(INVENTORY_SLOT_ITEM_START,INVENTORY_SLOT_ITEM_END,dest,pProto,count,true,pItem,bag,slot); 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) if (no_space_count)
*no_space_count = count + no_similar_count; *no_space_count = count + no_similar_count;
return res; return res;
} }
if(count==0) if (count==0)
{ {
if(no_similar_count==0) if (no_similar_count==0)
return EQUIP_ERR_OK; return EQUIP_ERR_OK;
if(no_space_count) if (no_space_count)
*no_space_count = count + no_similar_count; *no_space_count = count + no_similar_count;
return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS;
} }
@ -9004,22 +9007,22 @@ 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 // 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); 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); 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) if (no_space_count)
*no_space_count = count + no_similar_count; *no_space_count = count + no_similar_count;
return res; return res;
} }
if(count==0) if (count==0)
{ {
if(no_similar_count==0) if (no_similar_count==0)
return EQUIP_ERR_OK; return EQUIP_ERR_OK;
if(no_space_count) if (no_space_count)
*no_space_count = count + no_similar_count; *no_space_count = count + no_similar_count;
return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS;
} }
@ -9027,83 +9030,83 @@ uint8 Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, uint3
} }
// search free slot in bag for place to // search free slot in bag for place to
if( bag == INVENTORY_SLOT_BAG_0 ) // inventory if(bag == INVENTORY_SLOT_BAG_0) // inventory
{ {
// search free slot - keyring case // search free slot - keyring case
if(pProto->BagFamily & BAG_FAMILY_MASK_KEYS) if (pProto->BagFamily & BAG_FAMILY_MASK_KEYS)
{ {
uint32 keyringSize = GetMaxKeyringSize(); uint32 keyringSize = GetMaxKeyringSize();
res = _CanStoreItem_InInventorySlots(KEYRING_SLOT_START,KEYRING_SLOT_START+keyringSize,dest,pProto,count,false,pItem,bag,slot); 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) if (no_space_count)
*no_space_count = count + no_similar_count; *no_space_count = count + no_similar_count;
return res; return res;
} }
if(count==0) if (count==0)
{ {
if(no_similar_count==0) if (no_similar_count==0)
return EQUIP_ERR_OK; return EQUIP_ERR_OK;
if(no_space_count) if (no_space_count)
*no_space_count = count + no_similar_count; *no_space_count = count + no_similar_count;
return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS;
} }
res = _CanStoreItem_InInventorySlots(CURRENCYTOKEN_SLOT_START,CURRENCYTOKEN_SLOT_END,dest,pProto,count,false,pItem,bag,slot); 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) if (no_space_count)
*no_space_count = count + no_similar_count; *no_space_count = count + no_similar_count;
return res; return res;
} }
if(count==0) if (count==0)
{ {
if(no_similar_count==0) if (no_similar_count==0)
return EQUIP_ERR_OK; return EQUIP_ERR_OK;
if(no_space_count) if (no_space_count)
*no_space_count = count + no_similar_count; *no_space_count = count + no_similar_count;
return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS;
} }
} }
else if(pProto->BagFamily & BAG_FAMILY_MASK_CURRENCY_TOKENS) 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); 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) if (no_space_count)
*no_space_count = count + no_similar_count; *no_space_count = count + no_similar_count;
return res; return res;
} }
if(count==0) if (count==0)
{ {
if(no_similar_count==0) if (no_similar_count==0)
return EQUIP_ERR_OK; return EQUIP_ERR_OK;
if(no_space_count) if (no_space_count)
*no_space_count = count + no_similar_count; *no_space_count = count + no_similar_count;
return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS;
} }
} }
res = _CanStoreItem_InInventorySlots(INVENTORY_SLOT_ITEM_START,INVENTORY_SLOT_ITEM_END,dest,pProto,count,false,pItem,bag,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) if (no_space_count)
*no_space_count = count + no_similar_count; *no_space_count = count + no_similar_count;
return res; return res;
} }
if(count==0) if (count==0)
{ {
if(no_similar_count==0) if (no_similar_count==0)
return EQUIP_ERR_OK; return EQUIP_ERR_OK;
if(no_space_count) if (no_space_count)
*no_space_count = count + no_similar_count; *no_space_count = count + no_similar_count;
return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS;
} }
@ -9111,22 +9114,22 @@ uint8 Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, uint3
else // equipped bag else // equipped bag
{ {
res = _CanStoreItem_InBag(bag,dest,pProto,count,false,false,pItem,NULL_BAG,slot); 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); 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) if (no_space_count)
*no_space_count = count + no_similar_count; *no_space_count = count + no_similar_count;
return res; return res;
} }
if(count==0) if (count==0)
{ {
if(no_similar_count==0) if (no_similar_count==0)
return EQUIP_ERR_OK; return EQUIP_ERR_OK;
if(no_space_count) if (no_space_count)
*no_space_count = count + no_similar_count; *no_space_count = count + no_similar_count;
return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS;
} }
@ -9136,58 +9139,58 @@ uint8 Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, uint3
// not specific bag or have space for partly store only in specific bag // not specific bag or have space for partly store only in specific bag
// search stack for merge to // search stack for merge to
if( pProto->Stackable != 1 ) if (pProto->Stackable != 1)
{ {
res = _CanStoreItem_InInventorySlots(KEYRING_SLOT_START,CURRENCYTOKEN_SLOT_END,dest,pProto,count,true,pItem,bag,slot); 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) if (no_space_count)
*no_space_count = count + no_similar_count; *no_space_count = count + no_similar_count;
return res; return res;
} }
if(count==0) if (count==0)
{ {
if(no_similar_count==0) if (no_similar_count==0)
return EQUIP_ERR_OK; return EQUIP_ERR_OK;
if(no_space_count) if (no_space_count)
*no_space_count = count + no_similar_count; *no_space_count = count + no_similar_count;
return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS;
} }
res = _CanStoreItem_InInventorySlots(INVENTORY_SLOT_ITEM_START,INVENTORY_SLOT_ITEM_END,dest,pProto,count,true,pItem,bag,slot); 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) if (no_space_count)
*no_space_count = count + no_similar_count; *no_space_count = count + no_similar_count;
return res; return res;
} }
if(count==0) if (count==0)
{ {
if(no_similar_count==0) if (no_similar_count==0)
return EQUIP_ERR_OK; return EQUIP_ERR_OK;
if(no_space_count) if (no_space_count)
*no_space_count = count + no_similar_count; *no_space_count = count + no_similar_count;
return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS;
} }
if( pProto->BagFamily ) if (pProto->BagFamily)
{ {
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)
{ {
res = _CanStoreItem_InBag(i,dest,pProto,count,true,false,pItem,bag,slot); res = _CanStoreItem_InBag(i,dest,pProto,count,true,false,pItem,bag,slot);
if(res!=EQUIP_ERR_OK) if (res!=EQUIP_ERR_OK)
continue; continue;
if(count==0) if (count==0)
{ {
if(no_similar_count==0) if (no_similar_count==0)
return EQUIP_ERR_OK; return EQUIP_ERR_OK;
if(no_space_count) if (no_space_count)
*no_space_count = count + no_similar_count; *no_space_count = count + no_similar_count;
return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS;
} }
@ -9197,15 +9200,15 @@ uint8 Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, uint3
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)
{ {
res = _CanStoreItem_InBag(i,dest,pProto,count,true,true,pItem,bag,slot); res = _CanStoreItem_InBag(i,dest,pProto,count,true,true,pItem,bag,slot);
if(res!=EQUIP_ERR_OK) if (res!=EQUIP_ERR_OK)
continue; continue;
if(count==0) if (count==0)
{ {
if(no_similar_count==0) if (no_similar_count==0)
return EQUIP_ERR_OK; return EQUIP_ERR_OK;
if(no_space_count) if (no_space_count)
*no_space_count = count + no_similar_count; *no_space_count = count + no_similar_count;
return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS;
} }
@ -9213,45 +9216,45 @@ uint8 Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, uint3
} }
// search free slot - special bag case // search free slot - special bag case
if( pProto->BagFamily ) if (pProto->BagFamily)
{ {
if(pProto->BagFamily & BAG_FAMILY_MASK_KEYS) if (pProto->BagFamily & BAG_FAMILY_MASK_KEYS)
{ {
uint32 keyringSize = GetMaxKeyringSize(); uint32 keyringSize = GetMaxKeyringSize();
res = _CanStoreItem_InInventorySlots(KEYRING_SLOT_START,KEYRING_SLOT_START+keyringSize,dest,pProto,count,false,pItem,bag,slot); 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) if (no_space_count)
*no_space_count = count + no_similar_count; *no_space_count = count + no_similar_count;
return res; return res;
} }
if(count==0) if (count==0)
{ {
if(no_similar_count==0) if (no_similar_count==0)
return EQUIP_ERR_OK; return EQUIP_ERR_OK;
if(no_space_count) if (no_space_count)
*no_space_count = count + no_similar_count; *no_space_count = count + no_similar_count;
return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS;
} }
} }
else if(pProto->BagFamily & BAG_FAMILY_MASK_CURRENCY_TOKENS) 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); 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) if (no_space_count)
*no_space_count = count + no_similar_count; *no_space_count = count + no_similar_count;
return res; return res;
} }
if(count==0) if (count==0)
{ {
if(no_similar_count==0) if (no_similar_count==0)
return EQUIP_ERR_OK; return EQUIP_ERR_OK;
if(no_space_count) if (no_space_count)
*no_space_count = count + no_similar_count; *no_space_count = count + no_similar_count;
return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS;
} }
@ -9260,15 +9263,15 @@ uint8 Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, uint3
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)
{ {
res = _CanStoreItem_InBag(i,dest,pProto,count,false,false,pItem,bag,slot); res = _CanStoreItem_InBag(i,dest,pProto,count,false,false,pItem,bag,slot);
if(res!=EQUIP_ERR_OK) if (res!=EQUIP_ERR_OK)
continue; continue;
if(count==0) if (count==0)
{ {
if(no_similar_count==0) if (no_similar_count==0)
return EQUIP_ERR_OK; return EQUIP_ERR_OK;
if(no_space_count) if (no_space_count)
*no_space_count = count + no_similar_count; *no_space_count = count + no_similar_count;
return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS;
} }
@ -9277,19 +9280,19 @@ uint8 Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, uint3
// search free slot // search free slot
res = _CanStoreItem_InInventorySlots(INVENTORY_SLOT_ITEM_START,INVENTORY_SLOT_ITEM_END,dest,pProto,count,false,pItem,bag,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) if (no_space_count)
*no_space_count = count + no_similar_count; *no_space_count = count + no_similar_count;
return res; return res;
} }
if(count==0) if (count==0)
{ {
if(no_similar_count==0) if (no_similar_count==0)
return EQUIP_ERR_OK; return EQUIP_ERR_OK;
if(no_space_count) if (no_space_count)
*no_space_count = count + no_similar_count; *no_space_count = count + no_similar_count;
return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS;
} }
@ -9297,21 +9300,21 @@ uint8 Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, uint3
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)
{ {
res = _CanStoreItem_InBag(i,dest,pProto,count,false,true,pItem,bag,slot); res = _CanStoreItem_InBag(i,dest,pProto,count,false,true,pItem,bag,slot);
if(res!=EQUIP_ERR_OK) if (res!=EQUIP_ERR_OK)
continue; continue;
if(count==0) if (count==0)
{ {
if(no_similar_count==0) if (no_similar_count==0)
return EQUIP_ERR_OK; return EQUIP_ERR_OK;
if(no_space_count) if (no_space_count)
*no_space_count = count + no_similar_count; *no_space_count = count + no_similar_count;
return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS;
} }
} }
if(no_space_count) if (no_space_count)
*no_space_count = count + no_similar_count; *no_space_count = count + no_similar_count;
return EQUIP_ERR_INVENTORY_FULL; return EQUIP_ERR_INVENTORY_FULL;

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "8091" #define REVISION_NR "8092"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__