summaryrefslogtreecommitdiffstats
path: root/source/Player.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--source/Player.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/source/Player.cpp b/source/Player.cpp
index c7784c1b0..708eca9f4 100644
--- a/source/Player.cpp
+++ b/source/Player.cpp
@@ -443,6 +443,11 @@ void cPlayer::CloseWindow(char a_WindowType)
if (m_CurrentWindow == m_InventoryWindow)
{
// The inventory window must not be closed and must not be even sent a close packet
+ if (IsDraggingItem()) // But we need to check if player is holding anything
+ {
+ LOGD("Player holds item in inventory window! Dropping it...");
+ TossItem(true, GetDraggingItem().m_ItemCount);
+ }
return;
}
@@ -791,10 +796,12 @@ void cPlayer::TossItem(
cItem & Item = GetDraggingItem();
if (!Item.IsEmpty())
{
+ char OriginalItemAmount = Item.m_ItemCount;
+ Item.m_ItemCount = MIN(OriginalItemAmount, a_Amount);
Drops.push_back(Item);
- if (Item.m_ItemCount > a_Amount)
+ if (OriginalItemAmount > a_Amount)
{
- Item.m_ItemCount -= (char)a_Amount;
+ Item.m_ItemCount = OriginalItemAmount - (char)a_Amount;
}
else
{