summaryrefslogtreecommitdiff
path: root/src/craftdef.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/craftdef.cpp')
-rw-r--r--src/craftdef.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/craftdef.cpp b/src/craftdef.cpp
index 99e3fcc3d..c79408f99 100644
--- a/src/craftdef.cpp
+++ b/src/craftdef.cpp
@@ -987,6 +987,43 @@ public:
}
return false;
}
+ virtual std::vector<CraftDefinition*> getCraftRecipes(CraftOutput &output,
+ IGameDef *gamedef) const
+ {
+ std::vector<CraftDefinition*> recipes_list;
+ CraftInput input;
+ CraftOutput tmpout;
+ tmpout.item = "";
+ tmpout.time = 0;
+
+ for(std::vector<CraftDefinition*>::const_reverse_iterator
+ i = m_craft_definitions.rbegin();
+ i != m_craft_definitions.rend(); i++)
+ {
+ CraftDefinition *def = *i;
+
+ /*infostream<<"Checking "<<input.dump()<<std::endl
+ <<" against "<<def->dump()<<std::endl;*/
+
+ try {
+ tmpout = def->getOutput(input, gamedef);
+ if(tmpout.item.substr(0,output.item.length()) == output.item)
+ {
+ // Get output, then decrement input (if requested)
+ input = def->getInput(output, gamedef);
+ recipes_list.push_back(*i);
+ }
+ }
+ catch(SerializationError &e)
+ {
+ errorstream<<"getCraftResult: ERROR: "
+ <<"Serialization error in recipe "
+ <<def->dump()<<std::endl;
+ // then go on with the next craft definition
+ }
+ }
+ return recipes_list;
+ }
virtual std::string dump() const
{
std::ostringstream os(std::ios::binary);