diff options
Diffstat (limited to 'src/inventory.cpp')
-rw-r--r-- | src/inventory.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/inventory.cpp b/src/inventory.cpp index cdd7b61c..80bc582b 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -37,8 +37,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); @@ -134,11 +135,7 @@ bool Inventory::contains(Item *item) const int Inventory::getFreeSlot() const { -#ifdef TMWSERV_SUPPORT - Item **i = std::find_if(mItems, mItems + mSize, -#else - Item **i = std::find_if(mItems + 2, mItems + mSize, -#endif + Item **i = std::find_if(mItems + mOffset, mItems + mSize, std::not1(SlotUsed())); return (i == mItems + mSize) ? -1 : (i - mItems); } @@ -156,3 +153,8 @@ int Inventory::getLastUsedSlot() const return -1; } + +int Inventory::getInventorySize() const +{ + return mSize - mOffset; +} |