ManaPlus
Functions
EAthena::BuySellRecv Namespace Reference

Functions

void processNpcBuy (Net::MessageIn &msg)
 
void processNpcSellResponse (Net::MessageIn &msg)
 
void processNpcBuyResponse (Net::MessageIn &msg)
 

Function Documentation

◆ processNpcBuy()

void EAthena::BuySellRecv::processNpcBuy ( Net::MessageIn msg)

Definition at line 55 of file buysellrecv.cpp.

56 {
57  msg.readInt16("len");
58  const int sz = 9 + itemIdLen;
59  const int n_items = (msg.getLength() - 4) / sz;
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);
82 
83  for (int k = 0; k < n_items; k++)
84  {
85  const int value = msg.readInt32("price");
86  msg.readInt32("dc value?");
87  const ItemTypeT type = static_cast<ItemTypeT>(
88  msg.readUInt8("type"));
89  const int itemId = msg.readItemId("item id");
90  const ItemColor color = ItemColor_one;
91  Ea::BuySellRecv::mBuyDialog->addItem(itemId, type, color, 0, value);
92  }
94 }
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
int itemIdLen
Definition: client.cpp:130
const ItemColor ItemColor_one
Definition: itemcolor.h:30
uint16_t ItemColor
Definition: itemcolor.h:30
ItemType ::T ItemTypeT
Definition: itemtype.h:43
bool msg(InputEvent &event)
Definition: chat.cpp:39
bool info(InputEvent &event)
Definition: commands.cpp:57
BeingTypeId mNpcTypeId
Definition: npcrecv.cpp:43
BuyDialog * mBuyDialog
Definition: buysellrecv.cpp:53
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, NPCDB::get(), PlayerInfo::getAttribute(), Actions::info(), ItemColor_one, itemIdLen, Ea::BuySellRecv::mBuyDialog, Ea::BuySellRecv::mNpcId, EAthena::NpcRecv::mNpcTypeId, Attributes::MONEY, Actions::msg(), BuyDialog::setMoney(), and BuyDialog::sort().

◆ processNpcBuyResponse()

void EAthena::BuySellRecv::processNpcBuyResponse ( Net::MessageIn msg)

Definition at line 116 of file buysellrecv.cpp.

117 {
118  const uint8_t response = msg.readUInt8("response");
119  if (response == 0U)
120  {
122  return;
123  }
124  switch (response)
125  {
126  case 1:
128  break;
129 
130  case 2:
132  break;
133 
134  case 3:
136  break;
137 
138  default:
140  break;
141  }
142 }
void notify(const unsigned int message)
@ BUY_FAILED_NO_MONEY
Definition: notifytypes.h:34
@ BUY_FAILED_TOO_MANY_ITEMS
Definition: notifytypes.h:36
@ BUY_FAILED_OVERWEIGHT
Definition: notifytypes.h:35

References NotifyTypes::BUY_DONE, NotifyTypes::BUY_FAILED, NotifyTypes::BUY_FAILED_NO_MONEY, NotifyTypes::BUY_FAILED_OVERWEIGHT, NotifyTypes::BUY_FAILED_TOO_MANY_ITEMS, Actions::msg(), and NotifyManager::notify().

◆ processNpcSellResponse()

void EAthena::BuySellRecv::processNpcSellResponse ( Net::MessageIn msg)

Definition at line 96 of file buysellrecv.cpp.

97 {
98  switch (msg.readUInt8("result"))
99  {
100  case 0:
102  break;
103  case 1:
104  default:
106  break;
107  case 2:
109  break;
110  case 3:
112  break;
113  }
114 }
@ SELL_UNSELLABLE_FAILED
Definition: notifytypes.h:41
@ SELL_TRADE_FAILED
Definition: notifytypes.h:40

References Actions::msg(), NotifyManager::notify(), NotifyTypes::SELL_FAILED, NotifyTypes::SELL_TRADE_FAILED, NotifyTypes::SELL_UNSELLABLE_FAILED, and NotifyTypes::SOLD.