1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-07 16:48:40 +00:00

Fix some issues with minetest.clear_craft (#8712)

* Fix some issues with minetest.clear_craft

- Fix memory leak
- Fix crafts with an output count not being cleared when clearing by
  input.
- Fix recipe list being reversed when clearing by input.

* Add CraftInput::empty()
This commit is contained in:
Paul Ouellette 2019-08-10 17:28:00 -04:00 committed by sfan5
parent 86d7f84b89
commit 120155f312
6 changed files with 119 additions and 124 deletions

View file

@ -80,6 +80,9 @@ struct CraftInput
method(method_), width(width_), items(items_)
{}
// Returns true if all items are empty.
bool empty() const;
std::string dump() const;
};
@ -431,9 +434,8 @@ public:
virtual std::vector<CraftDefinition*> getCraftRecipes(CraftOutput &output,
IGameDef *gamedef, unsigned limit=0) const=0;
virtual bool clearCraftRecipesByOutput(const CraftOutput &output, IGameDef *gamedef) = 0;
virtual bool clearCraftRecipesByInput(CraftMethod craft_method,
unsigned int craft_grid_width, const std::vector<std::string> &recipe, IGameDef *gamedef) = 0;
virtual bool clearCraftsByOutput(const CraftOutput &output, IGameDef *gamedef) = 0;
virtual bool clearCraftsByInput(const CraftInput &input, IGameDef *gamedef) = 0;
// Print crafting recipes for debugging
virtual std::string dump() const=0;