Core/Items: Blizzlike fix for the recent trade exploit fix

This commit is contained in:
Machiavelli
2012-01-18 18:57:21 +01:00
parent abd94e324b
commit 46dda033c8
2 changed files with 9 additions and 14 deletions

View File

@@ -12814,6 +12814,14 @@ void Player::SplitItem(uint16 src, uint16 dst, uint32 count)
return;
}
//! If trading
if (TradeData* tradeData = GetTradeData())
{
//! If current item is in trade window (only possible with packet spoofing - silent return)
if (GetTradeData()->GetTradeSlotForItem(pSrcItem->GetGUID()) != TRADE_SLOT_INVALID)
return;
}
sLog->outDebug(LOG_FILTER_PLAYER_ITEMS, "STORAGE: SplitItem bag = %u, slot = %u, item = %u, count = %u", dstbag, dstslot, pSrcItem->GetEntry(), count);
Item* pNewItem = pSrcItem->CloneItem(count, this);
if (!pNewItem)
@@ -12883,19 +12891,6 @@ void Player::SplitItem(uint16 src, uint16 dst, uint32 count)
EquipItem(dest, pNewItem, true);
AutoUnequipOffhandIfNeed();
}
//! Make sure that code below only is executed when trading
if (!GetTradeData())
return;
//! Update item count in trade window, prevent spoofing
//! Since pSrcItem has its count updated (see above), Item::GetCount() will return the new count
//! in the underlying packet builder function
//! Note that this is not blizzlike, the item should be greyed out when in trade.
//! TODO: Figure out which packet(s) are responsible for that.
TradeSlots const slot = GetTradeData() ? GetTradeData()->GetTradeSlotForItem(pSrcItem->GetGUID()) : TRADE_SLOT_INVALID;
if (slot != TRADE_SLOT_INVALID)
GetTradeData()->SetItem(slot, pSrcItem, true);
}
void Player::SwapItem(uint16 src, uint16 dst)

View File

@@ -1004,7 +1004,7 @@ class TradeData
Item* GetItem(TradeSlots slot) const;
bool HasItem(uint64 itemGuid) const;
TradeSlots const GetTradeSlotForItem(uint64 itemGuid);
void SetItem(TradeSlots slot, Item* item, bool update = false);
void SetItem(TradeSlots slot, Item* item);
uint32 GetSpell() const { return m_spell; }
void SetSpell(uint32 spell_id, Item* castItem = NULL);