ManaPlus
Public Member Functions
EAthena::TradeHandler Class Reference

#include <tradehandler.h>

Inheritance diagram for EAthena::TradeHandler:
Ea::TradeHandler Net::TradeHandler

Public Member Functions

 TradeHandler ()
 
 ~TradeHandler ()
 
void request (const Being *const being) const
 
void respond (const bool accept) const
 
void addItem (const Item *const item, const int amount) const
 
void setMoney (const int amount) const
 
void confirm () const
 
void finish () const
 
void cancel () const
 
- Public Member Functions inherited from Ea::TradeHandler
 TradeHandler ()
 
void removeItem (const int slotNum, const int amount) const
 
- Public Member Functions inherited from Net::TradeHandler
 TradeHandler ()
 

Detailed Description

Definition at line 32 of file tradehandler.h.

Constructor & Destructor Documentation

◆ TradeHandler()

EAthena::TradeHandler::TradeHandler ( )

Definition at line 41 of file tradehandler.cpp.

41  :
43 {
44  tradeHandler = this;
47 }
Net::TradeHandler * tradeHandler
Definition: net.cpp:98

References EAthena::TradeRecv::mItemIndex, EAthena::TradeRecv::mQuantity, and tradeHandler.

◆ ~TradeHandler()

EAthena::TradeHandler::~TradeHandler ( )
virtual

Reimplemented from Net::TradeHandler.

Definition at line 49 of file tradehandler.cpp.

50 {
51  tradeHandler = nullptr;
52 }

References tradeHandler.

Member Function Documentation

◆ addItem()

void EAthena::TradeHandler::addItem ( const Item *const  item,
const int  amount 
) const
virtual

Reimplemented from Net::TradeHandler.

Definition at line 72 of file tradehandler.cpp.

73 {
74  if (item == nullptr)
75  return;
76 
78  TradeRecv::mQuantity = amount;
79  createOutPacket(CMSG_TRADE_ITEM_ADD_REQUEST);
80  outMsg.writeInt16(CAST_S16(
82  "index");
83  outMsg.writeInt32(amount, "amount");
84 }
#define CAST_S16
Definition: cast.h:28
int getInvIndex() const
Definition: item.h:165
static const int INVENTORY_OFFSET
Definition: inventory.h:27
#define createOutPacket(name)
Definition: messageout.h:37

References CAST_S16, createOutPacket, Item::getInvIndex(), INVENTORY_OFFSET, EAthena::TradeRecv::mItemIndex, and EAthena::TradeRecv::mQuantity.

◆ cancel()

void EAthena::TradeHandler::cancel ( ) const
virtual

Reimplemented from Net::TradeHandler.

Definition at line 103 of file tradehandler.cpp.

104 {
105  createOutPacket(CMSG_TRADE_CANCEL_REQUEST);
106 }

References createOutPacket.

◆ confirm()

void EAthena::TradeHandler::confirm ( ) const
virtual

Reimplemented from Net::TradeHandler.

Definition at line 93 of file tradehandler.cpp.

94 {
95  createOutPacket(CMSG_TRADE_ADD_COMPLETE);
96 }

References createOutPacket.

◆ finish()

void EAthena::TradeHandler::finish ( ) const
virtual

Reimplemented from Net::TradeHandler.

Definition at line 98 of file tradehandler.cpp.

99 {
100  createOutPacket(CMSG_TRADE_OK);
101 }

References createOutPacket.

◆ request()

void EAthena::TradeHandler::request ( const Being *const  being) const
virtual

Reimplemented from Net::TradeHandler.

Definition at line 54 of file tradehandler.cpp.

55 {
56  if (being == nullptr)
57  return;
58 
59  createOutPacket(CMSG_TRADE_REQUEST);
60  outMsg.writeBeingId(being->getId(), "player id");
61 }
BeingId getId() const
Definition: actorsprite.h:64

References createOutPacket, and ActorSprite::getId().

◆ respond()

void EAthena::TradeHandler::respond ( const bool  accept) const
virtual

Reimplemented from Net::TradeHandler.

Definition at line 63 of file tradehandler.cpp.

64 {
65  if (!accept)
67 
68  createOutPacket(CMSG_TRADE_RESPONSE);
69  outMsg.writeInt8(CAST_S8(accept ? 3 : 4), "accept");
70 }
#define CAST_S8
Definition: cast.h:26
void setTrading(const Trading trading)
Definition: playerinfo.cpp:396
TcpNet::Socket accept(const TcpNet::Socket sock)
Definition: sdltcpnet.cpp:198
const bool Trading_false
Definition: trading.h:30

References TcpNet::accept(), CAST_S8, createOutPacket, PlayerInfo::setTrading(), and Trading_false.

◆ setMoney()

void EAthena::TradeHandler::setMoney ( const int  amount) const
virtual

Reimplemented from Net::TradeHandler.

Definition at line 86 of file tradehandler.cpp.

87 {
88  createOutPacket(CMSG_TRADE_ITEM_ADD_REQUEST);
89  outMsg.writeInt16(0, "index");
90  outMsg.writeInt32(amount, "amount");
91 }

References createOutPacket.


The documentation for this class was generated from the following files: