ManaPlus
Functions | Variables
EAthena::CashShopRecv Namespace Reference

Functions

void processCashShopOpen (Net::MessageIn &msg)
 
void processCashShopBuyAck (Net::MessageIn &msg)
 
void processCashShopPoints (Net::MessageIn &msg)
 
void processCashShopBuy (Net::MessageIn &msg)
 
void processCashShopTabPriceList (Net::MessageIn &msg)
 
void processCashShopSchedule (Net::MessageIn &msg)
 

Variables

BuyDialogmBuyDialog
 

Function Documentation

◆ processCashShopBuy()

void EAthena::CashShopRecv::processCashShopBuy ( Net::MessageIn msg)

Definition at line 144 of file cashshoprecv.cpp.

145 {
147  msg.readInt32("id");
148  msg.readInt16("result");
149  msg.readInt32("cash points");
150  msg.readInt32("kafra points");
151 }
#define UNIMPLEMENTEDPACKET
Definition: logger.h:56
bool msg(InputEvent &event)
Definition: chat.cpp:39

References Actions::msg(), and UNIMPLEMENTEDPACKET.

◆ processCashShopBuyAck()

void EAthena::CashShopRecv::processCashShopBuyAck ( Net::MessageIn msg)

Definition at line 103 of file cashshoprecv.cpp.

104 {
105  msg.readInt32("cash points");
106  msg.readInt32("kafra points");
107  const uint16_t res = msg.readInt16("error");
108  switch (res)
109  {
110  case 0:
112  break;
113  case 1:
115  break;
116  case 2:
118  break;
119  case 3:
121  break;
122  case 4:
124  break;
125  case 5:
127  break;
128  case 6:
130  break;
131  default:
133  break;
134  }
135 }
#define UNIMPLEMENTEDPACKETFIELD(field)
Definition: logger.h:59
void notify(const unsigned int message)
@ BUY_FAILED_NPC_NOT_FOUND
Definition: notifytypes.h:235
@ BUY_FAILED_WRONG_ITEM
Definition: notifytypes.h:237
@ BUY_FAILED_NO_MONEY
Definition: notifytypes.h:34
@ BUY_FAILED_SYSTEM_ERROR
Definition: notifytypes.h:236
@ BUY_FAILED_OVERWEIGHT
Definition: notifytypes.h:35

References NotifyTypes::BUY_DONE, NotifyTypes::BUY_FAILED_NO_MONEY, NotifyTypes::BUY_FAILED_NPC_NOT_FOUND, NotifyTypes::BUY_FAILED_OVERWEIGHT, NotifyTypes::BUY_FAILED_SYSTEM_ERROR, NotifyTypes::BUY_FAILED_WRONG_ITEM, NotifyTypes::BUY_TRADE_FAILED, Actions::msg(), NotifyManager::notify(), and UNIMPLEMENTEDPACKETFIELD.

◆ processCashShopOpen()

void EAthena::CashShopRecv::processCashShopOpen ( Net::MessageIn msg)

Definition at line 55 of file cashshoprecv.cpp.

56 {
57  int count;
58  int blockSize = 11;
59  if (itemIdLen == 4)
60  blockSize += 2;
61  if (packetVersion >= 20070711)
62  count = (msg.readInt16("len") - 12) / blockSize;
63  else
64  count = (msg.readInt16("len") - 8) / blockSize;
65 
66  const BeingTypeId npcId = NpcRecv::mNpcTypeId;
67  std::string currency;
68 
69  if (npcId != BeingTypeId_zero)
70  {
71  const BeingInfo *const info = NPCDB::get(npcId);
72  if (info != nullptr)
73  currency = info->getCurrency();
74  else
75  currency = DEFAULT_CURRENCY;
76  }
77  else
78  {
79  currency = DEFAULT_CURRENCY;
80  }
83  currency);
84  const int points = msg.readInt32("cash points");
85 
86  mBuyDialog->setMoney(points);
87 
88  if (packetVersion >= 20070711)
89  msg.readInt32("kafra points");
90  for (int f = 0; f < count; f ++)
91  {
92  msg.readInt32("price");
93  const int value = msg.readInt32("discount price");
94  const ItemTypeT type = static_cast<ItemTypeT>(
95  msg.readUInt8("item type"));
96  const int itemId = msg.readItemId("item id");
97  const ItemColor color = ItemColor_one;
98  mBuyDialog->addItem(itemId, type, color, 0, value);
99  }
100  mBuyDialog->sort();
101 }
int BeingId
Definition: beingid.h:30
int BeingTypeId
Definition: beingtypeid.h:30
const BeingTypeId BeingTypeId_zero
Definition: beingtypeid.h:30
int itemIdLen
Definition: client.cpp:130
int packetVersion
Definition: client.cpp:125
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
BeingTypeId mNpcTypeId
Definition: npcrecv.cpp:43
BeingInfo * get(const BeingTypeId id)
Definition: npcdb.cpp:188

References BuyDialog::addItem(), BeingTypeId_zero, BuyDialog::Cash, CREATEWIDGETV, DEFAULT_CURRENCY, fromInt, NPCDB::get(), Actions::info(), ItemColor_one, itemIdLen, mBuyDialog, EAthena::NpcRecv::mNpcTypeId, Actions::msg(), packetVersion, BuyDialog::setMoney(), and BuyDialog::sort().

◆ processCashShopPoints()

void EAthena::CashShopRecv::processCashShopPoints ( Net::MessageIn msg)

Definition at line 137 of file cashshoprecv.cpp.

138 {
140  msg.readInt32("cash points");
141  msg.readInt32("kafra points");
142 }

References Actions::msg(), and UNIMPLEMENTEDPACKET.

◆ processCashShopSchedule()

void EAthena::CashShopRecv::processCashShopSchedule ( Net::MessageIn msg)

Definition at line 169 of file cashshoprecv.cpp.

170 {
172  int blockSize = 6;
173  if (itemIdLen == 4)
174  blockSize += 2;
175  const int count = (msg.readInt16("len") - 8) / blockSize;
176  const int itemsCount = msg.readInt16("count");
177  msg.readInt16("tab");
178  if (count != itemsCount)
179  logger->log("error: wrong list count");
180 
181  for (int f = 0; f < count; f ++)
182  {
183  msg.readItemId("item id");
184  msg.readInt32("price");
185  }
186 }
void log(const char *const log_text,...)
Definition: logger.cpp:269
Logger * logger
Definition: logger.cpp:89

References itemIdLen, Logger::log(), logger, Actions::msg(), and UNIMPLEMENTEDPACKET.

◆ processCashShopTabPriceList()

void EAthena::CashShopRecv::processCashShopTabPriceList ( Net::MessageIn msg)

Definition at line 153 of file cashshoprecv.cpp.

154 {
156  const int count = (msg.readInt16("len") - 10) / 6;
157  msg.readInt32("tab");
158  const int itemsCount = msg.readInt16("count");
159  if (count != itemsCount)
160  logger->log("error: wrong list count");
161 
162  for (int f = 0; f < count; f ++)
163  {
164  msg.readInt16("item id"); // item id size always 16 bit
165  msg.readInt32("price");
166  }
167 }

References Logger::log(), logger, Actions::msg(), and UNIMPLEMENTEDPACKET.

Variable Documentation

◆ mBuyDialog

BuyDialog * EAthena::CashShopRecv::mBuyDialog