void ItemStack::serialize(std::ostream &os) const
{
- DSTACK(__FUNCTION_NAME);
+ DSTACK(FUNCTION_NAME);
if(empty())
return;
void ItemStack::deSerialize(std::istream &is, IItemDefManager *itemdef)
{
- DSTACK(__FUNCTION_NAME);
+ DSTACK(FUNCTION_NAME);
clear();
std::getline(is, tmp, ' ');
if(!tmp.empty())
throw SerializationError("Unexpected text after item name");
-
+
if(name == "MaterialItem")
{
// Obsoleted on 2011-07-30
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++)
if(newitem.empty())
return newitem;
-
+
/*
First try to find if it could be added to some existing items
*/
return true;
for(std::vector<ItemStack>::const_reverse_iterator
i = m_items.rbegin();
- i != m_items.rend(); i++)
+ i != m_items.rend(); ++i)
{
if(count == 0)
break;
ItemStack removed;
for(std::vector<ItemStack>::reverse_iterator
i = m_items.rbegin();
- i != m_items.rend(); i++)
+ i != m_items.rend(); ++i)
{
if(i->name == item.name)
{
return;
// Try to add the item to destination list
- u32 oldcount = item1.count;
u32 dest_size = dest->getSize();
// First try all the non-empty slots
for (u32 dest_i = 0; dest_i < dest_size; dest_i++) {
}
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;
// 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.