ManaPlus
Functions
EAthena::BuyingStoreRecv Namespace Reference

Functions

void processBuyingStoreOpen (Net::MessageIn &msg)
 
void processBuyingStoreCreateFailed (Net::MessageIn &msg)
 
void processBuyingStoreOwnItems (Net::MessageIn &msg)
 
void processBuyingStoreShowBoard (Net::MessageIn &msg)
 
void processBuyingStoreHideBoard (Net::MessageIn &msg)
 
void processBuyingStoreItemsList (Net::MessageIn &msg)
 
void processBuyingStoreSellFailed (Net::MessageIn &msg)
 
void processBuyingStoreReport (Net::MessageIn &msg)
 
void processBuyingStoreDeleteItem (Net::MessageIn &msg)
 
void processBuyingStoreSellerSellFailed (Net::MessageIn &msg)
 

Function Documentation

◆ processBuyingStoreCreateFailed()

void EAthena::BuyingStoreRecv::processBuyingStoreCreateFailed ( Net::MessageIn msg)

Definition at line 60 of file buyingstorerecv.cpp.

61 {
62  const int16_t result = msg.readInt16("result");
63  const int weight = msg.readInt32("weight");
64  switch (result)
65  {
66  case 1:
67  default:
69  break;
70  case 2:
73  weight);
74  break;
75  case 8:
77  break;
78  }
79 }
bool msg(InputEvent &event)
Definition: chat.cpp:39
void notify(const unsigned int message)
@ BUYING_STORE_CREATE_EMPTY
Definition: notifytypes.h:133
@ BUYING_STORE_CREATE_FAILED_WEIGHT
Definition: notifytypes.h:132
@ BUYING_STORE_CREATE_FAILED
Definition: notifytypes.h:131

References NotifyTypes::BUYING_STORE_CREATE_EMPTY, NotifyTypes::BUYING_STORE_CREATE_FAILED, NotifyTypes::BUYING_STORE_CREATE_FAILED_WEIGHT, Actions::msg(), and NotifyManager::notify().

◆ processBuyingStoreDeleteItem()

void EAthena::BuyingStoreRecv::processBuyingStoreDeleteItem ( Net::MessageIn msg)

Definition at line 226 of file buyingstorerecv.cpp.

227 {
228  Inventory *const inventory = localPlayer != nullptr
230 
231  const int index = msg.readInt16("index") - INVENTORY_OFFSET;
232  const int amount = msg.readInt16("amount");
233  msg.readInt32("price");
234 
235  if (inventory != nullptr)
236  {
237  if (Item *const item = inventory->getItem(index))
238  {
239  item->increaseQuantity(-amount);
240  if (item->getQuantity() == 0)
241  inventory->removeItemAt(index);
243  }
244  }
245 }
static void distributeEvent()
void removeItemAt(const int index)
Definition: inventory.cpp:254
Item * getItem(const int index) const
Definition: inventory.cpp:83
Definition: item.h:50
static const int INVENTORY_OFFSET
Definition: inventory.h:27
#define nullptr
Definition: localconsts.h:45
LocalPlayer * localPlayer
Inventory * getInventory()
Definition: playerinfo.cpp:195

References ArrowsListener::distributeEvent(), PlayerInfo::getInventory(), Inventory::getItem(), INVENTORY_OFFSET, localPlayer, Actions::msg(), and Inventory::removeItemAt().

◆ processBuyingStoreHideBoard()

void EAthena::BuyingStoreRecv::processBuyingStoreHideBoard ( Net::MessageIn msg)

Definition at line 113 of file buyingstorerecv.cpp.

