- fixed voxels leaking memory.

This commit is contained in:
Christoph Oelckers 2019-12-25 08:57:58 +01:00
parent efe4261932
commit 745d78d8d7
5 changed files with 18 additions and 1 deletions

View File

@ -802,6 +802,8 @@ int32_t saveboard(const char *filename, const vec3_t *dapos, int16_t daang, in
int32_t qloadkvx(int32_t voxindex, const char *filename); int32_t qloadkvx(int32_t voxindex, const char *filename);
void vox_undefine(int32_t const); void vox_undefine(int32_t const);
void vox_deinit();
void tileCopySection(int32_t tilenume1, int32_t sx1, int32_t sy1, int32_t xsiz, int32_t ysiz, int32_t tilenume2, int32_t sx2, int32_t sy2); void tileCopySection(int32_t tilenume1, int32_t sx1, int32_t sy1, int32_t xsiz, int32_t ysiz, int32_t tilenume2, int32_t sx2, int32_t sy2);
void squarerotatetile(int16_t tilenume); void squarerotatetile(int16_t tilenume);

View File

@ -10104,6 +10104,15 @@ void vox_undefine(int32_t const tile)
// TODO: nextvoxid // TODO: nextvoxid
} }
void vox_deinit()
{
for (auto &vox : voxmodels)
{
voxfree(vox);
vox = nullptr;
}
}
// //
// inside // inside
// //

View File

@ -842,6 +842,11 @@ void voxfree(voxmodel_t *m)
DO_FREE_AND_NULL(m->mytex); DO_FREE_AND_NULL(m->mytex);
DO_FREE_AND_NULL(m->quad); DO_FREE_AND_NULL(m->quad);
for (auto& tex : m->texid)
{
if (tex) delete tex;
tex = nullptr;
}
Xfree(m); Xfree(m);
} }

View File

@ -318,6 +318,7 @@ int GameMain()
G_SaveConfig(); G_SaveConfig();
C_DeinitConsole(); C_DeinitConsole();
V_ClearFonts(); V_ClearFonts();
vox_deinit();
TileFiles.ClearTextureCache(); TileFiles.ClearTextureCache();
TileFiles.CloseAll(); // do this before shutting down graphics. TileFiles.CloseAll(); // do this before shutting down graphics.
GLInterface.Deinit(); GLInterface.Deinit();

View File

@ -1173,7 +1173,7 @@ int WINAPI wWinMain (HINSTANCE hInstance, HINSTANCE nothing, LPWSTR cmdline, int
// Use this to break at a specific allocation number. // Use this to break at a specific allocation number.
//_crtBreakAlloc = 253018; _crtBreakAlloc = 250894;
#endif #endif
int ret = DoMain (hInstance); int ret = DoMain (hInstance);