summaryrefslogtreecommitdiff
path: root/src/inventory.cpp
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-03-08 18:40:48 -0600
committerIra Rice <irarice@gmail.com>2009-03-09 00:52:56 -0600
commit5fa3f62d0d6d9cbffeef0f6a2497aae023dbadcf (patch)
treea905c74e059311b5adf10a6eacbe53482d95c380 /src/inventory.cpp
parent6ea994477c58912785729e7922eb90862a1ab13c (diff)
downloadmana-5fa3f62d0d6d9cbffeef0f6a2497aae023dbadcf.tar.gz
mana-5fa3f62d0d6d9cbffeef0f6a2497aae023dbadcf.tar.bz2
mana-5fa3f62d0d6d9cbffeef0f6a2497aae023dbadcf.tar.xz
mana-5fa3f62d0d6d9cbffeef0f6a2497aae023dbadcf.zip
Add an interface for eAthena's storage system
Diffstat (limited to 'src/inventory.cpp')
-rw-r--r--src/inventory.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/inventory.cpp b/src/inventory.cpp
index 4053bc96..d72e0e4a 100644
--- a/src/inventory.cpp
+++ b/src/inventory.cpp
@@ -34,8 +34,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);
@@ -51,7 +52,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];
@@ -127,7 +128,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, mItems + mSize,
std::not1(SlotUsed()));
return (i == mItems + mSize) ? -1 : (i - mItems);
}
@@ -148,5 +149,5 @@ int Inventory::getLastUsedSlot() const
int Inventory::getInventorySize() const
{
- return INVENTORY_SIZE - 2;
+ return mSize - mOffset;
}