114 {
115  if (actorManager == nullptr)
116  return;
117  const BeingId id = msg.readBeingId("owner id");
118  Being *const dstBeing = actorManager->findBeing(id);
119  if (dstBeing != nullptr)
120  dstBeing->setBuyBoard(std::string());
121  if (dstBeing == localPlayer)
122  {
125  }
126 }
ActorManager * actorManager
int BeingId
Definition: beingid.h:30
Being * findBeing(const BeingId id) const
Definition: being.h:96
void setBuyBoard(const std::string &text)
Definition: being.cpp:5336
static void distributeEvent(const bool b)
void enableVending(const bool b)
Definition: playerinfo.cpp:658

References actorManager, BuyingStoreModeListener::distributeEvent(), PlayerInfo::enableVending(), ActorManager::findBeing(), localPlayer, Actions::msg(), and Being::setBuyBoard().

◆ processBuyingStoreItemsList()

void EAthena::BuyingStoreRecv::processBuyingStoreItemsList ( Net::MessageIn msg)

Definition at line 128 of file buyingstorerecv.cpp.

129 {
130  if (actorManager == nullptr)
131  return;
132  const int count = (msg.readInt16("len") - 16) / (7 + itemIdLen);
133  const BeingId id = msg.readBeingId("account id");
134  const int storeId = msg.readInt32("store id");
135  // +++ in future need use it too
136  msg.readInt32("money limit");
137 
138  const Being *const dstBeing = actorManager->findBeing(id);
139  if (dstBeing == nullptr)
140  return;
141 
143  dstBeing->getId(),
144  storeId);
146  const Inventory *const inv = PlayerInfo::getInventory();
147  for (int f = 0; f < count; f ++)
148  {
149  const int price = msg.readInt32("price");
150  const int amount = msg.readInt16("amount");
151  const ItemTypeT itemType = static_cast<ItemTypeT>(
152  msg.readUInt8("item type"));
153  const int itemId = msg.readItemId("item id");
154 
155  if (inv == nullptr)
156  continue;
157  const Item *const item = inv->findItem(itemId, ItemColor_one);
158  if (item == nullptr)
159  continue;
160  // +++ need add colors support
161  dialog->addItem(itemId, itemType, ItemColor_one, amount, price);
162  }
163 }
int itemIdLen
Definition: client.cpp:130
BeingId getId() const
Definition: actorsprite.h:64
Item * findItem(const int itemId, const ItemColor color) const
Definition: inventory.cpp:94
void addItem(const Item *const item, const int price)
Definition: selldialog.cpp:238
void setMoney(const int amount)
Definition: selldialog.cpp:340
#define CREATEWIDGETR(type,...)
Definition: createwidget.h:36
const ItemColor ItemColor_one
Definition: itemcolor.h:30
ItemType ::T ItemTypeT
Definition: itemtype.h:43
int32_t getAttribute(const AttributesT id)
Definition: playerinfo.cpp:102

References actorManager, SellDialog::addItem(), CREATEWIDGETR, ActorManager::findBeing(), Inventory::findItem(), PlayerInfo::getAttribute(), ActorSprite::getId(), PlayerInfo::getInventory(), ItemColor_one, itemIdLen, Attributes::MONEY, Actions::msg(), and SellDialog::setMoney().

◆ processBuyingStoreOpen()

void EAthena::BuyingStoreRecv::processBuyingStoreOpen ( Net::MessageIn msg)

Definition at line 55 of file buyingstorerecv.cpp.

56 {
58 }
static void distributeEvent(const int slots)

References BuyingStoreSlotsListener::distributeEvent(), and Actions::msg().

◆ processBuyingStoreOwnItems()

void EAthena::BuyingStoreRecv::processBuyingStoreOwnItems ( Net::MessageIn msg)

Definition at line 81 of file buyingstorerecv.cpp.

82 {
83  const int count = (msg.readInt16("len") - 12) / (7 + itemIdLen);
84  msg.readBeingId("account id");
85  msg.readInt32("money limit");
86  for (int f = 0; f < count; f ++)
87  {
88  msg.readInt32("price");
89  msg.readInt16("amount");
90  msg.readUInt8("item type");
91  msg.readItemId("item id");
92  }
95 }

