Commented out debug statements again
[oweals/minetest.git] / src / content_nodemeta.cpp
index 7c0e817f8576a10606d883f28672d7a103bb7198..1552c8e1524ace63957af47df30d0fdc9e06f0a7 100644 (file)
@@ -182,7 +182,7 @@ std::string FurnaceNodeMetadata::infoText()
                assert(src_list);
                const InventoryItem *src_item = src_list->getItem(0);
 
-               if(src_item) {
+               if(src_item && src_item->isCookable()) {
                        InventoryList *dst_list = m_inventory->getList("dst");
                        if(!dst_list->roomForCookedItem(src_item))
                                return "Furnace is overloaded";
@@ -203,6 +203,24 @@ std::string FurnaceNodeMetadata::infoText()
                return s;
        }
 }
+bool FurnaceNodeMetadata::nodeRemovalDisabled()
+{
+       /*
+               Disable removal if furnace is not empty
+       */
+       InventoryList *list[3] = {m_inventory->getList("src"),
+       m_inventory->getList("dst"), m_inventory->getList("fuel")};
+       
+       for(int i = 0; i < 3; i++) {
+               if(list[i] == NULL)
+                       continue;
+               if(list[i]->getUsedSlots() == 0)
+                       continue;
+               return true;
+       }
+       return false;
+       
+}
 void FurnaceNodeMetadata::inventoryModified()
 {
        dstream<<"Furnace inventory modification callback"<<std::endl;
@@ -227,7 +245,7 @@ bool FurnaceNodeMetadata::step(float dtime)
 
                InventoryList *src_list = m_inventory->getList("src");
                assert(src_list);
-               const InventoryItem *src_item = src_list->getItem(0);
+               InventoryItem *src_item = src_list->getItem(0);
                
                bool room_available = false;
                
@@ -266,17 +284,22 @@ bool FurnaceNodeMetadata::step(float dtime)
                        }
                        changed = true;
                        
-                       // Fall through if the fuel item was used up this step
+                       // If the fuel was not used up this step, just keep burning it
                        if(m_fuel_time < m_fuel_totaltime)
                                continue;
                }
                
                /*
-                       If there is no source item or source item is not cookable,
-                       or furnace became overloaded, stop loop.
+                       Get the source again in case it has all burned
+               */
+               src_item = src_list->getItem(0);
+               
+               /*
+                       If there is no source item, or the source item is not cookable,
+                       or the furnace is still cooking, or the furnace became overloaded, stop loop.
                */
-               if((m_fuel_time < m_fuel_totaltime || dst_list->roomForCookedItem(src_item) == false)
-                       && (src_item == NULL || m_src_totaltime < 0.001))
+               if(src_item == NULL || !room_available || m_fuel_time < m_fuel_totaltime ||
+                       dst_list->roomForCookedItem(src_item) == false)
                {
                        m_step_accumulator = 0;
                        break;