+
+ virtual bool clearCraftsByOutput(const CraftOutput &output, IGameDef *gamedef)
+ {
+ auto to_clear = m_output_craft_definitions.find(output.item);
+
+ if (to_clear == m_output_craft_definitions.end())
+ return false;
+
+ for (auto def : to_clear->second) {
+ // Recipes are not yet hashed at this point
+ std::vector<CraftDefinition *> &defs = m_craft_defs[(int)CRAFT_HASH_TYPE_UNHASHED][0];
+ defs.erase(std::remove(defs.begin(), defs.end(), def), defs.end());
+ delete def;
+ }
+ m_output_craft_definitions.erase(to_clear);
+ return true;
+ }
+
+ virtual bool clearCraftsByInput(const CraftInput &input, IGameDef *gamedef)
+ {
+ if (input.empty())
+ return false;
+
+ // Recipes are not yet hashed at this point
+ std::vector<CraftDefinition *> &defs = m_craft_defs[(int)CRAFT_HASH_TYPE_UNHASHED][0];
+ std::vector<CraftDefinition *> new_defs;
+ bool got_hit = false;
+ for (auto def : defs) {
+ if (!def->check(input, gamedef)) {
+ new_defs.push_back(def);
+ continue;
+ }
+ got_hit = true;
+ std::string output = def->getOutput(input, gamedef).item;
+ delete def;
+ auto it = m_output_craft_definitions.find(craftGetItemName(output, gamedef));
+ if (it == m_output_craft_definitions.end())
+ continue;
+ std::vector<CraftDefinition *> &outdefs = it->second;
+ outdefs.erase(std::remove(outdefs.begin(), outdefs.end(), def), outdefs.end());
+ }
+ if (got_hit)
+ defs.swap(new_defs);
+
+ return got_hit;
+ }
+