From 91e74d8f1dc3f1fe01cb65822913488f5cbc5657 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 8 Aug 2017 20:18:08 +0300 Subject: Use size_t type for index in itemshortcut. --- src/gui/shortcut/itemshortcut.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/gui/shortcut/itemshortcut.cpp') diff --git a/src/gui/shortcut/itemshortcut.cpp b/src/gui/shortcut/itemshortcut.cpp index 2f80f6759..7139fd74e 100644 --- a/src/gui/shortcut/itemshortcut.cpp +++ b/src/gui/shortcut/itemshortcut.cpp @@ -147,7 +147,7 @@ void ItemShortcut::clear() } } -void ItemShortcut::useItem(const int index) const +void ItemShortcut::useItem(const size_t index) const { const Inventory *const inv = PlayerInfo::getInventory(); if (inv == nullptr) @@ -177,7 +177,7 @@ void ItemShortcut::useItem(const int index) const } } -void ItemShortcut::equipItem(const int index) const +void ItemShortcut::equipItem(const size_t index) const { const Inventory *const inv = PlayerInfo::getInventory(); if (inv == nullptr) @@ -197,7 +197,7 @@ void ItemShortcut::equipItem(const int index) const } } } -void ItemShortcut::unequipItem(const int index) const +void ItemShortcut::unequipItem(const size_t index) const { const Inventory *const inv = PlayerInfo::getInventory(); if (inv == nullptr) @@ -232,14 +232,14 @@ void ItemShortcut::setItemSelected(const Item *const item) } } -void ItemShortcut::setItem(const int index) +void ItemShortcut::setItem(const size_t index) { mItems[index] = mItemSelected; mItemColors[index] = mItemColorSelected; save(); } -void ItemShortcut::setItem(const int index, +void ItemShortcut::setItem(const size_t index, const int item, const ItemColor color) { @@ -256,11 +256,11 @@ void ItemShortcut::setItemFast(const size_t index, mItemColors[index] = color; } -void ItemShortcut::swap(const int index1, const int index2) +void ItemShortcut::swap(const size_t index1, + const size_t index2) { - if (index1 < 0 || index2 < 0 - || CAST_U32(index1) >= SHORTCUT_ITEMS - || CAST_U32(index2) >= SHORTCUT_ITEMS) + if (CAST_U32(index1) >= SHORTCUT_ITEMS || + CAST_U32(index2) >= SHORTCUT_ITEMS) { return; } @@ -285,5 +285,5 @@ size_t ItemShortcut::getFreeIndex() const if (mItems[i] < 0) return i; } - return -1; + return SHORTCUT_ITEMS; } -- cgit v1.2.3-60-g2f50