Skip to content
Permalink
Browse files
Core/Items: Fixed a possible crash with soulbound tradable items
Closes #15700

(cherry picked from commit 094f505)
  • Loading branch information
Shauren committed Dec 8, 2015
1 parent 7773984 commit cc685ac334335d9f6a25a7c1c739a905f919328f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 20 deletions.
@@ -13230,36 +13230,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)
@@ -2392,7 +2392,7 @@ class Player : public Unit, public GridObject<Player>

EnchantDurationList m_enchantDuration;
ItemDurationList m_itemDuration;
ItemDurationList m_itemSoulboundTradeable;
GuidUnorderedSet m_itemSoulboundTradeable;

void ResetTimeSync();
void SendTimeSync();

0 comments on commit cc685ac

Please sign in to comment.