Core/Items: Fixed a possible crash with soulbound tradable items

Closes #15700

(cherry picked from commit 094f505e404b5a4e4846657031f89ac44626a1f8)
(cherry picked from commit cc685ac334)
This commit is contained in:
Shauren authored and ariel- committed 2016-01-11 01:51:35 -03:00
1 parent 7a5a4cb726
commit 89928cbdf0
2 files changed
+9 -20

No files matched your search

+8 -19
View File
@@ -13365,36 +13365,25 @@ void Player::TradeCancel(bool sendback)
void Player::UpdateSoulboundTradeItems()
{
if (m_itemSoulboundTradeable.empty())
return;
// also checks for garbage data
for (ItemDurationList::iterator itr = m_itemSoulboundTradeable.begin(); itr != m_itemSoulboundTradeable.end();)
for (GuidUnorderedSet::iterator itr = m_itemSoulboundTradeable.begin(); itr != m_itemSoulboundTradeable.end();)
{
ASSERT(*itr);
if ((*itr)->GetOwnerGUID() != GetGUID())
{
m_itemSoulboundTradeable.erase(itr++);
continue;
}
if ((*itr)->CheckSoulboundTradeExpire())
{
m_itemSoulboundTradeable.erase(itr++);
continue;
}
++itr;
Item* item = GetItemByGuid(*itr);
if (!item || item->GetOwnerGUID() != GetGUID() || item->CheckSoulboundTradeExpire())
itr = m_itemSoulboundTradeable.erase(itr);
else
++itr;
}
}
void Player::AddTradeableItem(Item* item)
{
m_itemSoulboundTradeable.push_back(item);
m_itemSoulboundTradeable.insert(item->GetGUID());
}
/// @todo should never allow an item to be added to m_itemSoulboundTradeable twice
void Player::RemoveTradeableItem(Item* item)
{
m_itemSoulboundTradeable.remove(item);
m_itemSoulboundTradeable.erase(item->GetGUID());
}
void Player::UpdateItemDuration(uint32 time, bool realtimeonly)
+1 -1
View File
@@ -2728,7 +2728,7 @@ class Player : public Unit, public GridObject<Player>
EnchantDurationList m_enchantDuration;
ItemDurationList m_itemDuration;
ItemDurationList m_itemSoulboundTradeable;
GuidUnorderedSet m_itemSoulboundTradeable;
void ResetTimeSync();
void SendTimeSync();