Fixed issues with pickups.
* Now when picking up max. stack amount is checked. * Added cInventory::AddItemAnyAmount() which will not fail if it cannot add all items (it will just modify amount) * If there is no space in inventory and picking up stacked items, it will try to fill stacks already in inventory, partially picking up the item. * When closing inventory player will drop any items it's currently 'dragging' git-svn-id: http://mc-server.googlecode.com/svn/trunk@1008 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user