diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2008-11-01 14:55:54 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2008-11-01 14:55:54 +0000 |
commit | 55e0ddd7e1d60a56ece679a4c2563bef854e892b (patch) | |
tree | 322df9b8661f379990b3b526e5aa41f0e23ec9e2 /src/itemshortcut.cpp | |
parent | 3d85803d9a43c779f522a936df068a24ca6f7f2d (diff) | |
download | mana-55e0ddd7e1d60a56ece679a4c2563bef854e892b.tar.gz mana-55e0ddd7e1d60a56ece679a4c2563bef854e892b.tar.bz2 mana-55e0ddd7e1d60a56ece679a4c2563bef854e892b.tar.xz mana-55e0ddd7e1d60a56ece679a4c2563bef854e892b.zip |
Merged revisions 4180-4181 via svnmerge from
https://themanaworld.svn.sourceforge.net/svnroot/themanaworld/tmw/branches/0.0
........
r4180 | peaveydk | 2008-04-24 22:49:30 +0200 (Thu, 24 Apr 2008) | 1 line
Make shortcut container ID based instead of slot based. Fixes items shifting around often causing equipment to be lost.
........
r4181 | peaveydk | 2008-04-25 02:25:59 +0200 (Fri, 25 Apr 2008) | 1 line
Document anti-trade function.
........
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 12ae95f2..59c1ee3b 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,9 +78,10 @@ void ItemShortcut::useItem(int index) { if (mItems[index]) { - if (mItems[index]->getQuantity()) { + Item *item = player_node->searchForItem(mItems[index]); + if (item && item->getQuantity()) { // TODO: Fix this (index vs. pointer mismatch) - //player_node->useItem(mItems[index]); + //player_node->useItem(item); } } } |