diff options
Diffstat (limited to 'src/itemshortcut.cpp')
-rw-r--r-- | src/itemshortcut.cpp | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/itemshortcut.cpp b/src/itemshortcut.cpp index a3812042..cfe46238 100644 --- a/src/itemshortcut.cpp +++ b/src/itemshortcut.cpp @@ -61,14 +61,8 @@ void ItemShortcut::save() { for (int i = 0; i < SHORTCUT_ITEMS; i++) { - if (mItems[i]) - { - config.setValue("shortcut" + toString(i), mItems[i]); - } - else - { - config.setValue("shortcut" + toString(i), -1); - } + const int itemId = mItems[i] ? mItems[i] : -1; + config.setValue("shortcut" + toString(i), itemId); } } @@ -78,6 +72,16 @@ void ItemShortcut::useItem(int index) { Item *item = player_node->getInventory()->findItem(mItems[index]); if (item && item->getQuantity()) - player_node->useItem(item); + { + if (item->isEquipment()) { + if (item->isEquipped()) { + player_node->unequipItem(item); + } else { + player_node->equipItem(item); + } + } else { + player_node->useItem(item); + } + } } } |