References BuyingStoreModeListener::distributeEvent(), PlayerInfo::enableVending(), itemIdLen, and Actions::msg().

◆ processBuyingStoreReport()

void EAthena::BuyingStoreRecv::processBuyingStoreReport ( Net::MessageIn msg)

Definition at line 208 of file buyingstorerecv.cpp.

209 {
211  msg.readItemId("item id");
212  msg.readInt16("amount");
213  if (msg.getVersion() >= 20141016)
214  {
215  msg.readInt32("money");
216  msg.readInt32("money limit");
217  msg.readInt32("char id");
218  msg.readInt32("date");
219  }
220  else
221  {
222  msg.readInt32("money limit");
223  }
224 }
#define UNIMPLEMENTEDPACKET
Definition: logger.h:56

References Actions::msg(), and UNIMPLEMENTEDPACKET.

◆ processBuyingStoreSellerSellFailed()

void EAthena::BuyingStoreRecv::processBuyingStoreSellerSellFailed ( Net::MessageIn msg)

Definition at line 183 of file buyingstorerecv.cpp.

184 {
185  const int16_t result = msg.readInt16("result");
186  msg.readItemId("item id");
187  switch (result)
188  {
189  case 5:
192  break;
193  case 6:
196  break;
197  case 7:
200  break;
201  default:
204  break;
205  }
206 }
@ BUYING_STORE_SELLER_SELL_FAILED_BALANCE
Definition: notifytypes.h:139
@ BUYING_STORE_SELLER_SELL_FAILED_DEAL
Definition: notifytypes.h:137
@ BUYING_STORE_SELLER_SELL_FAILED
Definition: notifytypes.h:140
@ BUYING_STORE_SELLER_SELL_FAILED_AMOUNT
Definition: notifytypes.h:138

References NotifyTypes::BUYING_STORE_SELLER_SELL_FAILED, NotifyTypes::BUYING_STORE_SELLER_SELL_FAILED_AMOUNT, NotifyTypes::BUYING_STORE_SELLER_SELL_FAILED_BALANCE, NotifyTypes::BUYING_STORE_SELLER_SELL_FAILED_DEAL, Actions::msg(), and NotifyManager::notify().

◆ processBuyingStoreSellFailed()

void EAthena::BuyingStoreRecv::processBuyingStoreSellFailed ( Net::MessageIn msg)

Definition at line 165 of file buyingstorerecv.cpp.

166 {
167  const int16_t result = msg.readInt16("result");
168  switch (result)
169  {
170  case 3:
173  break;
174  case 4:
176  break;
177  default:
179  break;
180  }
181 }
@ BUYING_STORE_SELL_FAILED_EMPTY
Definition: notifytypes.h:135
@ BUYING_STORE_SELL_FAILED
Definition: notifytypes.h:136
@ BUYING_STORE_SELL_FAILED_MONEY_LIMIT
Definition: notifytypes.h:134

References NotifyTypes::BUYING_STORE_SELL_FAILED, NotifyTypes::BUYING_STORE_SELL_FAILED_EMPTY, NotifyTypes::BUYING_STORE_SELL_FAILED_MONEY_LIMIT, Actions::msg(), and NotifyManager::notify().

◆ processBuyingStoreShowBoard()

void EAthena::BuyingStoreRecv::processBuyingStoreShowBoard ( Net::MessageIn msg)

Definition at line 97 of file buyingstorerecv.cpp.

98 {
99  if (actorManager == nullptr)
100  return;
101  const BeingId id = msg.readBeingId("owner id");
102  Being *const dstBeing = actorManager->findBeing(id);
103  if (dstBeing != nullptr)
104  {
105  dstBeing->setBuyBoard(msg.readString(80, "shop name"));
106  }
107  else
108  {
109  msg.readString(80, "shop name");
110  }
111 }

References actorManager, ActorManager::findBeing(), Actions::msg(), and Being::setBuyBoard().