diff options
author | sebi.noreply@gmail.com <sebi.noreply@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-10-24 14:48:25 +0200 |
---|---|---|
committer | sebi.noreply@gmail.com <sebi.noreply@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-10-24 14:48:25 +0200 |
commit | e33e9111abe5bb7968f48bd2801bf182754e554c (patch) | |
tree | eece777a96e41238cbe1ecb6e569aa81d94905d2 /source/Player.cpp | |
parent | #grammarnazi: fixed tabs to spaces and alpha-sort (diff) | |
download | cuberite-e33e9111abe5bb7968f48bd2801bf182754e554c.tar cuberite-e33e9111abe5bb7968f48bd2801bf182754e554c.tar.gz cuberite-e33e9111abe5bb7968f48bd2801bf182754e554c.tar.bz2 cuberite-e33e9111abe5bb7968f48bd2801bf182754e554c.tar.lz cuberite-e33e9111abe5bb7968f48bd2801bf182754e554c.tar.xz cuberite-e33e9111abe5bb7968f48bd2801bf182754e554c.tar.zst cuberite-e33e9111abe5bb7968f48bd2801bf182754e554c.zip |
Diffstat (limited to '')
-rw-r--r-- | source/Player.cpp | 11 |
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 { |