summaryrefslogtreecommitdiff
path: root/src/content_nodemeta.cpp
diff options
context:
space:
mode:
authorJacobF <queatz@gmail.com>2011-08-25 19:27:50 -0400
committerJacobF <queatz@gmail.com>2011-08-25 19:27:50 -0400
commit134e49cc8e442e582608411832363e15f68ea6eb (patch)
tree3da141aefcfd33680f40b95f66ee99a31543c353 /src/content_nodemeta.cpp
parentefd8dabd913b2d1a0564378c30ae86c7a5081f06 (diff)
downloadminetest-134e49cc8e442e582608411832363e15f68ea6eb.tar.gz
minetest-134e49cc8e442e582608411832363e15f68ea6eb.tar.bz2
minetest-134e49cc8e442e582608411832363e15f68ea6eb.zip
Merged 2 branches because they relied on each other.
This one contains these changes from main c55: * Adds a function to check if there is room for a specific item * Using that, you can now pick up rats if you have a full inventory and a not full rat stack * Furnace would cook only 1 item if that item used the last available result slot, now it will continue * Furnace will say it's overloaded * Furnace won't wait until the next step to start on the next item - This caused small fuels to cook slower than meant to - Also caused furnaces to say they were out of fuel after finishing the last fuel item
Diffstat (limited to 'src/content_nodemeta.cpp')
-rw-r--r--src/content_nodemeta.cpp34
1 files changed, 26 insertions, 8 deletions
diff --git a/src/content_nodemeta.cpp b/src/content_nodemeta.cpp
index 433e6d04b..7c0e817f8 100644
--- a/src/content_nodemeta.cpp
+++ b/src/content_nodemeta.cpp
@@ -182,16 +182,24 @@ std::string FurnaceNodeMetadata::infoText()
assert(src_list);
const InventoryItem *src_item = src_list->getItem(0);
- if(src_item)
+ if(src_item) {
+ InventoryList *dst_list = m_inventory->getList("dst");
+ if(!dst_list->roomForCookedItem(src_item))
+ return "Furnace is overloaded";
return "Furnace is out of fuel";
+ }
else
return "Furnace is inactive";
}
else
{
- std::string s = "Furnace is active (";
- s += itos(m_fuel_time/m_fuel_totaltime*100);
- s += "%)";
+ std::string s = "Furnace is active";
+ // Do this so it doesn't always show (0%) for weak fuel
+ if(m_fuel_totaltime > 3) {
+ s += " (";
+ s += itos(m_fuel_time/m_fuel_totaltime*100);
+ s += "%)";
+ }
return s;
}
}
@@ -221,9 +229,14 @@ bool FurnaceNodeMetadata::step(float dtime)
assert(src_list);
const InventoryItem *src_item = src_list->getItem(0);
+ bool room_available = false;
+
+ if(src_item && src_item->isCookable())
+ room_available = dst_list->roomForCookedItem(src_item);
+
// Start only if there are free slots in dst, so that it can
// accomodate any result item
- if(dst_list->getFreeSlots() > 0 && src_item && src_item->isCookable())
+ if(room_available)
{
m_src_totaltime = 3;
}
@@ -252,13 +265,18 @@ bool FurnaceNodeMetadata::step(float dtime)
m_src_totaltime = 0;
}
changed = true;
- continue;
+
+ // Fall through if the fuel item was used up this step
+ if(m_fuel_time < m_fuel_totaltime)
+ continue;
}
/*
- If there is no source item or source item is not cookable, stop loop.
+ If there is no source item or source item is not cookable,
+ or furnace became overloaded, stop loop.
*/
- if(src_item == NULL || m_src_totaltime < 0.001)
+ if((m_fuel_time < m_fuel_totaltime || dst_list->roomForCookedItem(src_item) == false)
+ && (src_item == NULL || m_src_totaltime < 0.001))
{
m_step_accumulator = 0;
break;