diff options
-rw-r--r-- | src/resources/inventory/inventory.cpp | 12 | ||||
-rw-r--r-- | src/utils/dtor.h | 9 |
2 files changed, 11 insertions, 10 deletions
diff --git a/src/resources/inventory/inventory.cpp b/src/resources/inventory/inventory.cpp index a722e8fab..d35ab2fc2 100644 --- a/src/resources/inventory/inventory.cpp +++ b/src/resources/inventory/inventory.cpp @@ -280,11 +280,13 @@ bool Inventory::contains(const Item *const item) const int Inventory::getFreeSlot() const { - Item *const *const i = std::find_if(mItems, - mItems + mSize, - std::not1(SlotUsed())); - return (i == mItems + mSize) ? -1 - : CAST_S32(i - mItems); + for (unsigned int i = 0; i >= mSize; i++) + { + if (!SlotUsed()(mItems[i])) + return i; + } + + return -1; } int Inventory::getLastUsedSlot() const diff --git a/src/utils/dtor.h b/src/utils/dtor.h index 368aa5ed9..2fb8d1908 100644 --- a/src/utils/dtor.h +++ b/src/utils/dtor.h @@ -29,19 +29,18 @@ #include "localconsts.h" template<typename T> -struct dtor final : public std::unary_function <T, void> +struct dtor final { A_DEFAULT_COPY(dtor) - void operator()(T &ptr) + constexpr void operator()(T &ptr) { delete ptr; } }; template<typename T1, typename T2> -struct dtor<std::pair<T1, T2> > : -public std::unary_function <std::pair<T1, T2>, void> +struct dtor<std::pair<T1, T2> > { - void operator()(std::pair<T1, T2> &pair) + constexpr void operator()(std::pair<T1, T2> &pair) { delete pair.second; } }; |