summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gui/widgets/itemcontainer.cpp48
-rw-r--r--src/inventory.cpp2
2 files changed, 46 insertions, 4 deletions
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index b7af26a95..ad9f868ad 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -795,11 +795,50 @@ void ItemContainer::mouseReleased(MouseEvent &event)
}
return;
}
-#ifdef EATHENA_SUPPORT
- else if (src == DRAGDROP_SOURCE_NPC || src == DRAGDROP_SOURCE_MAIL)
-#else
else if (src == DRAGDROP_SOURCE_NPC)
-#endif
+ {
+ if (dst == DRAGDROP_SOURCE_NPC)
+ {
+ const Item *const item = mInventory->getItem(
+ dragDrop.getTag());
+ const int index = getSlotByXY(event.getX(), event.getY());
+ if (index == Inventory::NO_SLOT_INDEX)
+ {
+ mInventory->removeItemAt(dragDrop.getTag());
+ return;
+ }
+ mInventory->removeItemAt(index);
+ mInventory->setItem(index,
+ item->getId(),
+ item->getType(),
+ 1,
+ 1,
+ item->getColor(),
+ item->getIdentified(),
+ item->getDamaged(),
+ item->getFavorite(),
+ Equipm_false,
+ Equipped_false);
+ Item *const item2 = mInventory->getItem(index);
+ if (item2)
+ item2->setTag(item->getTag());
+ mInventory->removeItemAt(dragDrop.getTag());
+ }
+ else
+ {
+ inventory = PlayerInfo::getInventory();
+ if (inventory)
+ {
+ const Item *const item = inventory->getItem(
+ dragDrop.getTag());
+ if (item)
+ mInventory->removeItemAt(dragDrop.getTag());
+ }
+ return;
+ }
+ }
+#ifdef EATHENA_SUPPORT
+ else if (src == DRAGDROP_SOURCE_MAIL)
{
inventory = PlayerInfo::getInventory();
if (inventory)
@@ -810,6 +849,7 @@ void ItemContainer::mouseReleased(MouseEvent &event)
}
return;
}
+#endif
if (inventory)
{
diff --git a/src/inventory.cpp b/src/inventory.cpp
index 5ee1e34c0..61434754f 100644
--- a/src/inventory.cpp
+++ b/src/inventory.cpp
@@ -199,6 +199,8 @@ void Inventory::removeItem(const int id)
void Inventory::removeItemAt(const int index)
{
+ if (!mItems[index])
+ return;
delete2(mItems[index]);
mUsed--;
if (mUsed < 0) // Already at 0, no need to distribute event