summaryrefslogtreecommitdiff
path: root/src/itemshortcut.cpp
diff options
context:
space:
mode:
authorIra Rice <irarice@gmail.com>2008-11-25 18:43:28 +0000
committerIra Rice <irarice@gmail.com>2008-11-25 18:43:28 +0000
commit886a5d4803e277b053014ae6b5c1c347f7756d48 (patch)
treee24d94a1652470c27a2dbe26eed7a1923d43adb3 /src/itemshortcut.cpp
parentd5e30d8f72184241034aa797471c31a5bcbaa095 (diff)
downloadmana-886a5d4803e277b053014ae6b5c1c347f7756d48.tar.gz
mana-886a5d4803e277b053014ae6b5c1c347f7756d48.tar.bz2
mana-886a5d4803e277b053014ae6b5c1c347f7756d48.tar.xz
mana-886a5d4803e277b053014ae6b5c1c347f7756d48.zip
Miscellaneous TMW change commits. Missed these changes before because of
a confusion on git.
Diffstat (limited to 'src/itemshortcut.cpp')
-rw-r--r--src/itemshortcut.cpp22
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);
+ }
+ }
}
}