diff options
Diffstat (limited to 'src/gui/widgets/itemshortcutcontainer.cpp')
-rw-r--r-- | src/gui/widgets/itemshortcutcontainer.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp index 92e3e2e5..83efd4d4 100644 --- a/src/gui/widgets/itemshortcutcontainer.cpp +++ b/src/gui/widgets/itemshortcutcontainer.cpp @@ -142,9 +142,13 @@ void ItemShortcutContainer::mouseDragged(gcn::MouseEvent &event) if (!mItemMoved && mItemClicked) { const int index = getIndexFromGrid(event.getX(), event.getY()); + + if (index == -1) + return; + const int itemId = itemShortcut->getItem(index); - if (index == -1 || itemId < 0) + if (itemId < 0) return; Item *item = player_node->getInventory()->findItem(itemId); @@ -227,9 +231,13 @@ void ItemShortcutContainer::mouseReleased(gcn::MouseEvent &event) void ItemShortcutContainer::mouseMoved(gcn::MouseEvent &event) { const int index = getIndexFromGrid(event.getX(), event.getY()); + + if (index == -1) + return; + const int itemId = itemShortcut->getItem(index); - if (index == -1 || itemId < 0) + if (itemId < 0) return; Item *item = player_node->getInventory()->findItem(itemId); |