summaryrefslogtreecommitdiff
path: root/src/net/eathena/npchandler.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-11-04 02:03:03 +0300
committerAndrei Karas <akaras@inbox.ru>2015-11-04 02:40:04 +0300
commit5cfc73dc5c0093a96c45f604a028ecca21a01af8 (patch)
tree4916b602dfa9b5caee28252515a45215008b8d71 /src/net/eathena/npchandler.cpp
parent2288a403ad4377fbb552243e805aaf0b5a4f5a0d (diff)
downloadplus-5cfc73dc5c0093a96c45f604a028ecca21a01af8.tar.gz
plus-5cfc73dc5c0093a96c45f604a028ecca21a01af8.tar.bz2
plus-5cfc73dc5c0093a96c45f604a028ecca21a01af8.tar.xz
plus-5cfc73dc5c0093a96c45f604a028ecca21a01af8.zip
Allow sell to npc many items at one time (hercules).halloween2015
Diffstat (limited to 'src/net/eathena/npchandler.cpp')
-rw-r--r--src/net/eathena/npchandler.cpp33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/net/eathena/npchandler.cpp b/src/net/eathena/npchandler.cpp
index dc01d512c..9b09d8799 100644
--- a/src/net/eathena/npchandler.cpp
+++ b/src/net/eathena/npchandler.cpp
@@ -187,10 +187,41 @@ void NpcHandler::sellItem(const BeingId beingId A_UNUSED,
createOutPacket(CMSG_NPC_SELL_REQUEST);
outMsg.writeInt16(8, "len");
outMsg.writeInt16(static_cast<int16_t>(itemId + INVENTORY_OFFSET),
- "item id");
+ "item index");
outMsg.writeInt16(static_cast<int16_t>(amount), "amount");
}
+void NpcHandler::sellItems(std::vector<ShopItem*> &items) const
+{
+ const int pairSize = 4;
+ int cnt = 0;
+
+ FOR_EACH (std::vector<ShopItem*>::iterator, it, items)
+ {
+ ShopItem *const item = *it;
+ const int usedQuantity = item->getUsedQuantity();
+ if (!usedQuantity)
+ continue;
+ cnt ++;
+ }
+
+ createOutPacket(CMSG_NPC_SELL_REQUEST);
+ outMsg.writeInt16(static_cast<int16_t>(4 + pairSize * cnt), "len");
+ FOR_EACH (std::vector<ShopItem*>::iterator, it, items)
+ {
+ ShopItem *const item = *it;
+ const int usedQuantity = item->getUsedQuantity();
+ if (!usedQuantity)
+ continue;
+ item->increaseUsedQuantity(-usedQuantity);
+ item->update();
+ outMsg.writeInt16(static_cast<int16_t>(
+ item->getCurrentInvIndex() + INVENTORY_OFFSET),
+ "item index");
+ outMsg.writeInt16(static_cast<int16_t>(usedQuantity), "amount");
+ }
+}
+
void NpcHandler::completeProgressBar() const
{
createOutPacket(CMSG_NPC_COMPLETE_PROGRESS_BAR);