From 9df357f5d99a8204b866b1148b433734642cf47b Mon Sep 17 00:00:00 2001 From: Spp Date: Tue, 9 Mar 2010 21:11:54 +0100 Subject: Fix enchant items in trade window. Original patch by Kierkegaard closes issue #985 --HG-- branch : trunk --- src/game/Player.h | 6 ++++++ src/game/Spell.cpp | 16 +++++++--------- 2 files changed, 13 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/game/Player.h b/src/game/Player.h index 7b821ac5495..79d75d34821 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -1244,6 +1244,12 @@ class Player : public Unit, public GridObject Player* GetTrader() const { return pTrader; } void ClearTrade(); void TradeCancel(bool sendback); + Item *GetItemByTradeSlot(uint8 slot) const + { + if (slot < TRADE_SLOT_COUNT && tradeItems[slot]) + return GetItemByGuid(tradeItems[slot]); + return NULL; + } void UpdateEnchantTime(uint32 time); void UpdateItemDuration(uint32 time, bool realtimeonly=false); diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index f0c5acc48eb..7f2b0a76017 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -208,18 +208,16 @@ void SpellCastTargets::Update(Unit* caster) NULL; m_itemTarget = NULL; - if(caster->GetTypeId() == TYPEID_PLAYER) + if (caster->GetTypeId() == TYPEID_PLAYER) { if(m_targetMask & TARGET_FLAG_ITEM) m_itemTarget = caster->ToPlayer()->GetItemByGuid(m_itemTargetGUID); - else if(m_targetMask & TARGET_FLAG_TRADE_ITEM) - { - // here it is not guid but slot - Player* pTrader = caster->ToPlayer()->GetTrader(); - if(pTrader && m_itemTargetGUID < TRADE_SLOT_COUNT) - m_itemTarget = pTrader->GetItemByGuid(m_itemTargetGUID); - } - if(m_itemTarget) + else if (m_targetMask & TARGET_FLAG_TRADE_ITEM) + if (m_itemTargetGUID == TRADE_SLOT_NONTRADED) // here it is not guid but slot. Also prevent hacking slots + if (Player* pTrader = caster->ToPlayer()->GetTrader()) + m_itemTarget = pTrader->GetItemByTradeSlot(m_itemTargetGUID); + + if (m_itemTarget) m_itemTargetEntry = m_itemTarget->GetEntry(); } } -- cgit v1.2.3