Use enum InventoryResult as return type for few functions.

This commit is contained in:
TOM_RUS 2011-04-24 02:47:29 +04:00
parent 23a861e4a6
commit 730a907252
18 changed files with 184 additions and 185 deletions

View file

@ -202,6 +202,11 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
recv_data >> race_;
recv_data >> class_;
// extract other data required for player creating
uint8 gender, skin, face, hairStyle, hairColor, facialHair, outfitId;
recv_data >> gender >> skin >> face;
recv_data >> hairStyle >> hairColor >> facialHair >> outfitId;
WorldPacket data(SMSG_CHAR_CREATE, 1); // returned with diff.values in all cases
if(GetSecurity() == SEC_PLAYER)
@ -442,11 +447,6 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
return;
}
// extract other data required for player creating
uint8 gender, skin, face, hairStyle, hairColor, facialHair, outfitId;
recv_data >> gender >> skin >> face;
recv_data >> hairStyle >> hairColor >> facialHair >> outfitId;
Player *pNewChar = new Player(this);
if (!pNewChar->Create(sObjectMgr.GeneratePlayerLowGuid(), name, race_, class_, gender, skin, face, hairStyle, hairColor, facialHair, outfitId))
{
@ -1292,7 +1292,7 @@ void WorldSession::HandleEquipmentSetUseOpcode(WorldPacket &recv_data)
continue;
ItemPosCountVec sDest;
uint8 msg = _player->CanStoreItem( NULL_BAG, NULL_SLOT, sDest, uItem, false );
InventoryResult msg = _player->CanStoreItem( NULL_BAG, NULL_SLOT, sDest, uItem, false );
if(msg == EQUIP_ERR_OK)
{
_player->RemoveItem(INVENTORY_SLOT_BAG_0, i, true);

View file

@ -843,7 +843,7 @@ void Group::CountTheRoll(Rolls::iterator& rollI)
ItemPosCountVec dest;
LootItem *item = &(roll->getLoot()->items[roll->itemSlot]);
uint8 msg = player->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, roll->itemid, item->count );
InventoryResult msg = player->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, roll->itemid, item->count );
if ( msg == EQUIP_ERR_OK )
{
item->is_looted = true;
@ -898,7 +898,7 @@ void Group::CountTheRoll(Rolls::iterator& rollI)
if(rollvote == ROLL_GREED)
{
ItemPosCountVec dest;
uint8 msg = player->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, roll->itemid, item->count );
InventoryResult msg = player->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, roll->itemid, item->count );
if ( msg == EQUIP_ERR_OK )
{
item->is_looted = true;

View file

@ -1737,7 +1737,7 @@ void Guild::RemoveItem(uint8 tab, uint8 slot )
GetId(), uint32(tab), uint32(slot));
}
uint8 Guild::_CanStoreItem_InSpecificSlot( uint8 tab, uint8 slot, GuildItemPosCountVec &dest, uint32& count, bool swap, Item* pSrcItem ) const
InventoryResult Guild::_CanStoreItem_InSpecificSlot( uint8 tab, uint8 slot, GuildItemPosCountVec &dest, uint32& count, bool swap, Item* pSrcItem ) const
{
Item* pItem2 = m_TabListMap[tab]->Slots[slot];
@ -1780,7 +1780,7 @@ uint8 Guild::_CanStoreItem_InSpecificSlot( uint8 tab, uint8 slot, GuildItemPosCo
return EQUIP_ERR_OK;
}
uint8 Guild::_CanStoreItem_InTab( uint8 tab, GuildItemPosCountVec &dest, uint32& count, bool merge, Item* pSrcItem, uint8 skip_slot ) const
InventoryResult Guild::_CanStoreItem_InTab( uint8 tab, GuildItemPosCountVec &dest, uint32& count, bool merge, Item* pSrcItem, uint8 skip_slot ) const
{
for (uint32 j = 0; j < GUILD_BANK_MAX_SLOTS; ++j)
{
@ -1837,7 +1837,7 @@ uint8 Guild::_CanStoreItem_InTab( uint8 tab, GuildItemPosCountVec &dest, uint32&
return EQUIP_ERR_OK;
}
uint8 Guild::CanStoreItem( uint8 tab, uint8 slot, GuildItemPosCountVec &dest, uint32 count, Item *pItem, bool swap ) const
InventoryResult Guild::CanStoreItem( uint8 tab, uint8 slot, GuildItemPosCountVec &dest, uint32 count, Item *pItem, bool swap ) const
{
DEBUG_LOG( "GUILD STORAGE: CanStoreItem tab = %u, slot = %u, item = %u, count = %u", tab, slot, pItem->GetEntry(), count);
@ -1850,7 +1850,7 @@ uint8 Guild::CanStoreItem( uint8 tab, uint8 slot, GuildItemPosCountVec &dest, ui
// in specific slot
if (slot != NULL_SLOT)
{
uint8 res = _CanStoreItem_InSpecificSlot(tab,slot,dest,count,swap,pItem);
InventoryResult res = _CanStoreItem_InSpecificSlot(tab,slot,dest,count,swap,pItem);
if (res != EQUIP_ERR_OK)
return res;
@ -1863,7 +1863,7 @@ uint8 Guild::CanStoreItem( uint8 tab, uint8 slot, GuildItemPosCountVec &dest, ui
// search stack in tab for merge to
if (pItem->GetMaxStackCount() > 1)
{
uint8 res = _CanStoreItem_InTab(tab, dest, count, true, pItem, slot);
InventoryResult res = _CanStoreItem_InTab(tab, dest, count, true, pItem, slot);
if (res != EQUIP_ERR_OK)
return res;
@ -1872,7 +1872,7 @@ uint8 Guild::CanStoreItem( uint8 tab, uint8 slot, GuildItemPosCountVec &dest, ui
}
// search free slot in bag for place to
uint8 res = _CanStoreItem_InTab(tab, dest, count, false, pItem, slot);
InventoryResult res = _CanStoreItem_InTab(tab, dest, count, false, pItem, slot);
if (res != EQUIP_ERR_OK)
return res;
@ -1950,7 +1950,7 @@ void Guild::SwapItems(Player * pl, uint8 BankTab, uint8 BankTabSlot, uint8 BankT
if (SplitedAmount)
{ // Bank -> Bank item split (in empty or non empty slot
GuildItemPosCountVec dest;
uint8 msg = CanStoreItem(BankTabDst, BankTabSlotDst, dest, SplitedAmount, pItemSrc, false);
InventoryResult msg = CanStoreItem(BankTabDst, BankTabSlotDst, dest, SplitedAmount, pItemSrc, false);
if (msg != EQUIP_ERR_OK)
{
pl->SendEquipError( msg, pItemSrc, NULL );
@ -1977,7 +1977,7 @@ void Guild::SwapItems(Player * pl, uint8 BankTab, uint8 BankTabSlot, uint8 BankT
else // non split
{
GuildItemPosCountVec gDest;
uint8 msg = CanStoreItem(BankTabDst,BankTabSlotDst,gDest,pItemSrc->GetCount(), pItemSrc, false);
InventoryResult msg = CanStoreItem(BankTabDst,BankTabSlotDst,gDest,pItemSrc->GetCount(), pItemSrc, false);
if (msg == EQUIP_ERR_OK) // merge to
{
CharacterDatabase.BeginTransaction();
@ -2057,7 +2057,7 @@ void Guild::MoveFromBankToChar( Player * pl, uint8 BankTab, uint8 BankTabSlot, u
}
ItemPosCountVec dest;
uint8 msg = pl->CanStoreItem(PlayerBag, PlayerSlot, dest, pNewItem, false);
InventoryResult msg = pl->CanStoreItem(PlayerBag, PlayerSlot, dest, pNewItem, false);
if (msg != EQUIP_ERR_OK)
{
pl->SendEquipError( msg, pNewItem, NULL );
@ -2088,7 +2088,7 @@ void Guild::MoveFromBankToChar( Player * pl, uint8 BankTab, uint8 BankTabSlot, u
else // Bank -> Char swap with slot (move)
{
ItemPosCountVec dest;
uint8 msg = pl->CanStoreItem(PlayerBag, PlayerSlot, dest, pItemBank, false);
InventoryResult msg = pl->CanStoreItem(PlayerBag, PlayerSlot, dest, pItemBank, false);
if (msg == EQUIP_ERR_OK) // merge case
{
// check source pos rights (item moved to inventory)
@ -2208,7 +2208,7 @@ void Guild::MoveFromCharToBank( Player * pl, uint8 PlayerBag, uint8 PlayerSlot,
if (SplitedAmount)
{ // Char -> Bank split to empty or non-empty slot (partly move)
GuildItemPosCountVec dest;
uint8 msg = CanStoreItem(BankTab, BankTabSlot, dest, SplitedAmount, pItemChar, false);
InventoryResult msg = CanStoreItem(BankTab, BankTabSlot, dest, SplitedAmount, pItemChar, false);
if (msg != EQUIP_ERR_OK)
{
pl->SendEquipError( msg, pItemChar, NULL );
@ -2245,7 +2245,7 @@ void Guild::MoveFromCharToBank( Player * pl, uint8 PlayerBag, uint8 PlayerSlot,
else // Char -> Bank swap with empty or non-empty (move)
{
GuildItemPosCountVec dest;
uint8 msg = CanStoreItem(BankTab, BankTabSlot, dest, pItemChar->GetCount(), pItemChar, false);
InventoryResult msg = CanStoreItem(BankTab, BankTabSlot, dest, pItemChar->GetCount(), pItemChar, false);
if (msg == EQUIP_ERR_OK) // merge
{
// logging item move to bank

View file

@ -485,7 +485,7 @@ class Guild
// used only from high level Swap/Move functions
Item* GetItem(uint8 TabId, uint8 SlotId);
uint8 CanStoreItem( uint8 tab, uint8 slot, GuildItemPosCountVec& dest, uint32 count, Item *pItem, bool swap = false) const;
InventoryResult CanStoreItem( uint8 tab, uint8 slot, GuildItemPosCountVec& dest, uint32 count, Item *pItem, bool swap = false) const;
Item* StoreItem( uint8 tab, GuildItemPosCountVec const& pos, Item *pItem );
void RemoveItem(uint8 tab, uint8 slot );
void DisplayGuildBankContentUpdate(uint8 TabId, int32 slot1, int32 slot2 = -1);
@ -493,8 +493,8 @@ class Guild
// internal common parts for CanStore/StoreItem functions
void AppendDisplayGuildBankSlot( WorldPacket& data, GuildBankTab const *tab, int32 slot );
uint8 _CanStoreItem_InSpecificSlot( uint8 tab, uint8 slot, GuildItemPosCountVec& dest, uint32& count, bool swap, Item *pSrcItem ) const;
uint8 _CanStoreItem_InTab( uint8 tab, GuildItemPosCountVec& dest, uint32& count, bool merge, Item *pSrcItem, uint8 skip_slot ) const;
InventoryResult _CanStoreItem_InSpecificSlot( uint8 tab, uint8 slot, GuildItemPosCountVec& dest, uint32& count, bool swap, Item *pSrcItem ) const;
InventoryResult _CanStoreItem_InTab( uint8 tab, GuildItemPosCountVec& dest, uint32& count, bool merge, Item *pSrcItem, uint8 skip_slot ) const;
Item* _StoreItem( uint8 tab, uint8 slot, Item *pItem, uint32 count, bool clone );
};
#endif

View file

@ -1166,7 +1166,7 @@ void Item::BuildUpdateData(UpdateDataMapType& update_players)
ClearUpdateMask(false);
}
uint8 Item::CanBeMergedPartlyWith( ItemPrototype const* proto ) const
InventoryResult Item::CanBeMergedPartlyWith( ItemPrototype const* proto ) const
{
// check item type
if (GetEntry() != proto->ItemId)

View file

@ -37,7 +37,7 @@ struct ItemSetEffect
SpellEntry const *spells[8];
};
enum InventoryChangeFailure
enum InventoryResult
{
EQUIP_ERR_OK = 0,
EQUIP_ERR_CANT_EQUIP_LEVEL_I = 1, // ERR_CANT_EQUIP_LEVEL_I
@ -80,7 +80,7 @@ enum InventoryChangeFailure
EQUIP_ERR_YOU_ARE_DEAD = 38, // ERR_PLAYER_DEAD
EQUIP_ERR_CANT_DO_RIGHT_NOW = 39, // ERR_CLIENT_LOCKED_OUT
EQUIP_ERR_INT_BAG_ERROR = 40, // ERR_INTERNAL_BAG_ERROR
EQUIP_ERR_CAN_EQUIP_ONLY1_QUIVER2 = 41, // ERR_ONLY_ONE_BOLT
EQUIP_ERR_CAN_EQUIP_ONLY1_BOLT = 41, // ERR_ONLY_ONE_BOLT
EQUIP_ERR_CAN_EQUIP_ONLY1_AMMOPOUCH = 42, // ERR_ONLY_ONE_AMMO
EQUIP_ERR_STACKABLE_CANT_BE_WRAPPED = 43, // ERR_CANT_WRAP_STACKABLE
EQUIP_ERR_EQUIPPED_CANT_BE_WRAPPED = 44, // ERR_CANT_WRAP_EQUIPPED
@ -131,7 +131,7 @@ enum InventoryChangeFailure
EQUIP_ERR_ITEM_MAX_LIMIT_CATEGORY_EQUIPPED_EXCEEDED_IS = 89
};
enum BuyFailure
enum BuyResult
{
BUY_ERR_CANT_FIND_ITEM = 0,
BUY_ERR_ITEM_ALREADY_SOLD = 1,
@ -144,7 +144,7 @@ enum BuyFailure
BUY_ERR_REPUTATION_REQUIRE = 12
};
enum SellFailure
enum SellResult
{
SELL_ERR_CANT_FIND_ITEM = 1,
SELL_ERR_CANT_SELL_ITEM = 2, // merchant doesn't like that item
@ -313,7 +313,7 @@ class MANGOS_DLL_SPEC Item : public Object
uint32 GetMaxStackCount() const { return GetProto()->GetMaxStackSize(); }
uint8 GetGemCountWithID(uint32 GemID) const;
uint8 GetGemCountWithLimitCategory(uint32 limitCategory) const;
uint8 CanBeMergedPartlyWith(ItemPrototype const* proto) const;
InventoryResult CanBeMergedPartlyWith(ItemPrototype const* proto) const;
uint8 GetSlot() const {return m_slot;}
Bag *GetContainer() { return m_container; }

View file

@ -152,7 +152,7 @@ void WorldSession::HandleAutoEquipItemOpcode( WorldPacket & recv_data )
return; // only at cheat
uint16 dest;
uint8 msg = _player->CanEquipItem( NULL_SLOT, dest, pSrcItem, !pSrcItem->IsBag() );
InventoryResult msg = _player->CanEquipItem( NULL_SLOT, dest, pSrcItem, !pSrcItem->IsBag() );
if( msg != EQUIP_ERR_OK )
{
_player->SendEquipError( msg, pSrcItem, NULL );
@ -246,7 +246,7 @@ void WorldSession::HandleDestroyItemOpcode( WorldPacket & recv_data )
// prevent drop unequipable items (in combat, for example) and non-empty bags
if(_player->IsEquipmentPos(pos) || _player->IsBagPos(pos))
{
uint8 msg = _player->CanUnequipItem( pos, false );
InventoryResult msg = _player->CanUnequipItem( pos, false );
if( msg != EQUIP_ERR_OK )
{
_player->SendEquipError( msg, _player->GetItemByPos(pos), NULL );
@ -454,7 +454,7 @@ void WorldSession::HandleReadItemOpcode( WorldPacket & recv_data )
{
WorldPacket data;
uint8 msg = _player->CanUseItem( pItem );
InventoryResult msg = _player->CanUseItem( pItem );
if( msg == EQUIP_ERR_OK )
{
data.Initialize (SMSG_READ_ITEM_OK, 8);
@ -629,7 +629,7 @@ void WorldSession::HandleBuybackItem(WorldPacket & recv_data)
}
ItemPosCountVec dest;
uint8 msg = _player->CanStoreItem( NULL_BAG, NULL_SLOT, dest, pItem, false );
InventoryResult msg = _player->CanStoreItem( NULL_BAG, NULL_SLOT, dest, pItem, false );
if( msg == EQUIP_ERR_OK )
{
_player->ModifyMoney( -(int32)price );
@ -858,7 +858,7 @@ void WorldSession::HandleAutoStoreBagItemOpcode( WorldPacket & recv_data )
// check unequip potability for equipped items and bank bags
if(_player->IsEquipmentPos ( src ) || _player->IsBagPos ( src ))
{
uint8 msg = _player->CanUnequipItem( src, !_player->IsBagPos ( src ));
InventoryResult msg = _player->CanUnequipItem( src, !_player->IsBagPos ( src ));
if(msg != EQUIP_ERR_OK)
{
_player->SendEquipError( msg, pItem, NULL );
@ -867,7 +867,7 @@ void WorldSession::HandleAutoStoreBagItemOpcode( WorldPacket & recv_data )
}
ItemPosCountVec dest;
uint8 msg = _player->CanStoreItem( dstbag, NULL_SLOT, dest, pItem, false );
InventoryResult msg = _player->CanStoreItem( dstbag, NULL_SLOT, dest, pItem, false );
if( msg != EQUIP_ERR_OK )
{
_player->SendEquipError( msg, pItem, NULL );
@ -971,7 +971,7 @@ void WorldSession::HandleAutoBankItemOpcode(WorldPacket& recvPacket)
return;
ItemPosCountVec dest;
uint8 msg = _player->CanBankItem( NULL_BAG, NULL_SLOT, dest, pItem, false );
InventoryResult msg = _player->CanBankItem( NULL_BAG, NULL_SLOT, dest, pItem, false );
if( msg != EQUIP_ERR_OK )
{
_player->SendEquipError( msg, pItem, NULL );
@ -1005,7 +1005,7 @@ void WorldSession::HandleAutoStoreBankItemOpcode(WorldPacket& recvPacket)
if(_player->IsBankPos(srcbag, srcslot)) // moving from bank to inventory
{
ItemPosCountVec dest;
uint8 msg = _player->CanStoreItem( NULL_BAG, NULL_SLOT, dest, pItem, false );
InventoryResult msg = _player->CanStoreItem( NULL_BAG, NULL_SLOT, dest, pItem, false );
if( msg != EQUIP_ERR_OK )
{
_player->SendEquipError( msg, pItem, NULL );
@ -1018,7 +1018,7 @@ void WorldSession::HandleAutoStoreBankItemOpcode(WorldPacket& recvPacket)
else // moving from inventory to bank
{
ItemPosCountVec dest;
uint8 msg = _player->CanBankItem( NULL_BAG, NULL_SLOT, dest, pItem, false );
InventoryResult msg = _player->CanBankItem( NULL_BAG, NULL_SLOT, dest, pItem, false );
if( msg != EQUIP_ERR_OK )
{
_player->SendEquipError( msg, pItem, NULL );
@ -1378,7 +1378,7 @@ void WorldSession::HandleSocketOpcode(WorldPacket& recv_data)
// for equipped item check all equipment for duplicate equipped gems
if(itemTarget->IsEquipped())
{
if(uint8 res = _player->CanEquipUniqueItem(Gems[i], slot, limit_newcount >= 0 ? limit_newcount : 0))
if(InventoryResult res = _player->CanEquipUniqueItem(Gems[i], slot, limit_newcount >= 0 ? limit_newcount : 0))
{
_player->SendEquipError( res, itemTarget, NULL );
return;

View file

@ -2508,7 +2508,7 @@ bool ChatHandler::HandleAddItemSetCommand(char* args)
{
found = true;
ItemPosCountVec dest;
uint8 msg = plTarget->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, pProto->ItemId, 1 );
InventoryResult msg = plTarget->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, pProto->ItemId, 1 );
if (msg == EQUIP_ERR_OK)
{
Item* item = plTarget->StoreNewItem( dest, pProto->ItemId, true);

View file

@ -128,7 +128,7 @@ void WorldSession::HandleAutostoreLootItemOpcode( WorldPacket & recv_data )
pItem->SetLootState(ITEM_LOOT_CHANGED);
ItemPosCountVec dest;
uint8 msg = player->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, item->itemid, item->count );
InventoryResult msg = player->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, item->itemid, item->count );
if ( msg == EQUIP_ERR_OK )
{
Item * newitem = player->StoreNewItem( dest, item->itemid, true, item->randomPropertyId);
@ -551,7 +551,7 @@ void WorldSession::HandleLootMasterGiveOpcode( WorldPacket & recv_data )
LootItem& item = pLoot->items[slotid];
ItemPosCountVec dest;
uint8 msg = target->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, item.itemid, item.count );
InventoryResult msg = target->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, item.itemid, item.count );
if ( msg != EQUIP_ERR_OK )
{
target->SendEquipError( msg, NULL, NULL, item.itemid );

View file

@ -615,7 +615,7 @@ void WorldSession::HandleGetMailList(WorldPacket & recv_data )
data << uint32((*itr)->stationery); // stationery (Stationery.dbc)
data << uint32((*itr)->money); // copper
data << uint32((*itr)->checked); // flags
data << float(((*itr)->expire_time-time(NULL))/DAY);// Time
data << float(float((*itr)->expire_time - time(NULL)) / float(DAY));// Time
data << uint32((*itr)->mailTemplateId); // mail template (MailTemplate.dbc)
data << (*itr)->subject; // Subject string - once 00, when mail type = 3, max 256
data << (*itr)->body; // message? max 8000

View file

@ -185,10 +185,10 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket & recv_data)
}
ItemPosCountVec dest;
uint8 msg = _player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, charterid, pProto->BuyCount );
InventoryResult msg = _player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, charterid, pProto->BuyCount );
if(msg != EQUIP_ERR_OK)
{
_player->SendBuyError(msg, pCreature, charterid, 0);
_player->SendEquipError(msg, NULL, NULL, charterid);
return;
}

View file

@ -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)

View file

@ -1199,13 +1199,13 @@ class MANGOS_DLL_SPEC Player : public Unit
bool CanNoReagentCast(SpellEntry const* spellInfo) const;
bool HasItemOrGemWithIdEquipped( uint32 item, uint32 count, uint8 except_slot = NULL_SLOT) const;
bool HasItemOrGemWithLimitCategoryEquipped( uint32 limitCategory, uint32 count, uint8 except_slot = NULL_SLOT) const;
uint8 CanTakeMoreSimilarItems(Item* pItem) const { return _CanTakeMoreSimilarItems(pItem->GetEntry(), pItem->GetCount(), pItem); }
uint8 CanTakeMoreSimilarItems(uint32 entry, uint32 count) const { return _CanTakeMoreSimilarItems(entry, count, NULL); }
uint8 CanStoreNewItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 item, uint32 count, uint32* no_space_count = NULL ) const
InventoryResult CanTakeMoreSimilarItems(Item* pItem) const { return _CanTakeMoreSimilarItems(pItem->GetEntry(), pItem->GetCount(), pItem); }
InventoryResult CanTakeMoreSimilarItems(uint32 entry, uint32 count) const { return _CanTakeMoreSimilarItems(entry, count, NULL); }
InventoryResult CanStoreNewItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 item, uint32 count, uint32* no_space_count = NULL ) const
{
return _CanStoreItem(bag, slot, dest, item, count, NULL, false, no_space_count );
}
uint8 CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, Item *pItem, bool swap = false ) const
InventoryResult CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, Item *pItem, bool swap = false ) const
{
if(!pItem)
return EQUIP_ERR_ITEM_NOT_FOUND;
@ -1213,19 +1213,19 @@ class MANGOS_DLL_SPEC Player : public Unit
return _CanStoreItem( bag, slot, dest, pItem->GetEntry(), count, pItem, swap, NULL );
}
uint8 CanStoreItems( Item **pItem,int count) const;
uint8 CanEquipNewItem( uint8 slot, uint16 &dest, uint32 item, bool swap ) const;
uint8 CanEquipItem( uint8 slot, uint16 &dest, Item *pItem, bool swap, bool not_loading = true ) const;
InventoryResult CanStoreItems( Item **pItem,int count) const;
InventoryResult CanEquipNewItem( uint8 slot, uint16 &dest, uint32 item, bool swap ) const;
InventoryResult CanEquipItem( uint8 slot, uint16 &dest, Item *pItem, bool swap, bool not_loading = true ) const;
uint8 CanEquipUniqueItem( Item * pItem, uint8 except_slot = NULL_SLOT, uint32 limit_count = 1 ) const;
uint8 CanEquipUniqueItem( ItemPrototype const* itemProto, uint8 except_slot = NULL_SLOT, uint32 limit_count = 1 ) const;
uint8 CanUnequipItems( uint32 item, uint32 count ) const;
uint8 CanUnequipItem( uint16 src, bool swap ) const;
uint8 CanBankItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, Item *pItem, bool swap, bool not_loading = true ) const;
uint8 CanUseItem( Item *pItem, bool not_loading = true ) const;
InventoryResult CanEquipUniqueItem( Item * pItem, uint8 except_slot = NULL_SLOT, uint32 limit_count = 1 ) const;
InventoryResult CanEquipUniqueItem( ItemPrototype const* itemProto, uint8 except_slot = NULL_SLOT, uint32 limit_count = 1 ) const;
InventoryResult CanUnequipItems( uint32 item, uint32 count ) const;
InventoryResult CanUnequipItem( uint16 src, bool swap ) const;
InventoryResult CanBankItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, Item *pItem, bool swap, bool not_loading = true ) const;
InventoryResult CanUseItem( Item *pItem, bool not_loading = true ) const;
bool HasItemTotemCategory( uint32 TotemCategory ) const;
uint8 CanUseItem( ItemPrototype const *pItem ) const;
uint8 CanUseAmmo( uint32 item ) const;
InventoryResult CanUseItem( ItemPrototype const *pItem ) const;
InventoryResult CanUseAmmo( uint32 item ) const;
Item* StoreNewItem( ItemPosCountVec const& pos, uint32 item, bool update,int32 randomPropertyId = 0 );
Item* StoreItem( ItemPosCountVec const& pos, Item *pItem, bool update );
Item* EquipNewItem( uint16 pos, uint32 item, bool update );
@ -1237,8 +1237,8 @@ class MANGOS_DLL_SPEC Player : public Unit
void AutoStoreLoot(uint32 loot_id, LootStore const& store, bool broadcast = false, uint8 bag = NULL_BAG, uint8 slot = NULL_SLOT);
void AutoStoreLoot(Loot& loot, bool broadcast = false, uint8 bag = NULL_BAG, uint8 slot = NULL_SLOT);
uint8 _CanTakeMoreSimilarItems(uint32 entry, uint32 count, Item* pItem, uint32* no_space_count = NULL) const;
uint8 _CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 entry, uint32 count, Item *pItem = NULL, bool swap = false, uint32* no_space_count = NULL ) const;
InventoryResult _CanTakeMoreSimilarItems(uint32 entry, uint32 count, Item* pItem, uint32* no_space_count = NULL) const;
InventoryResult _CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 entry, uint32 count, Item *pItem = NULL, bool swap = false, uint32* no_space_count = NULL ) const;
void ApplyEquipCooldown( Item * pItem );
void SetAmmo( uint32 item );
@ -1273,9 +1273,9 @@ class MANGOS_DLL_SPEC Player : public Unit
void TakeExtendedCost(uint32 extendedCostId, uint32 count);
uint32 GetMaxKeyringSize() const { return KEYRING_SLOT_END-KEYRING_SLOT_START; }
void SendEquipError( uint8 msg, Item* pItem, Item *pItem2 = NULL, uint32 itemid = 0 ) const;
void SendBuyError( uint8 msg, Creature* pCreature, uint32 item, uint32 param );
void SendSellError( uint8 msg, Creature* pCreature, uint64 guid, uint32 param );
void SendEquipError( InventoryResult msg, Item* pItem, Item *pItem2 = NULL, uint32 itemid = 0 ) const;
void SendBuyError( BuyResult msg, Creature* pCreature, uint32 item, uint32 param );
void SendSellError( SellResult msg, Creature* pCreature, uint64 guid, uint32 param );
void AddWeaponProficiency(uint32 newflag) { m_WeaponProficiency |= newflag; }
void AddArmorProficiency(uint32 newflag) { m_ArmorProficiency |= newflag; }
uint32 GetWeaponProficiency() const { return m_WeaponProficiency; }
@ -1433,7 +1433,7 @@ class MANGOS_DLL_SPEC Player : public Unit
void SendQuestCompleteEvent(uint32 quest_id);
void SendQuestReward( Quest const *pQuest, uint32 XP, Object* questGiver );
void SendQuestFailed( uint32 quest_id, InventoryChangeFailure reason = EQUIP_ERR_OK);
void SendQuestFailed( uint32 quest_id, InventoryResult reason = EQUIP_ERR_OK);
void SendQuestTimerFailed( uint32 quest_id );
void SendCanTakeQuestResponse( uint32 msg ) const;
void SendQuestConfirmAccept(Quest const* pQuest, Player* pReceiver);
@ -2564,9 +2564,9 @@ class MANGOS_DLL_SPEC Player : public Unit
private:
void _HandleDeadlyPoison(Unit* Target, WeaponAttackType attType, SpellEntry const *spellInfo);
// internal common parts for CanStore/StoreItem functions
uint8 _CanStoreItem_InSpecificSlot( uint8 bag, uint8 slot, ItemPosCountVec& dest, ItemPrototype const *pProto, uint32& count, bool swap, Item *pSrcItem ) const;
uint8 _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 _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 _CanStoreItem_InSpecificSlot( uint8 bag, uint8 slot, ItemPosCountVec& dest, ItemPrototype const *pProto, uint32& count, bool swap, Item *pSrcItem ) const;
InventoryResult _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 _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;
Item* _StoreItem( uint16 pos, Item *pItem, uint32 count, bool clone, bool update );
void UpdateKnownCurrencies(uint32 itemId, bool apply);

View file

@ -6240,7 +6240,7 @@ SpellCastResult Spell::CheckItems()
}
ItemPosCountVec dest;
uint8 msg = p_caster->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, m_spellInfo->EffectItemType[i], 1 );
InventoryResult msg = p_caster->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, m_spellInfo->EffectItemType[i], 1 );
if (msg != EQUIP_ERR_OK )
{
p_caster->SendEquipError( msg, NULL, NULL, m_spellInfo->EffectItemType[i] );
@ -6270,7 +6270,7 @@ SpellCastResult Spell::CheckItems()
if (isVellumTarget && m_spellInfo->EffectItemType[i])
{
ItemPosCountVec dest;
uint8 msg = p_caster->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, m_spellInfo->EffectItemType[i], 1 );
InventoryResult msg = p_caster->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, m_spellInfo->EffectItemType[i], 1 );
if (msg != EQUIP_ERR_OK)
{
p_caster->SendEquipError( msg, NULL, NULL );

View file

@ -3685,7 +3685,7 @@ void Aura::HandleChannelDeathItem(bool apply, bool Real)
uint32 count = m_modifier.m_amount;
ItemPosCountVec dest;
uint8 msg = ((Player*)caster)->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, spellInfo->EffectItemType[m_effIndex], count, &noSpaceForCount);
InventoryResult msg = ((Player*)caster)->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, spellInfo->EffectItemType[m_effIndex], count, &noSpaceForCount);
if( msg != EQUIP_ERR_OK )
{
count-=noSpaceForCount;

View file

@ -3913,7 +3913,7 @@ void Spell::DoCreateItem(SpellEffectIndex eff_idx, uint32 itemtype)
// can the player store the new item?
ItemPosCountVec dest;
uint32 no_space = 0;
uint8 msg = player->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, newitemid, num_to_add, &no_space );
InventoryResult msg = player->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, newitemid, num_to_add, &no_space );
if( msg != EQUIP_ERR_OK )
{
// convert to possible store amount

View file

@ -91,7 +91,7 @@ void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket)
return;
}
uint8 msg = pUser->CanUseItem(pItem);
InventoryResult msg = pUser->CanUseItem(pItem);
if (msg != EQUIP_ERR_OK)
{
recvPacket.rpos(recvPacket.wpos()); // prevent spam at not read packet tail

View file

@ -92,7 +92,7 @@ bool ChatHandler::HandleDebugSendEquipErrorCommand(char* args)
return false;
uint8 msg = atoi(args);
m_session->GetPlayer()->SendEquipError(msg, NULL, NULL);
m_session->GetPlayer()->SendEquipError(InventoryResult(msg), NULL, NULL);
return true;
}
@ -102,7 +102,7 @@ bool ChatHandler::HandleDebugSendSellErrorCommand(char* args)
return false;
uint8 msg = atoi(args);
m_session->GetPlayer()->SendSellError(msg, 0, 0, 0);
m_session->GetPlayer()->SendSellError(SellResult(msg), 0, 0, 0);
return true;
}
@ -112,7 +112,7 @@ bool ChatHandler::HandleDebugSendBuyErrorCommand(char* args)
return false;
uint8 msg = atoi(args);
m_session->GetPlayer()->SendBuyError(msg, 0, 0, 0);
m_session->GetPlayer()->SendBuyError(BuyResult(msg), 0, 0, 0);
return true;
}