summaryrefslogtreecommitdiff
path: root/src/resources/inventory/inventory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/resources/inventory/inventory.cpp')
-rw-r--r--src/resources/inventory/inventory.cpp29
1 files changed, 26 insertions, 3 deletions
diff --git a/src/resources/inventory/inventory.cpp b/src/resources/inventory/inventory.cpp
index 180a1b4f3..c73d9d8b6 100644
--- a/src/resources/inventory/inventory.cpp
+++ b/src/resources/inventory/inventory.cpp
@@ -372,7 +372,8 @@ int Inventory::findIndexByTag(const int tag) const
}
bool Inventory::addVirtualItem(const Item *const item,
- int index)
+ int index,
+ const int amount)
{
if (item && !PlayerInfo::isItemProtected(item->getId()))
{
@@ -383,7 +384,7 @@ bool Inventory::addVirtualItem(const Item *const item,
setItem(index,
item->getId(),
item->getType(),
- 1,
+ amount,
1,
item->getColor(),
item->getIdentified(),
@@ -396,7 +397,7 @@ bool Inventory::addVirtualItem(const Item *const item,
{
index = addItem(item->getId(),
item->getType(),
- 1,
+ amount,
1,
item->getColor(),
item->getIdentified(),
@@ -465,3 +466,25 @@ void Inventory::virtualRestore(const Item *const item,
mItems[index]->mQuantity += amount;
}
}
+
+void Inventory::moveItem(const int index1,
+ const int index2)
+{
+ if (index1 < 0 ||
+ index1 >= static_cast<int>(mSize) ||
+ index2 < 0 ||
+ index2 >= static_cast<int>(mSize))
+ {
+ return;
+ }
+
+ Item *const item1 = mItems[index1];
+ Item *const item2 = mItems[index2];
+ if (item1)
+ item1->setInvIndex(index2);
+ if (item2)
+ item2->setInvIndex(index1);
+ mItems[index1] = item2;
+ mItems[index2] = item1;
+ distributeSlotsChangedEvent();
+}