summaryrefslogtreecommitdiff
path: root/src/inventory.cpp
diff options
context:
space:
mode:
authorest31 <MTest31@outlook.com>2015-08-19 02:28:37 +0200
committerest31 <MTest31@outlook.com>2015-08-19 03:42:00 +0200
commit1fadf7f21eb5fd7a09037d92f87cd0154e9306c1 (patch)
tree06a2557c71b7cf915660ac51a5c9142899057015 /src/inventory.cpp
parentc2d23ff9ccf04dd0e4c2ba8a8026857c034bc947 (diff)
downloadminetest-1fadf7f21eb5fd7a09037d92f87cd0154e9306c1.tar.gz
minetest-1fadf7f21eb5fd7a09037d92f87cd0154e9306c1.tar.bz2
minetest-1fadf7f21eb5fd7a09037d92f87cd0154e9306c1.zip
Fix inventory replace bug
Diffstat (limited to 'src/inventory.cpp')
-rw-r--r--src/inventory.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/inventory.cpp b/src/inventory.cpp
index 6c7c8cdd1..af8b1b301 100644
--- a/src/inventory.cpp
+++ b/src/inventory.cpp
@@ -163,7 +163,7 @@ void ItemStack::deSerialize(std::istream &is, IItemDefManager *itemdef)
std::getline(is, tmp, ' ');
if(!tmp.empty())
throw SerializationError("Unexpected text after item name");
-
+
if(name == "MaterialItem")
{
// Obsoleted on 2011-07-30
@@ -478,7 +478,7 @@ void InventoryList::setName(const std::string &name)
void InventoryList::serialize(std::ostream &os) const
{
//os.imbue(std::locale("C"));
-
+
os<<"Width "<<m_width<<"\n";
for(u32 i=0; i<m_items.size(); i++)
@@ -653,7 +653,7 @@ ItemStack InventoryList::addItem(const ItemStack &newitem_)
if(newitem.empty())
return newitem;
-
+
/*
First try to find if it could be added to some existing items
*/
@@ -818,7 +818,7 @@ void InventoryList::moveItemSomewhere(u32 i, InventoryList *dest, u32 count)
}
u32 InventoryList::moveItem(u32 i, InventoryList *dest, u32 dest_i,
- u32 count, bool swap_if_needed)
+ u32 count, bool swap_if_needed, bool *did_swap)
{
if(this == dest && i == dest_i)
return count;
@@ -850,6 +850,10 @@ u32 InventoryList::moveItem(u32 i, InventoryList *dest, u32 dest_i,
// If olditem is returned, nothing was added.
// Swap the items
if (nothing_added && swap_if_needed) {
+ // Tell that we swapped
+ if (did_swap != NULL) {
+ *did_swap = true;
+ }
// Take item from source list
item1 = changeItem(i, ItemStack());
// Adding was not possible, swap the items.