diff options
author | Nikos Giagtzoglou <gnikos21@yahoo.gr> | 2008-11-22 11:43:53 +0100 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2008-11-22 11:43:53 +0100 |
commit | 991389a535985af072f830b89e5113da82650fe5 (patch) | |
tree | 071ec4153b820a9c6404d5845443403b3cda83fb /src/inventory.cpp | |
parent | c79d12b91ef0e49878a8e3f10486b910184acc69 (diff) | |
download | mana-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.cpp | 11 |
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; +} |