From 5a6b02b6aba646816a7d27a85dd6724de554a157 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 6 Aug 2018 23:35:58 +0300 Subject: Play item usage sound to every player around. --- src/net/eathena/inventoryrecv.cpp | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) (limited to 'src/net') diff --git a/src/net/eathena/inventoryrecv.cpp b/src/net/eathena/inventoryrecv.cpp index 17e79b4da..c17db75d1 100644 --- a/src/net/eathena/inventoryrecv.cpp +++ b/src/net/eathena/inventoryrecv.cpp @@ -22,8 +22,10 @@ #include "net/eathena/inventoryrecv.h" +#include "actormanager.h" #include "notifymanager.h" #include "itemcolormanager.h" +#include "itemsoundmanager.h" #include "being/localplayer.h" @@ -1456,20 +1458,34 @@ void InventoryRecv::processPlayerInventoryUse(Net::MessageIn &msg) ? PlayerInfo::getInventory() : nullptr; const int index = msg.readInt16("index") - INVENTORY_OFFSET; - msg.readItemId("item id"); - msg.readInt32("id?"); + const int itemId = msg.readItemId("item id"); + const BeingId id = msg.readBeingId("account id"); const int amount = msg.readInt16("amount"); - msg.readUInt8("type"); + const uint8_t flag = msg.readUInt8("type"); + Being *const dstBeing = actorManager->findBeing(id); - if (inventory != nullptr) + if (dstBeing == localPlayer) { - if (Item *const item = inventory->getItem(index)) + if (flag == 0) { - if (amount != 0) - item->setQuantity(amount); - else - inventory->removeItemAt(index); + NotifyManager::notify(NotifyTypes::USE_FAILED); + return; } + if (inventory != nullptr) + { + if (Item *const item = inventory->getItem(index)) + { + if (amount != 0) + item->setQuantity(amount); + else + inventory->removeItemAt(index); + } + } + } + else + { + // +++ here can count left items in other player slot + id + amount + ItemSoundManager::playSfx(dstBeing, itemId, ItemSoundEvent::USE); } BLOCK_END("InventoryRecv::processPlayerInventoryUse") } -- cgit v1.2.3-60-g2f50