]> git.lizzy.rs Git - minetest.git/commitdiff
Ensure no item stack is being held before crafting (#4779)
authorLuis Cáceres <lacaceres97@gmail.com>
Wed, 6 Dec 2017 16:32:05 +0000 (16:32 +0000)
committerSmallJoker <mk939@ymail.com>
Sun, 3 Jun 2018 15:32:00 +0000 (17:32 +0200)
src/guiFormSpecMenu.cpp

index 19fd9f1f0e59abc526f0416aa73ae153778d7fb0..c4b072be1360f9c5d84d61faeafae835f7df91e2 100644 (file)
@@ -3681,18 +3681,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