summaryrefslogtreecommitdiff
path: root/src/inventory.cpp
diff options
context:
space:
mode:
authorJoshua Langley <joshlangley[at]optusnet.com.au>2007-08-14 05:59:52 +0000
committerJoshua Langley <joshlangley[at]optusnet.com.au>2007-08-14 05:59:52 +0000
commit0601642d8b3aa2c7aa365e27aa3ef2459553c3fd (patch)
treee2c4a93c3aca4b35b69857b17b722c3260b4c3d1 /src/inventory.cpp
parent68f069fea3182c6d5720df03f1d63de38f14c31d (diff)
downloadmana-0601642d8b3aa2c7aa365e27aa3ef2459553c3fd.tar.gz
mana-0601642d8b3aa2c7aa365e27aa3ef2459553c3fd.tar.bz2
mana-0601642d8b3aa2c7aa365e27aa3ef2459553c3fd.tar.xz
mana-0601642d8b3aa2c7aa365e27aa3ef2459553c3fd.zip
mantis_id:129 - Inventory Window Slots Added.
Diffstat (limited to 'src/inventory.cpp')
-rw-r--r--src/inventory.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/inventory.cpp b/src/inventory.cpp
index 11c52421..d9bd79f8 100644
--- a/src/inventory.cpp
+++ b/src/inventory.cpp
@@ -30,7 +30,7 @@
struct SlotUsed : public std::unary_function<Item, bool>
{
bool operator()(const Item &item) const {
- return (item.getId() != -1 && item.getQuantity() > 0);
+ return (item.getId() && item.getQuantity());
}
};
@@ -72,8 +72,7 @@ void Inventory::addItem(int index, int id, int quantity)
void Inventory::clear()
{
for (int i = 0; i < INVENTORY_SIZE; i++) {
- mItems[i].setId(-1);
- mItems[i].setQuantity(0);
+ removeItemIndex(i);
}
}
@@ -81,12 +80,17 @@ void Inventory::removeItem(int id)
{
for (int i = 0; i < INVENTORY_SIZE; i++) {
if (mItems[i].getId() == id) {
- mItems[i].setId(-1);
- mItems[i].setQuantity(0);
+ removeItemIndex(i);
}
}
}
+void Inventory::removeItemIndex(int index)
+{
+ mItems[index].setId(0);
+ mItems[index].setQuantity(0);
+}
+
bool Inventory::contains(Item *item)
{
for (int i = 0; i < INVENTORY_SIZE; i++) {