Core/Items: Fixed a possible crash with soulbound tradable items
Closes #15700 (cherry picked from commit 094f505e404b5a4e4846657031f89ac44626a1f8)
This commit is contained in:
1 parent
7773984f94
commit
cc685ac334
2 files changed
+9
-20
No files matched your search
@@ -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();
|
||||
|
||||
Reference in new issue
Block a user