summaryrefslogtreecommitdiff
path: root/src/inventory.cpp
diff options
context:
space:
mode:
authorNikos Giagtzoglou <gnikos21@yahoo.gr>2008-11-22 11:43:53 +0100
committerBjørn Lindeijer <bjorn@lindeijer.nl>2008-11-22 11:43:53 +0100
commit991389a535985af072f830b89e5113da82650fe5 (patch)
tree071ec4153b820a9c6404d5845443403b3cda83fb /src/inventory.cpp
parentc79d12b91ef0e49878a8e3f10486b910184acc69 (diff)
downloadmana-client-991389a535985af072f830b89e5113da82650fe5.tar.gz
mana-client-991389a535985af072f830b89e5113da82650fe5.tar.bz2
mana-client-991389a535985af072f830b89e5113da82650fe5.tar.xz
mana-client-991389a535985af072f830b89e5113da82650fe5.zip
Inventory window now displays amount of slots used
Patch by Nikos, with some improvements by vargavind.
Diffstat (limited to 'src/inventory.cpp')
-rw-r--r--src/inventory.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/inventory.cpp b/src/inventory.cpp
index 5633f430..938d23d3 100644
--- a/src/inventory.cpp
+++ b/src/inventory.cpp
@@ -132,19 +132,19 @@ bool Inventory::contains(Item *item) const
return false;
}
-int Inventory::getFreeSlot()
+int Inventory::getFreeSlot() const
{
Item **i = std::find_if(mItems + 2, mItems + INVENTORY_SIZE,
std::not1(SlotUsed()));
return (i == mItems + INVENTORY_SIZE) ? -1 : (i - mItems);
}
-int Inventory::getNumberOfSlotsUsed()
+int Inventory::getNumberOfSlotsUsed() const
{
return count_if(mItems, mItems + INVENTORY_SIZE, SlotUsed());
}
-int Inventory::getLastUsedSlot()
+int Inventory::getLastUsedSlot() const
{
for (int i = INVENTORY_SIZE - 1; i >= 0; i--) {
if (SlotUsed()(mItems[i])) {
@@ -154,3 +154,8 @@ int Inventory::getLastUsedSlot()
return -1;
}
+
+int Inventory::getInventorySize() const
+{
+ return INVENTORY_SIZE - 2;
+}