mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 01:37:00 +00:00
[10050] Implement apply non-trade slot item enchanting at trade complete.
Base at original patch provided by arrai. Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
parent
a248a1a32d
commit
64f959fb82
10 changed files with 438 additions and 183 deletions
|
|
@ -302,6 +302,105 @@ bool SpellModifier::isAffectedOnSpell( SpellEntry const *spell ) const
|
|||
return false;
|
||||
}
|
||||
|
||||
//== TradeData =================================================
|
||||
|
||||
TradeData* TradeData::GetTraderData() const
|
||||
{
|
||||
return m_trader->GetTradeData();
|
||||
}
|
||||
|
||||
Item* TradeData::GetItem( TradeSlots slot ) const
|
||||
{
|
||||
return !m_items[slot].IsEmpty() ? m_player->GetItemByGuid(m_items[slot]) : NULL;
|
||||
}
|
||||
|
||||
bool TradeData::HasItem( ObjectGuid item_guid ) const
|
||||
{
|
||||
for(int i = 0; i < TRADE_SLOT_COUNT; ++i)
|
||||
if (m_items[i] == item_guid)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Item* TradeData::GetSpellCastItem() const
|
||||
{
|
||||
return !m_spellCastItem.IsEmpty() ? m_player->GetItemByGuid(m_spellCastItem) : NULL;
|
||||
}
|
||||
|
||||
void TradeData::SetItem( TradeSlots slot, Item* item )
|
||||
{
|
||||
ObjectGuid itemGuid = item ? item->GetObjectGuid() : ObjectGuid();
|
||||
|
||||
if (m_items[slot] == itemGuid)
|
||||
return;
|
||||
|
||||
m_items[slot] = itemGuid;
|
||||
|
||||
SetAccepted(false);
|
||||
GetTraderData()->SetAccepted(false);
|
||||
|
||||
Update();
|
||||
|
||||
// need remove possible trader spell applied to changed item
|
||||
if (slot == TRADE_SLOT_NONTRADED)
|
||||
GetTraderData()->SetSpell(0);
|
||||
|
||||
// need remove possible player spell applied (possible move reagent)
|
||||
SetSpell(0);
|
||||
}
|
||||
|
||||
void TradeData::SetSpell( uint32 spell_id, Item* castItem /*= NULL*/ )
|
||||
{
|
||||
ObjectGuid itemGuid = castItem ? castItem->GetObjectGuid() : ObjectGuid();
|
||||
|
||||
if (m_spell == spell_id && m_spellCastItem == itemGuid)
|
||||
return;
|
||||
|
||||
m_spell = spell_id;
|
||||
m_spellCastItem = itemGuid;
|
||||
|
||||
SetAccepted(false);
|
||||
GetTraderData()->SetAccepted(false);
|
||||
|
||||
Update(true); // send spell info to item owner
|
||||
Update(false); // send spell info to caster self
|
||||
}
|
||||
|
||||
void TradeData::SetMoney( uint32 money )
|
||||
{
|
||||
if (m_money == money)
|
||||
return;
|
||||
|
||||
m_money = money;
|
||||
|
||||
SetAccepted(false);
|
||||
GetTraderData()->SetAccepted(false);
|
||||
|
||||
Update();
|
||||
}
|
||||
|
||||
void TradeData::Update( bool for_trader /*= true*/ )
|
||||
{
|
||||
if (for_trader)
|
||||
m_trader->GetSession()->SendUpdateTrade(true); // player state for trader
|
||||
else
|
||||
m_player->GetSession()->SendUpdateTrade(false); // player state for player
|
||||
}
|
||||
|
||||
void TradeData::SetAccepted(bool state, bool crosssend /*= false*/)
|
||||
{
|
||||
m_accepted = state;
|
||||
|
||||
if (!state)
|
||||
{
|
||||
if (crosssend)
|
||||
m_trader->GetSession()->SendTradeStatus(TRADE_STATUS_BACK_TO_TRADE);
|
||||
else
|
||||
m_player->GetSession()->SendTradeStatus(TRADE_STATUS_BACK_TO_TRADE);
|
||||
}
|
||||
}
|
||||
|
||||
//== Player ====================================================
|
||||
|
||||
UpdateMask Player::updateVisualBits;
|
||||
|
|
@ -9054,34 +9153,34 @@ bool Player::HasItemCount( uint32 item, uint32 count, bool inBankAlso ) const
|
|||
for(int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; ++i)
|
||||
{
|
||||
Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i );
|
||||
if( pItem && pItem->GetEntry() == item )
|
||||
if (pItem && pItem->GetEntry() == item && !pItem->IsInTrade())
|
||||
{
|
||||
tempcount += pItem->GetCount();
|
||||
if( tempcount >= count )
|
||||
if (tempcount >= count)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
for(int i = KEYRING_SLOT_START; i < CURRENCYTOKEN_SLOT_END; ++i)
|
||||
{
|
||||
Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i );
|
||||
if( pItem && pItem->GetEntry() == item )
|
||||
if (pItem && pItem->GetEntry() == item && !pItem->IsInTrade())
|
||||
{
|
||||
tempcount += pItem->GetCount();
|
||||
if( tempcount >= count )
|
||||
if (tempcount >= count)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i)
|
||||
{
|
||||
if(Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ))
|
||||
if (Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ))
|
||||
{
|
||||
for(uint32 j = 0; j < pBag->GetBagSize(); ++j)
|
||||
{
|
||||
Item* pItem = GetItemByPos( i, j );
|
||||
if( pItem && pItem->GetEntry() == item )
|
||||
if (pItem && pItem->GetEntry() == item && !pItem->IsInTrade())
|
||||
{
|
||||
tempcount += pItem->GetCount();
|
||||
if( tempcount >= count )
|
||||
if (tempcount >= count)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -9093,24 +9192,24 @@ bool Player::HasItemCount( uint32 item, uint32 count, bool inBankAlso ) const
|
|||
for(int i = BANK_SLOT_ITEM_START; i < BANK_SLOT_ITEM_END; ++i)
|
||||
{
|
||||
Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i );
|
||||
if( pItem && pItem->GetEntry() == item )
|
||||
if (pItem && pItem->GetEntry() == item && !pItem->IsInTrade())
|
||||
{
|
||||
tempcount += pItem->GetCount();
|
||||
if( tempcount >= count )
|
||||
if (tempcount >= count)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
for(int i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; ++i)
|
||||
{
|
||||
if(Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ))
|
||||
if (Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ))
|
||||
{
|
||||
for(uint32 j = 0; j < pBag->GetBagSize(); ++j)
|
||||
{
|
||||
Item* pItem = GetItemByPos( i, j );
|
||||
if( pItem && pItem->GetEntry() == item )
|
||||
if (pItem && pItem->GetEntry() == item && !pItem->IsInTrade())
|
||||
{
|
||||
tempcount += pItem->GetCount();
|
||||
if( tempcount >= count )
|
||||
if (tempcount >= count)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -11231,7 +11330,7 @@ void Player::DestroyItemCount( uint32 item, uint32 count, bool update, bool uneq
|
|||
{
|
||||
if (Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ))
|
||||
{
|
||||
if (pItem->GetEntry() == item)
|
||||
if (pItem->GetEntry() == item && !pItem->IsInTrade())
|
||||
{
|
||||
if (pItem->GetCount() + remcount <= count)
|
||||
{
|
||||
|
|
@ -11259,7 +11358,7 @@ void Player::DestroyItemCount( uint32 item, uint32 count, bool update, bool uneq
|
|||
{
|
||||
if (Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ))
|
||||
{
|
||||
if (pItem->GetEntry() == item)
|
||||
if (pItem->GetEntry() == item && !pItem->IsInTrade())
|
||||
{
|
||||
if (pItem->GetCount() + remcount <= count)
|
||||
{
|
||||
|
|
@ -11292,7 +11391,7 @@ void Player::DestroyItemCount( uint32 item, uint32 count, bool update, bool uneq
|
|||
{
|
||||
if(Item* pItem = pBag->GetItemByPos(j))
|
||||
{
|
||||
if (pItem->GetEntry() == item)
|
||||
if (pItem->GetEntry() == item && !pItem->IsInTrade())
|
||||
{
|
||||
// all items in bags can be unequipped
|
||||
if (pItem->GetCount() + remcount <= count)
|
||||
|
|
@ -11323,7 +11422,7 @@ void Player::DestroyItemCount( uint32 item, uint32 count, bool update, bool uneq
|
|||
{
|
||||
if (Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ))
|
||||
{
|
||||
if (pItem && pItem->GetEntry() == item)
|
||||
if (pItem && pItem->GetEntry() == item && !pItem->IsInTrade())
|
||||
{
|
||||
if (pItem->GetCount() + remcount <= count)
|
||||
{
|
||||
|
|
@ -11992,7 +12091,7 @@ void Player::TradeCancel(bool sendback)
|
|||
{
|
||||
if (m_trade)
|
||||
{
|
||||
Player* trader = m_trade->m_tradeWith;
|
||||
Player* trader = m_trade->GetTrader();
|
||||
|
||||
// send yellow "Trade canceled" message to both traders
|
||||
if (sendback)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue