From cf87169737fdeeee7d4b160688bbed7194e46147 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Fri, 24 May 2013 07:30:39 +0000 Subject: Refactored cInventory to use cItemGrid for the actual Storage This makes the API more orthogonal and is easier to use in the plugins. Also changes in the inventory are now propagated to the needed places (armor updates to BroadcastEntityEquipment etc.) even when the inventory is changed by a plugin. git-svn-id: http://mc-server.googlecode.com/svn/trunk@1503 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/Pickup.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'source/Pickup.cpp') diff --git a/source/Pickup.cpp b/source/Pickup.cpp index bf48daf82..19959efa3 100644 --- a/source/Pickup.cpp +++ b/source/Pickup.cpp @@ -149,17 +149,17 @@ bool cPickup::CollectedBy(cPlayer * a_Dest) return false; } - if (a_Dest->GetInventory().AddItemAnyAmount(m_Item)) + int NumAdded = a_Dest->GetInventory().AddItem(m_Item); + if (NumAdded > 0) { + m_Item.m_ItemCount -= NumAdded; m_World->BroadcastCollectPickup(*this, *a_Dest); - m_bCollected = true; - m_Timer = 0; - if (m_Item.m_ItemCount != 0) + if (m_Item.m_ItemCount == 0) { - cItems Pickup; - Pickup.push_back(cItem(m_Item)); - m_World->SpawnItemPickups(Pickup, GetPosX(), GetPosY(), GetPosZ()); + // All of the pickup has been collected, schedule the pickup for destroying + m_bCollected = true; } + m_Timer = 0; return true; } -- cgit v1.2.3