ManaPlus
Functions
TmwAthena::BuySellRecv Namespace Reference

Functions

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

Function Documentation

◆ processNpcBuy()

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

Definition at line 47 of file buysellrecv.cpp.

48 {
49  msg.readInt16("len");
50  const unsigned int n_items = (msg.getLength() - 4U) / 11;
56 
57  for (unsigned int k = 0; k < n_items; k++)
58  {
59  const int value = msg.readInt32("price");
60  msg.readInt32("dc value?");
61  const ItemTypeT type = static_cast<ItemTypeT>(msg.readUInt8("type"));
62  const int itemId = msg.readInt16("item id");
63  const ItemColor color = ItemColor_one;
64  Ea::BuySellRecv::mBuyDialog->addItem(itemId, type, color, 0, value);
65  }
67 }
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
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
BuyDialog * mBuyDialog
Definition: buysellrecv.cpp:53
int32_t getAttribute(const AttributesT id)
Definition: playerinfo.cpp:102

References BuyDialog::addItem(), CREATEWIDGETV, DEFAULT_CURRENCY, PlayerInfo::getAttribute(), ItemColor_one, Ea::BuySellRecv::mBuyDialog, Ea::BuySellRecv::mNpcId, Attributes::MONEY, Actions::msg(), BuyDialog::setMoney(), and BuyDialog::sort().

◆ processNpcBuyResponse()

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

Definition at line 89 of file buysellrecv.cpp.

90 {
91  const uint8_t response = msg.readUInt8("response");
92  if (response == 0U)
93  {
95  return;
96  }
97  // Reset player money since buy dialog already assumed purchase
98  // would go fine
99  if (Ea::BuySellRecv::mBuyDialog != nullptr)
100  {
103  }
104  switch (response)
105  {
106  case 1:
108  break;
109 
110  case 2:
112  break;
113 
114  case 3:
116  break;
117 
118  default:
120  break;
121  }
122 }
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, PlayerInfo::getAttribute(), Ea::BuySellRecv::mBuyDialog, Attributes::MONEY, Actions::msg(), NotifyManager::notify(), and BuyDialog::setMoney().

◆ processNpcSellResponse()

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

Definition at line 69 of file buysellrecv.cpp.

70 {
71  switch (msg.readUInt8("result"))
72  {
73  case 0:
75  break;
76  case 1:
77  default:
79  break;
80  case 2:
82  break;
83  case 3:
85  break;
86  }
87 }
@ 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.