ManaPlus
Public Member Functions
EAthena::BuyingStoreHandler Class Reference

#include <buyingstorehandler.h>

Inheritance diagram for EAthena::BuyingStoreHandler:
Net::BuyingStoreHandler

Public Member Functions

 BuyingStoreHandler ()
 
 ~BuyingStoreHandler ()
 
void create (const std::string &name, const int maxMoney, const bool flag, const std::vector< ShopItem * > &items) const
 
void close () const
 
void open (const Being *const being) const
 
void sell (const Being *const being, const int storeId, const Item *const item, const int amount) const
 
- Public Member Functions inherited from Net::BuyingStoreHandler
 BuyingStoreHandler ()
 

Detailed Description

Definition at line 29 of file buyingstorehandler.h.

Constructor & Destructor Documentation

◆ BuyingStoreHandler()

EAthena::BuyingStoreHandler::BuyingStoreHandler ( )

Definition at line 44 of file buyingstorehandler.cpp.

45 {
46  buyingStoreHandler = this;
47 }
Net::BuyingStoreHandler * buyingStoreHandler
Definition: net.cpp:107

References buyingStoreHandler.

◆ ~BuyingStoreHandler()

EAthena::BuyingStoreHandler::~BuyingStoreHandler ( )
virtual

Reimplemented from Net::BuyingStoreHandler.

Definition at line 49 of file buyingstorehandler.cpp.

50 {
51  buyingStoreHandler = nullptr;
52 }

References buyingStoreHandler.

Member Function Documentation

◆ close()

void EAthena::BuyingStoreHandler::close ( ) const
virtual

Implements Net::BuyingStoreHandler.

Definition at line 75 of file buyingstorehandler.cpp.

76 {
77  if (packetVersion < 20100420)
78  return;
79  createOutPacket(CMSG_BUYINGSTORE_CLOSE);
81 }
int packetVersion
Definition: client.cpp:125
#define createOutPacket(name)
Definition: messageout.h:37
void enableVending(const bool b)
Definition: playerinfo.cpp:658

References createOutPacket, PlayerInfo::enableVending(), and packetVersion.

◆ create()

void EAthena::BuyingStoreHandler::create ( const std::string &  name,
const int  maxMoney,
const bool  flag,
const std::vector< ShopItem * > &  items 
) const
virtual

Implements Net::BuyingStoreHandler.

Definition at line 54 of file buyingstorehandler.cpp.

58 {
59  if (packetVersion < 20100303)
60  return;
61  createOutPacket(CMSG_BUYINGSTORE_CREATE);
62  outMsg.writeInt16(CAST_S16(89 + items.size() * (6 + itemIdLen)), "len");
63  outMsg.writeInt32(maxMoney, "limit money");
64  outMsg.writeInt8(static_cast<int8_t>(flag), "flag");
65  outMsg.writeString(name, 80, "store name");
66  FOR_EACH (STD_VECTOR<ShopItem*>::const_iterator, it, items)
67  {
68  const ShopItem *const item = *it;
69  outMsg.writeItemId(item->getId(), "item id");
70  outMsg.writeInt16(CAST_S16(item->getQuantity()), "amount");
71  outMsg.writeInt32(item->getPrice(), "price");
72  }
73 }
#define CAST_S16
Definition: cast.h:28
int getQuantity() const
Definition: item.h:105
int getId() const
Definition: item.h:81
int getPrice() const
Definition: shopitem.h:132
int itemIdLen
Definition: client.cpp:130
#define FOR_EACH(type, iter, array)
Definition: foreach.h:25

References CAST_S16, createOutPacket, FOR_EACH, Item::getId(), ShopItem::getPrice(), Item::getQuantity(), itemIdLen, and packetVersion.

◆ open()

void EAthena::BuyingStoreHandler::open ( const Being *const  being) const
virtual

Implements Net::BuyingStoreHandler.

Definition at line 83 of file buyingstorehandler.cpp.

84 {
85  if (being == nullptr)
86  return;
87  if (packetVersion < 20100420)
88  return;
89  createOutPacket(CMSG_BUYINGSTORE_OPEN);
90  outMsg.writeBeingId(being->getId(), "account id");
91 }
BeingId getId() const
Definition: actorsprite.h:64

References createOutPacket, ActorSprite::getId(), and packetVersion.

◆ sell()

void EAthena::BuyingStoreHandler::sell ( const Being *const  being,
const int  storeId,
const Item *const  item,
const int  amount 
) const
virtual

Implements Net::BuyingStoreHandler.

Definition at line 93 of file buyingstorehandler.cpp.

97 {
98  if ((being == nullptr) || (item == nullptr))
99  return;
100  if (packetVersion < 20100420)
101  return;
102 
103  createOutPacket(CMSG_BUYINGSTORE_SELL);
104  outMsg.writeInt16(18, "len");
105  outMsg.writeBeingId(being->getId(), "account id");
106  outMsg.writeInt32(storeId, "store id");
107  outMsg.writeInt16(CAST_S16(
108  item->getInvIndex() + INVENTORY_OFFSET),
109  "index");
110  outMsg.writeItemId(item->getId(), "item id");
111  outMsg.writeInt16(CAST_S16(amount), "amount");
112 }
int getInvIndex() const
Definition: item.h:165
static const int INVENTORY_OFFSET
Definition: inventory.h:27

References CAST_S16, createOutPacket, ActorSprite::getId(), Item::getId(), Item::getInvIndex(), INVENTORY_OFFSET, and packetVersion.


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