summaryrefslogtreecommitdiff
path: root/src/itemshortcut.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-02-28 21:37:19 +0300
committerAndrei Karas <akaras@inbox.ru>2013-02-28 21:37:19 +0300
commit03bfe2db420e0b219451590e14bb34c03c71f03c (patch)
treec3cb081449261b51f1ffefa2da4ba39fa5645888 /src/itemshortcut.cpp
parentc47ef8b3f2ec6ea0e26748af17cb12b7f9cd20c9 (diff)
downloadmanaverse-03bfe2db420e0b219451590e14bb34c03c71f03c.tar.gz
manaverse-03bfe2db420e0b219451590e14bb34c03c71f03c.tar.bz2
manaverse-03bfe2db420e0b219451590e14bb34c03c71f03c.tar.xz
manaverse-03bfe2db420e0b219451590e14bb34c03c71f03c.zip
improve some other files.
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())