summaryrefslogtreecommitdiff
path: root/src/itemshortcut.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/itemshortcut.cpp')
-rw-r--r--src/itemshortcut.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/itemshortcut.cpp b/src/itemshortcut.cpp
index 03efa63c3..499b8e5b8 100644
--- a/src/itemshortcut.cpp
+++ b/src/itemshortcut.cpp
@@ -120,7 +120,8 @@ void ItemShortcut::save() const
void ItemShortcut::useItem(const int index) const
{
- if (!PlayerInfo::getInventory())
+ const Inventory *const inv = PlayerInfo::getInventory();
+ if (!inv)
return;
const int itemId = mItems[index];
@@ -129,8 +130,7 @@ void ItemShortcut::useItem(const int index) const
{
if (itemId < SPELL_MIN_ID)
{
- const Item *const item = PlayerInfo::getInventory()->findItem(
- itemId, itemColor);
+ const Item *const item = inv->findItem(itemId, itemColor);
if (item && item->getQuantity())
{
if (item->isEquipment())
@@ -159,13 +159,14 @@ void ItemShortcut::useItem(const int index) const
void ItemShortcut::equipItem(const int index) const
{
- if (!PlayerInfo::getInventory())
+ const Inventory *const inv = PlayerInfo::getInventory();
+ if (!inv)
return;
- if (mItems[index])
+ const int itemId = mItems[index];
+ if (itemId)
{
- const Item *const item = PlayerInfo::getInventory()->findItem(
- mItems[index], mItemColors[index]);
+ const Item *const item = inv->findItem(itemId, mItemColors[index]);
if (item && item->getQuantity())
{
if (item->isEquipment())
@@ -178,13 +179,14 @@ void ItemShortcut::equipItem(const int index) const
}
void ItemShortcut::unequipItem(const int index) const
{
- if (!PlayerInfo::getInventory())
+ const Inventory *const inv = PlayerInfo::getInventory();
+ if (!inv)
return;
- if (mItems[index])
+ const int itemId = mItems[index];
+ if (itemId)
{
- const Item *const item = PlayerInfo::getInventory()->findItem(
- mItems[index], mItemColors[index]);
+ const Item *const item = inv->findItem(itemId, mItemColors[index]);
if (item && item->getQuantity())
{
if (item->isEquipment())