diff options
author | Dennis Friis <peavey@placid.dk> | 2008-04-24 20:49:30 +0000 |
---|---|---|
committer | Dennis Friis <peavey@placid.dk> | 2008-04-24 20:49:30 +0000 |
commit | 3676b78c6e6e8089c0b6e38c0983bd99ea22e756 (patch) | |
tree | 30dadd8b4e00f70245279eeee04c71347f7dbc60 /src/itemshortcut.cpp | |
parent | 8c0964dbb59a10c47d2040686b03201ab5688092 (diff) | |
download | mana-3676b78c6e6e8089c0b6e38c0983bd99ea22e756.tar.gz mana-3676b78c6e6e8089c0b6e38c0983bd99ea22e756.tar.bz2 mana-3676b78c6e6e8089c0b6e38c0983bd99ea22e756.tar.xz mana-3676b78c6e6e8089c0b6e38c0983bd99ea22e756.zip |
Make shortcut container ID based instead of slot based. Fixes items shifting around often causing equipment to be lost.
Diffstat (limited to 'src/itemshortcut.cpp')
-rw-r--r-- | src/itemshortcut.cpp | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/itemshortcut.cpp b/src/itemshortcut.cpp index 931ce6f2..1201b23b 100644 --- a/src/itemshortcut.cpp +++ b/src/itemshortcut.cpp @@ -32,12 +32,13 @@ ItemShortcut::ItemShortcut *itemShortcut; ItemShortcut::ItemShortcut(): - mItemSelected(NULL) + mItemSelected(-1) { for (int i = 0; i < SHORTCUT_ITEMS; i++) { - mItems[i] = NULL; + mItems[i] = -1; } + load(); } ItemShortcut::~ItemShortcut() @@ -49,15 +50,11 @@ void ItemShortcut::load() { for (int i = 0; i < SHORTCUT_ITEMS; i++) { - int itemId = (int) config.getValue("itemShortcut" + toString(i), -1); + int itemId = (int) config.getValue("shortcut" + toString(i), -1); if (itemId != -1) { - Item* item = player_node->searchForItem(itemId); - if (item) - { - mItems[i] = item; - } + mItems[i] = itemId; } } } @@ -68,7 +65,7 @@ void ItemShortcut::save() { if (mItems[i]) { - config.setValue("shortcut" + toString(i), mItems[i]->getId()); + config.setValue("shortcut" + toString(i), mItems[i]); } else { @@ -81,8 +78,9 @@ void ItemShortcut::useItem(int index) { if (mItems[index]) { - if (mItems[index]->getQuantity()) { - player_node->useItem(mItems[index]); + Item *item = player_node->searchForItem(mItems[index]); + if (item && item->getQuantity()) { + player_node->useItem(item); } } } |