Fix enchant items in trade window.

Original patch by Kierkegaard
closes issue #985

--HG--
branch : trunk
This commit is contained in:
Spp
2010-03-09 21:11:54 +01:00
parent 6c725aa530
commit 9df357f5d9
2 changed files with 13 additions and 9 deletions
+6
View File
@@ -1244,6 +1244,12 @@ class Player : public Unit, public GridObject<Player>
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);
+7 -9
View File
@@ -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();
}
}