From 9e48f292f14fe96c98b5cfe18a32bcb1bc3d7c24 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 5 Sep 2017 01:03:01 +0300 Subject: Fix adding stackable items to mail. --- src/resources/inventory/inventory.cpp | 15 +++++++++++++++ src/resources/inventory/inventory.h | 2 ++ 2 files changed, 17 insertions(+) (limited to 'src/resources') diff --git a/src/resources/inventory/inventory.cpp b/src/resources/inventory/inventory.cpp index 7363bdd30..d256ea9ac 100644 --- a/src/resources/inventory/inventory.cpp +++ b/src/resources/inventory/inventory.cpp @@ -420,6 +420,21 @@ int Inventory::findIndexByTag(const int tag) const return -1; } +Item *Inventory::findItemByTag(const int tag) const +{ + for (unsigned i = 0; i < mSize; i++) + { + Item *const item = mItems[i]; + if (item != nullptr && + item->mTag == tag) + { + return item; + } + } + + return nullptr; +} + bool Inventory::addVirtualItem(const Item *const item, int index, const int amount) diff --git a/src/resources/inventory/inventory.h b/src/resources/inventory/inventory.h index a7b1e8e73..573a0f5c0 100644 --- a/src/resources/inventory/inventory.h +++ b/src/resources/inventory/inventory.h @@ -189,6 +189,8 @@ class Inventory notfinal int findIndexByTag(const int tag) const; + Item *findItemByTag(const int tag) const; + virtual bool addVirtualItem(const Item *const item, int index, const int amount); -- cgit v1.2.3-70-g09d2