X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Finventory.cpp;h=5e39a41a6bc42527351824d6b63c4fca99baaca4;hb=ab45133ab4826359ca9a5ed50b68150eb462c8ef;hp=f4a4f280863133566fc4f6f6b7e1dfa201557fb8;hpb=037b2591971d752e67fa7d47095b996b3f56da5a;p=oweals%2Fminetest.git diff --git a/src/inventory.cpp b/src/inventory.cpp index f4a4f2808..5e39a41a6 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -19,7 +19,6 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "inventory.h" #include "serialization.h" -#include "utility.h" #include "debug.h" #include #include "log.h" @@ -27,6 +26,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "strfnd.h" #include "content_mapnode.h" // For loading legacy MaterialItems #include "nameidmapping.h" // For loading legacy MaterialItems +#include "util/serialize.h" +#include "util/string.h" /* ItemStack @@ -430,6 +431,7 @@ InventoryList::InventoryList(std::string name, u32 size, IItemDefManager *itemde { m_name = name; m_size = size; + m_width = 0; m_itemdef = itemdef; clearItems(); //m_dirty = false; @@ -458,6 +460,11 @@ void InventoryList::setSize(u32 newsize) m_size = newsize; } +void InventoryList::setWidth(u32 newwidth) +{ + m_width = newwidth; +} + void InventoryList::setName(const std::string &name) { m_name = name; @@ -467,6 +474,8 @@ void InventoryList::serialize(std::ostream &os) const { //os.imbue(std::locale("C")); + os<<"Width "<> m_width; + if (iss.fail()) + throw SerializationError("incorrect width property"); + } else if(name == "Item") { if(item_i > getSize() - 1) @@ -526,10 +542,6 @@ void InventoryList::deSerialize(std::istream &is) throw SerializationError("too many items"); m_items[item_i++].clear(); } - else - { - throw SerializationError("Unknown inventory identifier"); - } } } @@ -542,6 +554,7 @@ InventoryList & InventoryList::operator = (const InventoryList &other) { m_items = other.m_items; m_size = other.m_size; + m_width = other.m_width; m_name = other.m_name; m_itemdef = other.m_itemdef; //setDirty(true); @@ -559,6 +572,11 @@ u32 InventoryList::getSize() const return m_items.size(); } +u32 InventoryList::getWidth() const +{ + return m_width; +} + u32 InventoryList::getUsedSlots() const { u32 num = 0; @@ -885,10 +903,6 @@ void Inventory::deSerialize(std::istream &is) m_lists.push_back(list); } - else - { - throw SerializationError("Unknown inventory identifier"); - } } }