summaryrefslogtreecommitdiff
path: root/src/inventory.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-11-03 15:54:23 +0300
committerAndrei Karas <akaras@inbox.ru>2015-11-03 15:54:23 +0300
commitcd636f7e367cfb7fa2c348d00071301a480d62c3 (patch)
tree2ed2f2565362aec0b02a1de0f4bdc5d6f6c3bc6e /src/inventory.cpp
parentb86f75e0faf7d646d5414cb6a6893bbb07131315 (diff)
downloadManaVerse-cd636f7e367cfb7fa2c348d00071301a480d62c3.tar.gz
ManaVerse-cd636f7e367cfb7fa2c348d00071301a480d62c3.tar.bz2
ManaVerse-cd636f7e367cfb7fa2c348d00071301a480d62c3.tar.xz
ManaVerse-cd636f7e367cfb7fa2c348d00071301a480d62c3.zip
Fix removing items from npc inventory (restore amount in player inventory)
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;
+ }
+}