summaryrefslogtreecommitdiff
path: root/src/net/eathena
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/eathena')
-rw-r--r--src/net/eathena/vendinghandler.cpp35
-rw-r--r--src/net/eathena/vendinghandler.h4
-rw-r--r--src/net/eathena/vendingrecv.cpp2
3 files changed, 40 insertions, 1 deletions
diff --git a/src/net/eathena/vendinghandler.cpp b/src/net/eathena/vendinghandler.cpp
index 739f39acd..35e77f954 100644
--- a/src/net/eathena/vendinghandler.cpp
+++ b/src/net/eathena/vendinghandler.cpp
@@ -73,6 +73,41 @@ void VendingHandler::buy(const Being *const being,
outMsg.writeInt16(CAST_S16(index), "index");
}
+void VendingHandler::buyItems(const Being *const being,
+ const std::vector<ShopItem*> &items) const
+{
+ int cnt = 0;
+ const int pairSize = 4;
+
+ FOR_EACH (std::vector<ShopItem*>::const_iterator, it, items)
+ {
+ ShopItem *const item = *it;
+ const int usedQuantity = item->getUsedQuantity();
+ if (!usedQuantity)
+ continue;
+ cnt ++;
+ }
+
+ if (cnt > 100)
+ return;
+
+ createOutPacket(CMSG_VENDING_BUY);
+ outMsg.writeInt16(CAST_S16(4 + 4 + pairSize * cnt), "len");
+ outMsg.writeBeingId(being->getId(), "account id");
+ FOR_EACH (std::vector<ShopItem*>::const_iterator, it, items)
+ {
+ ShopItem *const item = *it;
+ const int usedQuantity = item->getUsedQuantity();
+ if (!usedQuantity)
+ continue;
+ item->increaseQuantity(usedQuantity);
+ item->increaseUsedQuantity(-usedQuantity);
+ item->update();
+ outMsg.writeInt16(CAST_S16(usedQuantity), "amount");
+ outMsg.writeInt16(CAST_S16(item->getInvIndex()), "index");
+ }
+}
+
void VendingHandler::buy2(const Being *const being,
const int vendId,
const int index,
diff --git a/src/net/eathena/vendinghandler.h b/src/net/eathena/vendinghandler.h
index b824a8d8e..307c93ad9 100644
--- a/src/net/eathena/vendinghandler.h
+++ b/src/net/eathena/vendinghandler.h
@@ -45,6 +45,10 @@ class VendingHandler final : public Net::VendingHandler
const int index,
const int amount) const override final;
+ void buyItems(const Being *const being,
+ const std::vector<ShopItem*> &items) const
+ override final;
+
void createShop(const std::string &name,
const bool flag,
const std::vector<ShopItem*> &items) const
diff --git a/src/net/eathena/vendingrecv.cpp b/src/net/eathena/vendingrecv.cpp
index 468143dfd..d3b625159 100644
--- a/src/net/eathena/vendingrecv.cpp
+++ b/src/net/eathena/vendingrecv.cpp
@@ -98,7 +98,7 @@ void VendingRecv::processItemsList(Net::MessageIn &msg)
if (!being)
return;
int cards[maxCards];
- CREATEWIDGETV(mBuyDialog, BuyDialog, being->getName());
+ CREATEWIDGETV(mBuyDialog, BuyDialog, being);
mBuyDialog->setMoney(PlayerInfo::getAttribute(Attributes::MONEY));
if (msg.getVersion() >= 20100105)
msg.readInt32("vender id");