mirror of
https://github.com/smartcmd/MinecraftConsoles.git
synced 2026-06-24 03:07:04 +00:00
add proper recipe clean up on class delete
This commit is contained in:
parent
4cacbee4aa
commit
9af38d7a9d
|
|
@ -41,7 +41,7 @@ public:
|
|||
unsigned short usBitmaskMissingGridIngredients[XUSER_MAX_COUNT]; // each bit set means we don't have that grid ingredient
|
||||
}
|
||||
INGREDIENTS_REQUIRED;
|
||||
~Recipy() {}
|
||||
~Recipy() = default;
|
||||
virtual bool matches(shared_ptr<CraftingContainer> craftSlots, Level *level) = 0;
|
||||
virtual shared_ptr<ItemInstance> assemble(shared_ptr<CraftingContainer> craftSlots) = 0;
|
||||
virtual int size() = 0;
|
||||
|
|
|
|||
|
|
@ -23,6 +23,17 @@ ShapedRecipy::ShapedRecipy(int width, int height, ItemInstance **recipeItems, It
|
|||
_keepTag = false;
|
||||
}
|
||||
|
||||
ShapedRecipy::~ShapedRecipy()
|
||||
{
|
||||
for (int i = 0; i < width * height; i++) {
|
||||
if (recipeItems[i] == nullptr) continue;
|
||||
delete recipeItems[i];
|
||||
}
|
||||
|
||||
delete[] recipeItems;
|
||||
delete result;
|
||||
}
|
||||
|
||||
const int ShapedRecipy::getGroup()
|
||||
{
|
||||
return group;
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ public:
|
|||
|
||||
public:
|
||||
ShapedRecipy(int width, int height, ItemInstance **recipeItems, ItemInstance *result, int iGroup=Recipy::eGroupType_Decoration);
|
||||
~ShapedRecipy();
|
||||
|
||||
virtual const ItemInstance *getResultItem();
|
||||
virtual const int getGroup();
|
||||
|
|
|
|||
|
|
@ -19,6 +19,16 @@ ShapelessRecipy::ShapelessRecipy(ItemInstance *result, vector<ItemInstance *> *i
|
|||
{
|
||||
}
|
||||
|
||||
ShapelessRecipy::~ShapelessRecipy()
|
||||
{
|
||||
for (auto ingredient : *ingredients) {
|
||||
delete ingredient;
|
||||
}
|
||||
|
||||
delete ingredients;
|
||||
delete result;
|
||||
}
|
||||
|
||||
const int ShapelessRecipy::getGroup()
|
||||
{
|
||||
return group;
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ private:
|
|||
|
||||
public:
|
||||
ShapelessRecipy(ItemInstance *result, vector<ItemInstance *> *ingredients, _eGroupType egroup=Recipy::eGroupType_Decoration);
|
||||
~ShapelessRecipy();
|
||||
|
||||
virtual const ItemInstance *getResultItem();
|
||||
virtual const int getGroup();
|
||||
|
|
|
|||
Loading…
Reference in a new issue