ManaPlus
Functions | Variables
Ea::BuySellRecv Namespace Reference

Functions

void processNpcBuySellChoice (Net::MessageIn &msg)
 
void processNpcSell (Net::MessageIn &msg)
 

Variables

BeingId mNpcId = BeingId_zero
 
BuyDialogmBuyDialog = 0
 

Function Documentation

◆ processNpcBuySellChoice()

void Ea::BuySellRecv::processNpcBuySellChoice ( Net::MessageIn msg)

Definition at line 56 of file buysellrecv.cpp.

57 {
59  {
60  mNpcId = msg.readBeingId("npc id");
62  }
63 }
static bool isActive()
Definition: buyselldialog.h:70
#define CREATEWIDGET(type,...)
Definition: createwidget.h:29
bool msg(InputEvent &event)
Definition: chat.cpp:39

References CREATEWIDGET, BuySellDialog::isActive(), mNpcId, and Actions::msg().

◆ processNpcSell()

void Ea::BuySellRecv::processNpcSell ( Net::MessageIn msg)

Definition at line 65 of file buysellrecv.cpp.

66 {
67  msg.readInt16("len");
68  const int n_items = (msg.getLength() - 4) / 10;
69  if (n_items > 0)
70  {
71  SellDialog *const dialog = CREATEWIDGETR(NpcSellDialog, mNpcId);
73 
74  for (int k = 0; k < n_items; k++)
75  {
76  const int index = msg.readInt16("index") - INVENTORY_OFFSET;
77  const int value = msg.readInt32("value");
78  msg.readInt32("value?");
79 
80  const Item *const item = PlayerInfo::getInventory()
81  ->getItem(index);
82 
83  if ((item != nullptr) && item->isEquipped() == Equipped_false)
84  dialog->addItem(item, value);
85  }
86  }
87  else
88  {
90  }
91 }
Item * getItem(const int index) const
Definition: inventory.cpp:83
Definition: item.h:50
Equipped isEquipped() const
Definition: item.h:129
void addItem(const Item *const item, const int price)
Definition: selldialog.cpp:238
void setMoney(const int amount)
Definition: selldialog.cpp:340
static const int INVENTORY_OFFSET
Definition: inventory.h:27
#define CREATEWIDGETR(type,...)
Definition: createwidget.h:36
const bool Equipped_false
Definition: equipped.h:30
void notify(const unsigned int message)
Inventory * getInventory()
Definition: playerinfo.cpp:195
int32_t getAttribute(const AttributesT id)
Definition: playerinfo.cpp:102

References SellDialog::addItem(), CREATEWIDGETR, Equipped_false, PlayerInfo::getAttribute(), PlayerInfo::getInventory(), Inventory::getItem(), INVENTORY_OFFSET, Item::isEquipped(), mNpcId, Attributes::MONEY, Actions::msg(), NotifyManager::notify(), NotifyTypes::SELL_LIST_EMPTY, and SellDialog::setMoney().

Variable Documentation

◆ mBuyDialog

BuyDialog * Ea::BuySellRecv::mBuyDialog = 0

◆ mNpcId

BeingId Ea::BuySellRecv::mNpcId = BeingId_zero