diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-03-23 21:59:21 +0100 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-03-23 22:00:09 +0100 |
commit | 99e8a3fd77b63a029fe02dcf771b6af1aad252ed (patch) | |
tree | 03c296d1f89859aae35336dfe2f58df09d256fd3 /src/inventory.cpp | |
parent | fa8a4bf49100c0a1d5b96e00803f43bbbb861100 (diff) | |
parent | 347452b9b69ef3af29c577b7751082822e900c01 (diff) | |
download | mana-99e8a3fd77b63a029fe02dcf771b6af1aad252ed.tar.gz mana-99e8a3fd77b63a029fe02dcf771b6af1aad252ed.tar.bz2 mana-99e8a3fd77b63a029fe02dcf771b6af1aad252ed.tar.xz mana-99e8a3fd77b63a029fe02dcf771b6af1aad252ed.zip |
Merge branch 'aethyra/master'
Conflicts:
Many files.
Diffstat (limited to 'src/inventory.cpp')
-rw-r--r-- | src/inventory.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/inventory.cpp b/src/inventory.cpp index 3ca26e1e..5092fe3c 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -33,8 +33,9 @@ struct SlotUsed : public std::unary_function<Item*, bool> } }; -Inventory::Inventory(int size): - mSize(size) +Inventory::Inventory(int size, int offset): + mSize(size), + mOffset(offset) { mItems = new Item*[mSize]; std::fill_n(mItems, mSize, (Item*) 0); @@ -50,7 +51,7 @@ Inventory::~Inventory() Item* Inventory::getItem(int index) const { - if (index < 0 || index >= INVENTORY_SIZE || !mItems[index] || mItems[index]->getQuantity() <= 0) + if (index < 0 || index >= mSize || !mItems[index] || mItems[index]->getQuantity() <= 0) return 0; return mItems[index]; @@ -126,7 +127,7 @@ bool Inventory::contains(Item *item) const int Inventory::getFreeSlot() const { - Item **i = std::find_if(mItems + 2, mItems + mSize, + Item **i = std::find_if(mItems + mOffset, mItems + mSize, std::not1(SlotUsed())); return (i == mItems + mSize) ? -1 : (i - mItems); } @@ -147,5 +148,5 @@ int Inventory::getLastUsedSlot() const int Inventory::getInventorySize() const { - return INVENTORY_SIZE - 2; + return mSize - mOffset; } |