From ae375cc322c5ee090c21ff4a04e54ef4422020cc Mon Sep 17 00:00:00 2001 From: Kahrl Date: Mon, 20 Oct 2014 16:11:00 +0200 Subject: [PATCH 1/2] Fix memory leak caused by mesh nodes (and nodeboxes) --- src/nodedef.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/nodedef.cpp b/src/nodedef.cpp index 5735ef914..ee5505236 100644 --- a/src/nodedef.cpp +++ b/src/nodedef.cpp @@ -171,6 +171,12 @@ ContentFeatures::ContentFeatures() ContentFeatures::~ContentFeatures() { +#ifndef SERVER + for (u32 i = 0; i < 24; i++) { + if (mesh_ptr[i]) + mesh_ptr[i]->drop(); + } +#endif } void ContentFeatures::reset() From 9029a34cc6a3b19c1a431fe3ba069c30a13321fc Mon Sep 17 00:00:00 2001 From: Kahrl Date: Mon, 20 Oct 2014 16:11:38 +0200 Subject: [PATCH 2/2] Fix some indentation in nodedef.cpp --- src/nodedef.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/nodedef.cpp b/src/nodedef.cpp index ee5505236..2f95b68f9 100644 --- a/src/nodedef.cpp +++ b/src/nodedef.cpp @@ -857,12 +857,12 @@ void CNodeDefManager::updateTextures(IGameDef *gamedef) //Cache 6dfacedir rotated clones of meshes if (f->mesh_ptr[0] && (f->param_type_2 == CPT2_FACEDIR)) { - for (u16 j = 1; j < 24; j++) { - f->mesh_ptr[j] = cloneMesh(f->mesh_ptr[0]); - rotateMeshBy6dFacedir(f->mesh_ptr[j], j); - recalculateBoundingBox(f->mesh_ptr[j]); - } + for (u16 j = 1; j < 24; j++) { + f->mesh_ptr[j] = cloneMesh(f->mesh_ptr[0]); + rotateMeshBy6dFacedir(f->mesh_ptr[j], j); + recalculateBoundingBox(f->mesh_ptr[j]); } + } } #endif }