aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShauren <none@none>2010-09-25 14:12:50 +0200
committerShauren <none@none>2010-09-25 14:12:50 +0200
commit24e24020d1ebb7b56e971922f754b68942d9a93e (patch)
tree253e1e127c6b5ffebc55ee589c060646034e866b /src
parenta24b84e6f728ad4c784ae5ed0f7b8dd51657e1c6 (diff)
Core/Players: This should fix crashes related to trading soulbound items
Updates issue #4162. Updates issue #4165. --HG-- branch : trunk extra : rebase_source : eb30f245cb3a24ade6823d2fbb025cc9998870df
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Entities/Player/Player.cpp25
-rw-r--r--src/server/game/Entities/Player/Player.h2
2 files changed, 9 insertions, 18 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 1e2cdd86295..98193cdd998 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -11597,7 +11597,7 @@ Item* Player::_StoreItem(uint16 pos, Item *pItem, uint32 count, bool clone, bool
pItem->SetOwnerGUID(GetGUID()); // prevent error at next SetState in case trade/mail/buy from vendor
pItem->SetNotRefundable(this);
pItem->SetSoulboundTradeable(NULL, this, false);
- RemoveTradeableItem(pItem->GetGUIDLow());
+ RemoveTradeableItem(pItem);
pItem->SetState(ITEM_REMOVED, this);
}
@@ -11716,7 +11716,7 @@ Item* Player::EquipItem(uint16 pos, Item *pItem, bool update)
pItem->SetOwnerGUID(GetGUID()); // prevent error at next SetState in case trade/mail/buy from vendor
pItem->SetNotRefundable(this);
pItem->SetSoulboundTradeable(NULL, this, false);
- RemoveTradeableItem(pItem->GetGUIDLow());
+ RemoveTradeableItem(pItem);
pItem->SetState(ITEM_REMOVED, this);
pItem2->SetState(ITEM_CHANGED, this);
@@ -11806,6 +11806,7 @@ void Player::RemoveItem(uint8 bag, uint8 slot, bool update)
RemoveEnchantmentDurations(pItem);
RemoveItemDurations(pItem);
+ RemoveTradeableItem(pItem);
if (bag == INVENTORY_SLOT_BAG_0)
{
@@ -11888,15 +11889,6 @@ void Player::MoveItemFromInventory(uint8 bag, uint8 slot, bool update)
it->RemoveFromWorld();
it->DestroyForPlayer(this);
}
- for (ItemDurationList::iterator itr = m_itemSoulboundTradeable.begin(); itr != m_itemSoulboundTradeable.end();)
- {
- if ((*itr)->GetGUID() == it->GetGUID())
- {
- m_itemSoulboundTradeable.erase(itr++);
- break;
- }
- ++itr;
- }
}
}
@@ -11948,7 +11940,7 @@ void Player::DestroyItem(uint8 bag, uint8 slot, bool update)
pItem->SetNotRefundable(this);
pItem->SetSoulboundTradeable(NULL, this, false);
- RemoveTradeableItem(pItem->GetGUIDLow());
+ RemoveTradeableItem(pItem);
ItemRemovedQuestCheck(pItem->GetEntry(), pItem->GetCount());
@@ -12915,16 +12907,15 @@ void Player::UpdateSoulboundTradeItems()
}
}
-void Player::RemoveTradeableItem(uint32 lowGuid)
+void Player::RemoveTradeableItem(Item* item)
{
- for (ItemDurationList::iterator itr = m_itemSoulboundTradeable.begin(); itr != m_itemSoulboundTradeable.end();)
+ for (ItemDurationList::iterator itr = m_itemSoulboundTradeable.begin(); itr != m_itemSoulboundTradeable.end(); ++itr)
{
- if ((*itr)->GetGUIDLow() == lowGuid)
+ if ((*itr) == item)
{
- m_itemSoulboundTradeable.erase(itr++);
+ m_itemSoulboundTradeable.erase(itr);
break;
}
- ++itr;
}
}
diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h
index c6b9bb4b479..9baeae3f16c 100644
--- a/src/server/game/Entities/Player/Player.h
+++ b/src/server/game/Entities/Player/Player.h
@@ -1262,7 +1262,7 @@ class Player : public Unit, public GridObject<Player>
void UpdateEnchantTime(uint32 time);
void UpdateSoulboundTradeItems();
- void RemoveTradeableItem(uint32 guid);
+ void RemoveTradeableItem(Item* item);
void UpdateItemDuration(uint32 time, bool realtimeonly = false);
void AddEnchantmentDurations(Item *item);
void RemoveEnchantmentDurations(Item *item);