From 1abe4c0d79df6da3e8f7a4cee8022939e776a14f Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Wed, 27 May 2009 10:53:02 +0400 Subject: [PATCH] [7900] Now really allow recieve account bounded items by mail reciver. --- src/game/Item.cpp | 26 ++++++++++++++++++++++++++ src/game/Item.h | 2 +- src/game/Player.cpp | 10 +++++----- src/shared/revision_nr.h | 2 +- 4 files changed, 33 insertions(+), 7 deletions(-) diff --git a/src/game/Item.cpp b/src/game/Item.cpp index d508b6dbd..5d595e323 100644 --- a/src/game/Item.cpp +++ b/src/game/Item.cpp @@ -942,3 +942,29 @@ Item* Item::CloneItem( uint32 count, Player const* player ) const newItem->SetItemRandomProperties(GetItemRandomPropertyId()); return newItem; } + +bool Item::IsBindedNotWith( Player const* player ) const +{ + // not binded item + if(!IsSoulBound()) + return false; + + // own item + if(GetOwnerGUID()== player->GetGUID()) + return false; + + // not BOA item case + if(!IsBoundAccountWide()) + return true; + + // online + if(Player* owner = objmgr.GetPlayer(GetOwnerGUID())) + { + return owner->GetSession()->GetAccountId() != player->GetSession()->GetAccountId(); + } + // offline slow case + else + { + return objmgr.GetPlayerAccountIdByGUID(GetOwnerGUID()) != player->GetSession()->GetAccountId(); + } +} \ No newline at end of file diff --git a/src/game/Item.h b/src/game/Item.h index 03209ec51..b13fcf568 100644 --- a/src/game/Item.h +++ b/src/game/Item.h @@ -216,7 +216,7 @@ class MANGOS_DLL_SPEC Item : public Object void SetBinding(bool val) { ApplyModFlag(ITEM_FIELD_FLAGS,ITEM_FLAGS_BINDED,val); } bool IsSoulBound() const { return HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_BINDED); } bool IsBoundAccountWide() const { return HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_BOA); } - bool IsBindedNotWith(uint64 guid) const { return IsSoulBound() && GetOwnerGUID()!= guid; } + bool IsBindedNotWith(Player const* player) const; bool IsBoundByEnchant() const; virtual void SaveToDB(); virtual bool LoadFromDB(uint32 guid, uint64 owner_guid, QueryResult *result = NULL); diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 81cd7ee3e..88725e0be 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -8892,7 +8892,7 @@ uint8 Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, uint3 return swap ? EQUIP_ERR_ITEMS_CANT_BE_SWAPPED :EQUIP_ERR_ITEM_NOT_FOUND; } - if(pItem && pItem->IsBindedNotWith(GetGUID())) + if(pItem && pItem->IsBindedNotWith(this)) { if(no_space_count) *no_space_count = count; @@ -9375,7 +9375,7 @@ uint8 Player::CanStoreItems( Item **pItems,int count) const return EQUIP_ERR_ITEM_NOT_FOUND; // item it 'bind' - if(pItem->IsBindedNotWith(GetGUID())) + if(pItem->IsBindedNotWith(this)) return EQUIP_ERR_DONT_OWN_THAT_ITEM; Bag *pBag; @@ -9577,7 +9577,7 @@ uint8 Player::CanEquipItem( uint8 slot, uint16 &dest, Item *pItem, bool swap, bo ItemPrototype const *pProto = pItem->GetProto(); if( pProto ) { - if(pItem->IsBindedNotWith(GetGUID())) + if(pItem->IsBindedNotWith(this)) return EQUIP_ERR_DONT_OWN_THAT_ITEM; // check count of items (skip for auto move for same player from bank) @@ -9750,7 +9750,7 @@ uint8 Player::CanBankItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, Item *p if (!pProto) return swap ? EQUIP_ERR_ITEMS_CANT_BE_SWAPPED : EQUIP_ERR_ITEM_NOT_FOUND; - if (pItem->IsBindedNotWith(GetGUID())) + if (pItem->IsBindedNotWith(this)) return EQUIP_ERR_DONT_OWN_THAT_ITEM; // check count of items (skip for auto move for same player from bank) @@ -9930,7 +9930,7 @@ uint8 Player::CanUseItem( Item *pItem, bool not_loading ) const ItemPrototype const *pProto = pItem->GetProto(); if (pProto) { - if (pItem->IsBindedNotWith(GetGUID())) + if (pItem->IsBindedNotWith(this)) return EQUIP_ERR_DONT_OWN_THAT_ITEM; if ((pProto->AllowableClass & getClassMask()) == 0 || (pProto->AllowableRace & getRaceMask()) == 0) diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 87fee4bd4..b38946ae9 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "7899" + #define REVISION_NR "7900" #endif // __REVISION_NR_H__