aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2015-12-08 18:02:10 +0100
committerShauren <shauren.trinity@gmail.com>2015-12-08 18:02:43 +0100
commitcc685ac334335d9f6a25a7c1c739a905f919328f (patch)
tree95e29e6f0aa54f4f2d022afb0a1ab4feb653fac7
parent7773984f94a15f45e0260e6478edf991c77d6e87 (diff)
Core/Items: Fixed a possible crash with soulbound tradable items
Closes #15700 (cherry picked from commit 094f505e404b5a4e4846657031f89ac44626a1f8)
-rw-r--r--src/server/game/Entities/Player/Player.cpp27
-rw-r--r--src/server/game/Entities/Player/Player.h2
2 files changed, 9 insertions, 20 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index aa9cd9fa045..f4761931c42 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -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)
diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h
index 8057a4ee54d..7f72bff5211 100644
--- a/src/server/game/Entities/Player/Player.h
+++ b/src/server/game/Entities/Player/Player.h
@@ -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();