diff options
author | Weblate <42@minetest.ru> | 2013-03-30 19:49:52 +0100 |
---|---|---|
committer | Weblate <42@minetest.ru> | 2013-03-30 19:49:52 +0100 |
commit | a0566270d9fa075afa36a7e3e68c690b1b23ba90 (patch) | |
tree | 6bc88127ee67b7bf4d6a2d6f9d0a9e5f997d1dd1 /src/craftdef.cpp | |
parent | 0d83bdc3aa9f1077836aacb833ac4ad9bbb9a4f4 (diff) | |
parent | 1aa50b13622c1e264044839ecdf0152670dae6ce (diff) | |
download | minetest-a0566270d9fa075afa36a7e3e68c690b1b23ba90.tar.gz minetest-a0566270d9fa075afa36a7e3e68c690b1b23ba90.tar.bz2 minetest-a0566270d9fa075afa36a7e3e68c690b1b23ba90.zip |
Merge remote branch 'origin/master'
Diffstat (limited to 'src/craftdef.cpp')
-rw-r--r-- | src/craftdef.cpp | 37 |
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); |