AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
TradeHandler.cpp File Reference
#include "Chat.h"
#include "Item.h"
#include "Language.h"
#include "Log.h"
#include "ObjectAccessor.h"
#include "Opcodes.h"
#include "Player.h"
#include "ScriptMgr.h"
#include "SocialMgr.h"
#include "Spell.h"
#include "SpellMgr.h"
#include "World.h"
#include "WorldPacket.h"
#include "WorldSession.h"

Go to the source code of this file.

Functions

static void setAcceptTradeMode (TradeData *myTrade, TradeData *hisTrade, Item **myItems, Item **hisItems)
 
static void clearAcceptTradeMode (TradeData *myTrade, TradeData *hisTrade)
 
static void clearAcceptTradeMode (Item **myItems, Item **hisItems)
 

Function Documentation

◆ clearAcceptTradeMode() [1/2]

static void clearAcceptTradeMode ( Item **  myItems,
Item **  hisItems 
)
static
235{
236 // clear 'in-trade' flag
237 for (uint8 i = 0; i < TRADE_SLOT_TRADED_COUNT; ++i)
238 {
239 if (myItems[i])
240 myItems[i]->SetInTrade(false);
241 if (hisItems[i])
242 hisItems[i]->SetInTrade(false);
243 }
244}
std::uint8_t uint8
Definition: Define.h:109
@ TRADE_SLOT_TRADED_COUNT
Definition: TradeData.h:30
void SetInTrade(bool b=true)
Definition: Item.h:259

References Item::SetInTrade(), and TRADE_SLOT_TRADED_COUNT.

◆ clearAcceptTradeMode() [2/2]

static void clearAcceptTradeMode ( TradeData myTrade,
TradeData hisTrade 
)
static
229{
230 myTrade->SetInAcceptProcess(false);
231 hisTrade->SetInAcceptProcess(false);
232}
void SetInAcceptProcess(bool state)
Definition: TradeData.h:62

References TradeData::SetInAcceptProcess().

Referenced by WorldSession::HandleAcceptTradeOpcode().

◆ setAcceptTradeMode()

static void setAcceptTradeMode ( TradeData myTrade,
TradeData hisTrade,
Item **  myItems,
Item **  hisItems 
)
static
204{
205 myTrade->SetInAcceptProcess(true);
206 hisTrade->SetInAcceptProcess(true);
207
208 // store items in local list and set 'in-trade' flag
209 for (uint8 i = 0; i < TRADE_SLOT_TRADED_COUNT; ++i)
210 {
211 if (Item* item = myTrade->GetItem(TradeSlots(i)))
212 {
213 LOG_DEBUG("network.opcode", "player trade item {} bag: {} slot: {}", item->GetGUID().ToString(), item->GetBagSlot(), item->GetSlot());
214 //Can return nullptr
215 myItems[i] = item;
216 myItems[i]->SetInTrade();
217 }
218
219 if (Item* item = hisTrade->GetItem(TradeSlots(i)))
220 {
221 LOG_DEBUG("network.opcode", "partner trade item {} bag: {} slot: {}", item->GetGUID().ToString(), item->GetBagSlot(), item->GetSlot());
222 hisItems[i] = item;
223 hisItems[i]->SetInTrade();
224 }
225 }
226}
#define LOG_DEBUG(filterType__,...)
Definition: Log.h:169
TradeSlots
Definition: TradeData.h:28
Definition: Item.h:220
Item * GetItem(TradeSlots slot) const
Definition: TradeData.cpp:26

References TradeData::GetItem(), LOG_DEBUG, TradeData::SetInAcceptProcess(), Item::SetInTrade(), and TRADE_SLOT_TRADED_COUNT.

Referenced by WorldSession::HandleAcceptTradeOpcode().