- diff --git a/src/game/Player.cpp b/src/game/Player.cpp
- index a73de9b..dcc71a3 100644
- --- a/src/game/Player.cpp
- +++ b/src/game/Player.cpp
- @@ -11177,7 +11177,7 @@ Item* Player::_StoreItem( uint16 pos, Item *pItem, uint32 count, bool clone, boo
- else if (Bag *pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, bag ))
- {
- pBag->StoreItem( slot, pItem, update );
- - if( IsInWorld() && update )
- + if (IsInWorld() && update)
- {
- pItem->AddToWorld();
- pItem->SendCreateUpdateToPlayer( this );
- @@ -11293,7 +11293,7 @@ Item* Player::EquipItem( uint16 pos, Item *pItem, bool update )
- }
- }
- - if( IsInWorld() && update )
- + if (IsInWorld() && update)
- {
- pItem->AddToWorld();
- pItem->SendCreateUpdateToPlayer( this );
- @@ -11315,12 +11315,12 @@ Item* Player::EquipItem( uint16 pos, Item *pItem, bool update )
- else
- {
- pItem2->SetCount( pItem2->GetCount() + pItem->GetCount() );
- - if( IsInWorld() && update )
- + if (IsInWorld() && update)
- pItem2->SendCreateUpdateToPlayer( this );
- // delete item (it not in any slot currently)
- //pItem->DeleteFromDB();
- - if( IsInWorld() && update )
- + if (IsInWorld() && update)
- {
- pItem->RemoveFromWorld();
- pItem->DestroyForPlayer( this );
- @@ -11618,7 +11618,7 @@ void Player::DestroyItem( uint8 bag, uint8 slot, bool update )
- else if(Bag *pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, bag ))
- pBag->RemoveItem(slot, update);
- - if( IsInWorld() && update )
- + if (IsInWorld() && update)
- {
- pItem->RemoveFromWorld();
- pItem->DestroyForPlayer(this);
- @@ -11631,15 +11631,15 @@ void Player::DestroyItem( uint8 bag, uint8 slot, bool update )
- }
- }
- -void Player::DestroyItemCount( uint32 item, uint32 count, bool update, bool unequip_check)
- +void Player::DestroyItemCount(uint32 item, uint32 count, bool update, bool unequip_check, bool inBankAlso)
- {
- - DEBUG_LOG( "STORAGE: DestroyItemCount item = %u, count = %u", item, count);
- + DEBUG_LOG("STORAGE: DestroyItemCount item = %u, count = %u", item, count);
- uint32 remcount = 0;
- // in inventory
- - for(int i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; ++i)
- + for (int i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; ++i)
- {
- - if (Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ))
- + if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i))
- {
- if (pItem->GetEntry() == item && !pItem->IsInTrade())
- {
- @@ -11647,17 +11647,17 @@ void Player::DestroyItemCount( uint32 item, uint32 count, bool update, bool uneq
- {
- // all items in inventory can unequipped
- remcount += pItem->GetCount();
- - DestroyItem( INVENTORY_SLOT_BAG_0, i, update);
- + DestroyItem(INVENTORY_SLOT_BAG_0, i, update);
- if (remcount >= count)
- return;
- }
- else
- {
- - ItemRemovedQuestCheck( pItem->GetEntry(), count - remcount );
- - pItem->SetCount( pItem->GetCount() - count + remcount );
- - if (IsInWorld() & update)
- - pItem->SendCreateUpdateToPlayer( this );
- + ItemRemovedQuestCheck(pItem->GetEntry(), count - remcount);
- + pItem->SetCount(pItem->GetCount() - count + remcount);
- + if (IsInWorld() && update)
- + pItem->SendCreateUpdateToPlayer(this);
- pItem->SetState(ITEM_CHANGED, this);
- return;
- }
- @@ -11665,9 +11665,9 @@ void Player::DestroyItemCount( uint32 item, uint32 count, bool update, bool uneq
- }
- }
- - for(int i = KEYRING_SLOT_START; i < CURRENCYTOKEN_SLOT_END; ++i)
- + for (int i = KEYRING_SLOT_START; i < CURRENCYTOKEN_SLOT_END; ++i)
- {
- - if (Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ))
- + if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i))
- {
- if (pItem->GetEntry() == item && !pItem->IsInTrade())
- {
- @@ -11675,17 +11675,17 @@ void Player::DestroyItemCount( uint32 item, uint32 count, bool update, bool uneq
- {
- // all keys can be unequipped
- remcount += pItem->GetCount();
- - DestroyItem( INVENTORY_SLOT_BAG_0, i, update);
- + DestroyItem(INVENTORY_SLOT_BAG_0, i, update);
- if (remcount >= count)
- return;
- }
- else
- {
- - ItemRemovedQuestCheck( pItem->GetEntry(), count - remcount );
- - pItem->SetCount( pItem->GetCount() - count + remcount );
- - if (IsInWorld() & update)
- - pItem->SendCreateUpdateToPlayer( this );
- + ItemRemovedQuestCheck(pItem->GetEntry(), count - remcount);
- + pItem->SetCount(pItem->GetCount() - count + remcount);
- + if (IsInWorld() && update)
- + pItem->SendCreateUpdateToPlayer(this);
- pItem->SetState(ITEM_CHANGED, this);
- return;
- }
- @@ -11694,13 +11694,13 @@ void Player::DestroyItemCount( uint32 item, uint32 count, bool update, bool uneq
- }
- // in inventory bags
- - for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i)
- + for (int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i)
- {
- - if(Bag *pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ))
- + if (Bag *pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, i))
- {
- - for(uint32 j = 0; j < pBag->GetBagSize(); ++j)
- + for (uint32 j = 0; j < pBag->GetBagSize(); ++j)
- {
- - if(Item* pItem = pBag->GetItemByPos(j))
- + if (Item* pItem = pBag->GetItemByPos(j))
- {
- if (pItem->GetEntry() == item && !pItem->IsInTrade())
- {
- @@ -11708,17 +11708,17 @@ void Player::DestroyItemCount( uint32 item, uint32 count, bool update, bool uneq
- if (pItem->GetCount() + remcount <= count)
- {
- remcount += pItem->GetCount();
- - DestroyItem( i, j, update );
- + DestroyItem(i, j, update);
- if (remcount >= count)
- return;
- }
- else
- {
- - ItemRemovedQuestCheck( pItem->GetEntry(), count - remcount );
- - pItem->SetCount( pItem->GetCount() - count + remcount );
- + ItemRemovedQuestCheck(pItem->GetEntry(), count - remcount);
- + pItem->SetCount(pItem->GetCount() - count + remcount);
- if (IsInWorld() && update)
- - pItem->SendCreateUpdateToPlayer( this );
- + pItem->SendCreateUpdateToPlayer(this);
- pItem->SetState(ITEM_CHANGED, this);
- return;
- }
- @@ -11729,18 +11729,18 @@ void Player::DestroyItemCount( uint32 item, uint32 count, bool update, bool uneq
- }
- // in equipment and bag list
- - for(int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_BAG_END; ++i)
- + for (int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_BAG_END; ++i)
- {
- - if (Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ))
- + if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i))
- {
- if (pItem && pItem->GetEntry() == item && !pItem->IsInTrade())
- {
- if (pItem->GetCount() + remcount <= count)
- {
- - if (!unequip_check || CanUnequipItem(INVENTORY_SLOT_BAG_0 << 8 | i, false) == EQUIP_ERR_OK )
- + if (!unequip_check || CanUnequipItem(INVENTORY_SLOT_BAG_0 << 8 | i, false) == EQUIP_ERR_OK)
- {
- remcount += pItem->GetCount();
- - DestroyItem( INVENTORY_SLOT_BAG_0, i, update);
- + DestroyItem(INVENTORY_SLOT_BAG_0, i, update);
- if (remcount >= count)
- return;
- @@ -11748,16 +11748,80 @@ void Player::DestroyItemCount( uint32 item, uint32 count, bool update, bool uneq
- }
- else
- {
- - ItemRemovedQuestCheck( pItem->GetEntry(), count - remcount );
- - pItem->SetCount( pItem->GetCount() - count + remcount );
- - if (IsInWorld() & update)
- - pItem->SendCreateUpdateToPlayer( this );
- + ItemRemovedQuestCheck(pItem->GetEntry(), count - remcount);
- + pItem->SetCount(pItem->GetCount() - count + remcount);
- + if (IsInWorld() && update)
- + pItem->SendCreateUpdateToPlayer(this);
- pItem->SetState(ITEM_CHANGED, this);
- return;
- }
- }
- }
- }
- +
- + if (inBankAlso)
- + {
- + // in bank
- + for (int i = BANK_SLOT_ITEM_START; i < BANK_SLOT_ITEM_END; ++i)
- + {
- + if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i))
- + {
- + if (pItem->GetEntry() == item && !pItem->IsInTrade())
- + {
- + if (pItem->GetCount() + remcount <= count)
- + {
- + remcount += pItem->GetCount();
- + DestroyItem(INVENTORY_SLOT_BAG_0, i, update);
- +
- + if (remcount >= count)
- + return;
- + }
- + else
- + {
- + ItemRemovedQuestCheck(pItem->GetEntry(), count - remcount);
- + pItem->SetCount(pItem->GetCount() - count + remcount);
- + if (IsInWorld() && update)
- + pItem->SendCreateUpdateToPlayer(this);
- + pItem->SetState(ITEM_CHANGED, this);
- + return;
- + }
- + }
- + }
- + }
- +
- + for (int i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; ++i)
- + {
- + if (Bag *pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, i))
- + {
- + for (uint32 j = 0; j < pBag->GetBagSize(); ++j)
- + {
- + if (Item* pItem = pBag->GetItemByPos(j))
- + {
- + if (pItem->GetEntry() == item && !pItem->IsInTrade())
- + {
- + if (pItem->GetCount() + remcount <= count)
- + {
- + remcount += pItem->GetCount();
- + DestroyItem(i, j, update);
- +
- + if (remcount >= count)
- + return;
- + }
- + else
- + {
- + ItemRemovedQuestCheck(pItem->GetEntry(), count - remcount);
- + pItem->SetCount(pItem->GetCount() - count + remcount);
- + if (IsInWorld() && update)
- + pItem->SendCreateUpdateToPlayer(this);
- + pItem->SetState(ITEM_CHANGED, this);
- + return;
- + }
- + }
- + }
- + }
- + }
- + }
- + }
- }
- void Player::DestroyZoneLimitedItem( bool update, uint32 new_zone )
- @@ -11835,7 +11899,7 @@ void Player::DestroyItemCount( Item* pItem, uint32 &count, bool update )
- ItemRemovedQuestCheck( pItem->GetEntry(), count);
- pItem->SetCount( pItem->GetCount() - count );
- count = 0;
- - if( IsInWorld() & update )
- + if (IsInWorld() && update)
- pItem->SendCreateUpdateToPlayer( this );
- pItem->SetState(ITEM_CHANGED, this);
- }
- @@ -13958,12 +14022,22 @@ void Player::RewardQuest(Quest const *pQuest, uint32 reward, Object* questGiver,
- {
- uint32 quest_id = pQuest->GetQuestId();
- - for (int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i )
- + for (int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i)
- {
- if (pQuest->ReqItemId[i])
- DestroyItemCount(pQuest->ReqItemId[i], pQuest->ReqItemCount[i], true);
- }
- + for (int i = 0; i < QUEST_SOURCE_ITEM_IDS_COUNT; ++i)
- + {
- + if (pQuest->ReqSourceId[i])
- + {
- + ItemPrototype const* iProto = ObjectMgr::GetItemPrototype(pQuest->ReqSourceId[i]);
- + if (iProto && iProto->Bonding == BIND_QUEST_ITEM)
- + DestroyItemCount(pQuest->ReqSourceId[i], pQuest->ReqSourceCount[i], true, false, true);
- + }
- + }
- +
- RemoveTimedQuest(quest_id);
- if (BattleGround* bg = GetBattleGround())
- @@ -23200,4 +23274,4 @@ void Player::_fillGearScoreData(Item* item, GearScoreVec* gearScore, uint32& two
- default:
- break;
- }
- -}
- +}
- \ No newline at end of file
- diff --git a/src/game/Player.h b/src/game/Player.h
- index 5b2e8ec..8fa5fb4 100644
- --- a/src/game/Player.h
- +++ b/src/game/Player.h
- @@ -1240,7 +1240,7 @@ class MANGOS_DLL_SPEC Player : public Unit
- // in trade, guild bank, mail....
- void RemoveItemDependentAurasAndCasts( Item * pItem );
- void DestroyItem( uint8 bag, uint8 slot, bool update );
- - void DestroyItemCount( uint32 item, uint32 count, bool update, bool unequip_check = false);
- + void DestroyItemCount(uint32 item, uint32 count, bool update, bool unequip_check = false, bool inBankAlso = false);
- void DestroyItemCount( Item* item, uint32& count, bool update );
- void DestroyConjuredItems( bool update );
- void DestroyZoneLimitedItem( bool update, uint32 new_zone );
- @@ -1342,7 +1342,7 @@ class MANGOS_DLL_SPEC Player : public Unit
- void AddQuest( Quest const *pQuest, Object *questGiver );
- void CompleteQuest( uint32 quest_id );
- void IncompleteQuest( uint32 quest_id );
- - void RewardQuest( Quest const *pQuest, uint32 reward, Object* questGiver, bool announce = true );
- + void RewardQuest(Quest const *pQuest, uint32 reward, Object* questGiver, bool announce = true);
- void FailQuest( uint32 quest_id );
- bool SatisfyQuestSkill(Quest const* qInfo, bool msg) const;
- diff --git a/src/game/QuestHandler.cpp b/src/game/QuestHandler.cpp
- index 88536e1..df2fcfa 100644
- --- a/src/game/QuestHandler.cpp
- +++ b/src/game/QuestHandler.cpp
- @@ -320,22 +320,30 @@ void WorldSession::HandleQuestLogRemoveQuest(WorldPacket& recv_data)
- uint8 slot;
- recv_data >> slot;
- - DEBUG_LOG( "WORLD: Received CMSG_QUESTLOG_REMOVE_QUEST slot = %u",slot );
- + DEBUG_LOG("WORLD: Received CMSG_QUESTLOG_REMOVE_QUEST slot = %u",slot);
- - if( slot < MAX_QUEST_LOG_SIZE )
- + if (slot < MAX_QUEST_LOG_SIZE)
- {
- - if(uint32 quest = _player->GetQuestSlotQuestId(slot))
- + if (uint32 quest = _player->GetQuestSlotQuestId(slot))
- {
- - if(!_player->TakeQuestSourceItem( quest, true ))
- + if (!_player->TakeQuestSourceItem(quest, true))
- return; // can't un-equip some items, reject quest cancel
- - if (const Quest *pQuest = sObjectMgr.GetQuestTemplate(quest))
- + const Quest *pQuest = sObjectMgr.GetQuestTemplate(quest);
- + if (pQuest->HasSpecialFlag(QUEST_SPECIAL_FLAG_TIMED))
- + _player->RemoveTimedQuest(quest);
- +
- + for (int i = 0; i < QUEST_SOURCE_ITEM_IDS_COUNT; ++i)
- {
- - if (pQuest->HasSpecialFlag(QUEST_SPECIAL_FLAG_TIMED))
- - _player->RemoveTimedQuest(quest);
- + if (pQuest->ReqSourceId[i])
- + {
- + ItemPrototype const* iProto = ObjectMgr::GetItemPrototype(pQuest->ReqSourceId[i]);
- + if (iProto && iProto->Bonding == BIND_QUEST_ITEM)
- + _player->DestroyItemCount(pQuest->ReqSourceId[i], pQuest->ReqSourceCount[i], true, false, true);
- + }
- }
- - _player->SetQuestStatus( quest, QUEST_STATUS_NONE);
- + _player->SetQuestStatus(quest, QUEST_STATUS_NONE);
- }
- _player->SetQuestSlot(slot, 0);
REMOVE_REQ_SOURCE_ITEM