diff options
Diffstat (limited to 'src/inventory.cpp')
-rw-r--r-- | src/inventory.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/inventory.cpp b/src/inventory.cpp index 0a0a29cd5..fda11e40f 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -431,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; @@ -459,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; @@ -468,6 +474,8 @@ 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++) { const ItemStack &item = m_items[i]; @@ -492,6 +500,7 @@ void InventoryList::deSerialize(std::istream &is) clearItems(); u32 item_i = 0; + m_width = 0; for(;;) { @@ -513,6 +522,12 @@ void InventoryList::deSerialize(std::istream &is) { break; } + else if(name == "Width") + { + iss >> m_width; + if (iss.fail()) + throw SerializationError("incorrect width property"); + } else if(name == "Item") { if(item_i > getSize() - 1) @@ -543,6 +558,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); @@ -560,6 +576,11 @@ u32 InventoryList::getSize() const return m_items.size(); } +u32 InventoryList::getWidth() const +{ + return m_width; +} + u32 InventoryList::getUsedSlots() const { u32 num = 0; |