diff options
author | Andrei Karas <akaras@inbox.ru> | 2018-08-06 23:35:58 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2018-08-06 23:35:58 +0300 |
commit | 5a6b02b6aba646816a7d27a85dd6724de554a157 (patch) | |
tree | 77f5d1c6b94f8a549b7be20c1188091a4b3cd0f2 /src/net | |
parent | 3b5390eee9c3e031867d3acfce574f1993d46b76 (diff) | |
download | manaplus-5a6b02b6aba646816a7d27a85dd6724de554a157.tar.gz manaplus-5a6b02b6aba646816a7d27a85dd6724de554a157.tar.bz2 manaplus-5a6b02b6aba646816a7d27a85dd6724de554a157.tar.xz manaplus-5a6b02b6aba646816a7d27a85dd6724de554a157.zip |
Play item usage sound to every player around.
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/eathena/inventoryrecv.cpp | 34 |
1 files changed, 25 insertions, 9 deletions
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") } |