diff --git a/Minecraft.World/Recipy.h b/Minecraft.World/Recipy.h index 9cbf5cacf..e78710726 100644 --- a/Minecraft.World/Recipy.h +++ b/Minecraft.World/Recipy.h @@ -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 craftSlots, Level *level) = 0; virtual shared_ptr assemble(shared_ptr craftSlots) = 0; virtual int size() = 0; diff --git a/Minecraft.World/ShapedRecipy.cpp b/Minecraft.World/ShapedRecipy.cpp index 7a0e85b03..907666370 100644 --- a/Minecraft.World/ShapedRecipy.cpp +++ b/Minecraft.World/ShapedRecipy.cpp @@ -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; diff --git a/Minecraft.World/ShapedRecipy.h b/Minecraft.World/ShapedRecipy.h index 33087ab69..b6d269503 100644 --- a/Minecraft.World/ShapedRecipy.h +++ b/Minecraft.World/ShapedRecipy.h @@ -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(); diff --git a/Minecraft.World/ShapelessRecipy.cpp b/Minecraft.World/ShapelessRecipy.cpp index 8fab1b7e9..e10c3c672 100644 --- a/Minecraft.World/ShapelessRecipy.cpp +++ b/Minecraft.World/ShapelessRecipy.cpp @@ -19,6 +19,16 @@ ShapelessRecipy::ShapelessRecipy(ItemInstance *result, vector *i { } +ShapelessRecipy::~ShapelessRecipy() +{ + for (auto ingredient : *ingredients) { + delete ingredient; + } + + delete ingredients; + delete result; +} + const int ShapelessRecipy::getGroup() { return group; diff --git a/Minecraft.World/ShapelessRecipy.h b/Minecraft.World/ShapelessRecipy.h index 713a41faa..105afafcb 100644 --- a/Minecraft.World/ShapelessRecipy.h +++ b/Minecraft.World/ShapelessRecipy.h @@ -9,6 +9,7 @@ private: public: ShapelessRecipy(ItemInstance *result, vector *ingredients, _eGroupType egroup=Recipy::eGroupType_Decoration); + ~ShapelessRecipy(); virtual const ItemInstance *getResultItem(); virtual const int getGroup();