aboutsummaryrefslogtreecommitdiff
path: root/src/inventory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/inventory.cpp')
-rw-r--r--src/inventory.cpp23
1 files changed, 7 insertions, 16 deletions
diff --git a/src/inventory.cpp b/src/inventory.cpp
index fc1aaf371..d14b12f9d 100644
--- a/src/inventory.cpp
+++ b/src/inventory.cpp
@@ -460,7 +460,6 @@ void InventoryList::deSerialize(std::istream &is)
std::getline(is, line, '\n');
std::istringstream iss(line);
- //iss.imbue(std::locale("C"));
std::string name;
std::getline(iss, name, ' ');
@@ -561,11 +560,6 @@ u32 InventoryList::getUsedSlots() const
return num;
}
-u32 InventoryList::getFreeSlots() const
-{
- return getSize() - getUsedSlots();
-}
-
const ItemStack& InventoryList::getItem(u32 i) const
{
assert(i < m_size); // Pre-condition
@@ -938,19 +932,16 @@ void Inventory::deSerialize(std::istream &is)
InventoryList * Inventory::addList(const std::string &name, u32 size)
{
setModified();
+
+ // Remove existing lists
s32 i = getListIndex(name);
- if(i != -1)
- {
- if(m_lists[i]->getSize() != size)
- {
- delete m_lists[i];
- m_lists[i] = new InventoryList(name, size, m_itemdef);
- m_lists[i]->setModified();
- }
+ if (i != -1) {
+ delete m_lists[i];
+ m_lists[i] = new InventoryList(name, size, m_itemdef);
+ m_lists[i]->setModified();
return m_lists[i];
}
-
//don't create list with invalid name
if (name.find(' ') != std::string::npos)
return nullptr;
@@ -999,7 +990,7 @@ const InventoryList *Inventory::getList(const std::string &name) const
return m_lists[i];
}
-const s32 Inventory::getListIndex(const std::string &name) const
+s32 Inventory::getListIndex(const std::string &name) const
{
for(u32 i=0; i<m_lists.size(); i++)
{