From 03bfe2db420e0b219451590e14bb34c03c71f03c Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 28 Feb 2013 21:37:19 +0300 Subject: improve some other files. --- src/itemshortcut.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'src/itemshortcut.cpp') 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()) -- cgit v1.2.3-60-g2f50