Ensure no item stack is being held before crafting (#4779)

This commit is contained in:
Luis Cáceres 2017-12-06 16:32:05 +00:00 committed by SmallJoker
parent 48ebbf0fc6
commit 6f80e302fd

@ -3681,19 +3681,25 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event)
a->from_i = m_selected_item->i; a->from_i = m_selected_item->i;
m_invmgr->inventoryAction(a); m_invmgr->inventoryAction(a);
} else if (craft_amount > 0) { } else if (craft_amount > 0) {
assert(s.isValid());
// 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 m_selected_content_guess = ItemStack(); // Clear
// Send IACTION_CRAFT
assert(s.isValid());
assert(inv_s); assert(inv_s);
// Send IACTION_CRAFT
infostream << "Handing IACTION_CRAFT to manager" << std::endl; infostream << "Handing IACTION_CRAFT to manager" << std::endl;
ICraftAction *a = new ICraftAction(); ICraftAction *a = new ICraftAction();
a->count = craft_amount; a->count = craft_amount;
a->craft_inv = s.inventoryloc; a->craft_inv = s.inventoryloc;
m_invmgr->inventoryAction(a); m_invmgr->inventoryAction(a);
} }
}
// If m_selected_amount has been decreased to zero, deselect // If m_selected_amount has been decreased to zero, deselect
if (m_selected_amount == 0) { if (m_selected_amount == 0) {