From af5fde1f88bd5c8d0e11b59d73f6c76610c14acf Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 24 Aug 2017 21:40:32 +0300 Subject: Add into inventory method for set tag to item at given index. --- src/resources/inventory/inventory.cpp | 14 ++++++++++++++ src/resources/inventory/inventory.h | 3 +++ 2 files changed, 17 insertions(+) (limited to 'src/resources') diff --git a/src/resources/inventory/inventory.cpp b/src/resources/inventory/inventory.cpp index b7aa39e91..dd88da99c 100644 --- a/src/resources/inventory/inventory.cpp +++ b/src/resources/inventory/inventory.cpp @@ -220,6 +220,20 @@ void Inventory::setOptions(const int index, item1->setOptions(options); } +void Inventory::setTag(const int index, + const int tag) +{ + if (index < 0 || index >= CAST_S32(mSize)) + { + reportAlways("Warning: invalid inventory index: %d", + index); + return; + } + Item *const item1 = mItems[index]; + if (item1 != nullptr) + item1->setTag(tag); +} + void Inventory::clear() { for (unsigned i = 0; i < mSize; i++) diff --git a/src/resources/inventory/inventory.h b/src/resources/inventory/inventory.h index 5180e49e1..a7b1e8e73 100644 --- a/src/resources/inventory/inventory.h +++ b/src/resources/inventory/inventory.h @@ -126,6 +126,9 @@ class Inventory notfinal void setOptions(const int index, const ItemOptionsList *const options); + void setTag(const int index, + const int tag); + void moveItem(const int index1, const int index2); -- cgit v1.2.3-60-g2f50