summaryrefslogtreecommitdiff
path: root/src/gui/shortcut
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-08-08 20:18:08 +0300
committerAndrei Karas <akaras@inbox.ru>2017-08-08 20:18:08 +0300
commit91e74d8f1dc3f1fe01cb65822913488f5cbc5657 (patch)
tree7cd1485d11ca1915504ba6ed6e92c0d7ca0d97d0 /src/gui/shortcut
parentd1dcddb018c74aebf0ffb2bbde1501685372c2d8 (diff)
downloadManaVerse-91e74d8f1dc3f1fe01cb65822913488f5cbc5657.tar.gz
ManaVerse-91e74d8f1dc3f1fe01cb65822913488f5cbc5657.tar.bz2
ManaVerse-91e74d8f1dc3f1fe01cb65822913488f5cbc5657.tar.xz
ManaVerse-91e74d8f1dc3f1fe01cb65822913488f5cbc5657.zip
Use size_t type for index in itemshortcut.
Diffstat (limited to 'src/gui/shortcut')
-rw-r--r--src/gui/shortcut/itemshortcut.cpp20
-rw-r--r--src/gui/shortcut/itemshortcut.h21
2 files changed, 21 insertions, 20 deletions
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;
}
diff --git a/src/gui/shortcut/itemshortcut.h b/src/gui/shortcut/itemshortcut.h
index 8aa7a9efc..5e77e9152 100644
--- a/src/gui/shortcut/itemshortcut.h
+++ b/src/gui/shortcut/itemshortcut.h
@@ -66,10 +66,10 @@ class ItemShortcut final
*
* @param index Index of the shortcut item.
*/
- int getItem(const int index) const A_WARN_UNUSED
+ int getItem(const size_t index) const A_WARN_UNUSED
{ return mItems[index]; }
- ItemColor getItemColor(const int index) const A_WARN_UNUSED
+ ItemColor getItemColor(const size_t index) const A_WARN_UNUSED
{ return mItemColors[index]; }
void setItemData(const size_t index,
@@ -96,9 +96,9 @@ class ItemShortcut final
*
* @param index Index of the items.
*/
- void setItem(const int index);
+ void setItem(const size_t index);
- void setItem(const int index,
+ void setItem(const size_t index,
const int item,
const ItemColor color);
@@ -112,7 +112,7 @@ class ItemShortcut final
* @param index Index of the item.
* @param itemId ID of the item.
*/
- void setItems(const int index,
+ void setItems(const size_t index,
const int itemId,
const ItemColor color)
{ mItems[index] = itemId; mItemColors[index] = color; save(); }
@@ -142,7 +142,7 @@ class ItemShortcut final
/**
* Remove a item from the shortcut.
*/
- void removeItem(const int index)
+ void removeItem(const size_t index)
{ mItems[index] = -1; save(); }
/**
@@ -150,19 +150,20 @@ class ItemShortcut final
*
* @param index Index of the item shortcut.
*/
- void useItem(const int index) const;
+ void useItem(const size_t index) const;
/**
* Equip a item from the shortcut.
*/
- void equipItem(const int index) const;
+ void equipItem(const size_t index) const;
/**
* UnEquip a item from the shortcut.
*/
- void unequipItem(const int index) const;
+ void unequipItem(const size_t index) const;
- void swap(const int index1, const int index2);
+ void swap(const size_t index1,
+ const size_t index2);
void clear();