ManaPlus
Public Member Functions
TmwAthena::TradeHandler Class Reference

#include <tradehandler.h>

Inheritance diagram for TmwAthena::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()

TmwAthena::TradeHandler::TradeHandler ( )

Definition at line 42 of file tradehandler.cpp.

42  :
44 {
45  tradeHandler = this;
46 }
Net::TradeHandler * tradeHandler
Definition: net.cpp:98

References tradeHandler.

◆ ~TradeHandler()

TmwAthena::TradeHandler::~TradeHandler ( )
virtual

Reimplemented from Net::TradeHandler.

Definition at line 48 of file tradehandler.cpp.

49 {
50  tradeHandler = nullptr;
51 }

References tradeHandler.

Member Function Documentation

◆ addItem()

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

Reimplemented from Net::TradeHandler.

Definition at line 71 of file tradehandler.cpp.

72 {
73  if (item == nullptr)
74  return;
75 
76  createOutPacket(CMSG_TRADE_ITEM_ADD_REQUEST);
77  outMsg.writeInt16(CAST_S16(
78  item->getInvIndex() + INVENTORY_OFFSET), "index");
79  outMsg.writeInt32(amount, "amount");
80 }
#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(), and INVENTORY_OFFSET.

◆ cancel()

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

Reimplemented from Net::TradeHandler.

Definition at line 99 of file tradehandler.cpp.

100 {
101  createOutPacket(CMSG_TRADE_CANCEL_REQUEST);
102 }

References createOutPacket.

◆ confirm()

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

Reimplemented from Net::TradeHandler.

Definition at line 89 of file tradehandler.cpp.

90 {
91  createOutPacket(CMSG_TRADE_ADD_COMPLETE);
92 }

References createOutPacket.

◆ finish()

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

Reimplemented from Net::TradeHandler.

Definition at line 94 of file tradehandler.cpp.

95 {
96  createOutPacket(CMSG_TRADE_OK);
97 }

References createOutPacket.

◆ request()

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

Reimplemented from Net::TradeHandler.

Definition at line 53 of file tradehandler.cpp.

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

References createOutPacket, and ActorSprite::getId().

◆ respond()

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

Reimplemented from Net::TradeHandler.

Definition at line 62 of file tradehandler.cpp.

63 {
64  if (!accept)
66 
67  createOutPacket(CMSG_TRADE_RESPONSE);
68  outMsg.writeInt8(CAST_S8(accept ? 3 : 4), "accept");
69 }
#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 TmwAthena::TradeHandler::setMoney ( const int  amount) const
virtual

Reimplemented from Net::TradeHandler.

Definition at line 82 of file tradehandler.cpp.

83 {
84  createOutPacket(CMSG_TRADE_ITEM_ADD_REQUEST);
85  outMsg.writeInt16(0, "index");
86  outMsg.writeInt32(amount, "amount");
87 }

References createOutPacket.


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