diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-02-28 21:37:19 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-02-28 21:37:19 +0300 |
commit | 03bfe2db420e0b219451590e14bb34c03c71f03c (patch) | |
tree | c3cb081449261b51f1ffefa2da4ba39fa5645888 /src/itemshortcut.cpp | |
parent | c47ef8b3f2ec6ea0e26748af17cb12b7f9cd20c9 (diff) | |
download | mv-03bfe2db420e0b219451590e14bb34c03c71f03c.tar.gz mv-03bfe2db420e0b219451590e14bb34c03c71f03c.tar.bz2 mv-03bfe2db420e0b219451590e14bb34c03c71f03c.tar.xz mv-03bfe2db420e0b219451590e14bb34c03c71f03c.zip |
improve some other files.
Diffstat (limited to 'src/itemshortcut.cpp')
-rw-r--r-- | src/itemshortcut.cpp | 24 |
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()) |