ManaPlus
Functions | Variables
EAthena::MarketRecv Namespace Reference

Functions

void processMarketOpen (Net::MessageIn &msg)
 
void processMarketBuyAck (Net::MessageIn &msg)
 

Variables

BuyDialogmBuyDialog = 0
 

Function Documentation

◆ processMarketBuyAck()

void EAthena::MarketRecv::processMarketBuyAck ( Net::MessageIn msg)

Definition at line 95 of file marketrecv.cpp.

96 {
97  const int len = (msg.readInt16("len") - 5) / (6 + itemIdLen);
98  const int res = msg.readUInt8("result");
99  for (int f = 0; f < len; f ++)
100  {
101  msg.readItemId("item id");
102  msg.readInt16("amount");
103  msg.readInt32("price");
104  }
105  if (res != 0)
107  else
109 }
int itemIdLen
Definition: client.cpp:130
bool msg(InputEvent &event)
Definition: chat.cpp:39
void notify(const unsigned int message)

References NotifyTypes::BUY_DONE, NotifyTypes::BUY_FAILED, itemIdLen, Actions::msg(), and NotifyManager::notify().

◆ processMarketOpen()

void EAthena::MarketRecv::processMarketOpen ( Net::MessageIn msg)

Definition at line 57 of file marketrecv.cpp.

58 {
59  const int len = (msg.readInt16("len") - 4) / (11 + itemIdLen);
60 
61  const BeingTypeId npcId = NpcRecv::mNpcTypeId;
62  std::string currency;
63 
64  if (npcId != BeingTypeId_zero)
65  {
66  const BeingInfo *const info = NPCDB::get(npcId);
67  if (info != nullptr)
68  currency = info->getCurrency();
69  else
70  currency = DEFAULT_CURRENCY;
71  }
72  else
73  {
74  currency = DEFAULT_CURRENCY;
75  }
76 
79  currency);
81 
82  for (int f = 0; f < len; f ++)
83  {
84  const int itemId = msg.readItemId("item id");
85  const ItemTypeT type = static_cast<ItemTypeT>(msg.readUInt8("type"));
86  const int value = msg.readInt32("price");
87  const int amount = msg.readInt32("amount");
88  msg.readInt16("weight"); // +++ compare with item weight from db?
89  const ItemColor color = ItemColor_one;
90  mBuyDialog->addItem(itemId, type, color, amount, value);
91  }
92  mBuyDialog->sort();
93 }
int BeingId
Definition: beingid.h:30
int BeingTypeId
Definition: beingtypeid.h:30
const BeingTypeId BeingTypeId_zero
Definition: beingtypeid.h:30
void sort()
Definition: buydialog.cpp:472
ShopItem * addItem(const int id, const ItemTypeT type, const ItemColor color, const int amount, const int price)
Definition: buydialog.cpp:457
void setMoney(const int amount)
Definition: buydialog.cpp:437
#define CREATEWIDGETV(var, type,...)
Definition: createwidget.h:25
const std::string DEFAULT_CURRENCY
Definition: currency.h:27
#define fromInt(val, name)
Definition: intdefines.h:46
const ItemColor ItemColor_one
Definition: itemcolor.h:30
uint16_t ItemColor
Definition: itemcolor.h:30
ItemType ::T ItemTypeT
Definition: itemtype.h:43
bool info(InputEvent &event)
Definition: commands.cpp:57
BuyDialog * mBuyDialog
Definition: marketrecv.cpp:53
BeingTypeId mNpcTypeId
Definition: npcrecv.cpp:43
BeingInfo * get(const BeingTypeId id)
Definition: npcdb.cpp:188
int32_t getAttribute(const AttributesT id)
Definition: playerinfo.cpp:102

References BuyDialog::addItem(), BeingTypeId_zero, CREATEWIDGETV, DEFAULT_CURRENCY, fromInt, NPCDB::get(), PlayerInfo::getAttribute(), Actions::info(), ItemColor_one, itemIdLen, BuyDialog::Market, mBuyDialog, EAthena::NpcRecv::mNpcTypeId, Attributes::MONEY, Actions::msg(), BuyDialog::setMoney(), and BuyDialog::sort().

Variable Documentation

◆ mBuyDialog

BuyDialog * EAthena::MarketRecv::mBuyDialog = 0

Definition at line 53 of file marketrecv.cpp.

Referenced by EAthena::MarketHandler::MarketHandler(), and processMarketOpen().