summaryrefslogtreecommitdiff
path: root/src/inventory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/inventory.cpp')
-rw-r--r--src/inventory.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/inventory.cpp b/src/inventory.cpp
index 29df424e1..3240f9d8f 100644
--- a/src/inventory.cpp
+++ b/src/inventory.cpp
@@ -443,3 +443,19 @@ void Inventory::restoreVirtuals()
}
mVirtualRemove.clear();
}
+
+void Inventory::virtualRestore(const Item *const item,
+ const int amount)
+{
+ const int index = item->getTag();
+ const IntMapCIter it = mVirtualRemove.find(index);
+ if (it != mVirtualRemove.end())
+ {
+ mVirtualRemove[index] -= amount;
+ if (mVirtualRemove[index] < 0)
+ mVirtualRemove.erase(index);
+ if (index < 0 || index >= static_cast<int>(mSize) || !mItems[index])
+ return;
+ mItems[index]->mQuantity += amount;
+ }
+}