aboutsummaryrefslogtreecommitdiff
path: root/src/gui/guiFormSpecMenu.cpp
diff options
context:
space:
mode:
authorLuis Cáceres <lacaceres97@gmail.com>2017-12-06 16:32:05 +0000
committerSmallJoker <SmallJoker@users.noreply.github.com>2017-12-06 17:32:05 +0100
commit2b5341c51864660bb1a434a520f7cca9ce3619e6 (patch)
treefc557cd2ed3779184a247a1e24e4a1f162d2389c /src/gui/guiFormSpecMenu.cpp
parentfd9f195fcc2e4e592dbad3290876486eb08318b2 (diff)
downloadminetest-2b5341c51864660bb1a434a520f7cca9ce3619e6.tar.gz
minetest-2b5341c51864660bb1a434a520f7cca9ce3619e6.tar.bz2
minetest-2b5341c51864660bb1a434a520f7cca9ce3619e6.zip
Ensure no item stack is being held before crafting (#4779)
Diffstat (limited to 'src/gui/guiFormSpecMenu.cpp')
-rw-r--r--src/gui/guiFormSpecMenu.cpp28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/gui/guiFormSpecMenu.cpp b/src/gui/guiFormSpecMenu.cpp
index 0691bc598..c83e6aa49 100644
--- a/src/gui/guiFormSpecMenu.cpp
+++ b/src/gui/guiFormSpecMenu.cpp
@@ -3668,18 +3668,24 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event)
a->from_i = m_selected_item->i;
m_invmgr->inventoryAction(a);
} else if (craft_amount > 0) {
- m_selected_content_guess = ItemStack(); // Clear
-
- // Send IAction::Craft
-
assert(s.isValid());
- assert(inv_s);
-
- infostream << "Handing IAction::Craft to manager" << std::endl;
- ICraftAction *a = new ICraftAction();
- a->count = craft_amount;
- a->craft_inv = s.inventoryloc;
- m_invmgr->inventoryAction(a);
+
+ // if there are no items selected or the selected item
+ // belongs to craftresult list, proceed with crafting
+ if (m_selected_item == NULL ||
+ !m_selected_item->isValid() || m_selected_item->listname == "craftresult") {
+
+ m_selected_content_guess = ItemStack(); // Clear
+
+ assert(inv_s);
+
+ // Send IACTION_CRAFT
+ infostream << "Handing IACTION_CRAFT to manager" << std::endl;
+ ICraftAction *a = new ICraftAction();
+ a->count = craft_amount;
+ a->craft_inv = s.inventoryloc;
+ m_invmgr->inventoryAction(a);
+ }
}
// If m_selected_amount has been decreased to zero, deselect