diff --git a/source/build/include/build.h b/source/build/include/build.h index de62a32a6..b1b3a1a75 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -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); 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 squarerotatetile(int16_t tilenume); diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index 03b0d147b..2e34d2d9c 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -10104,6 +10104,15 @@ void vox_undefine(int32_t const tile) // TODO: nextvoxid } +void vox_deinit() +{ + for (auto &vox : voxmodels) + { + voxfree(vox); + vox = nullptr; + } +} + // // inside // diff --git a/source/build/src/voxmodel.cpp b/source/build/src/voxmodel.cpp index 2f0915a20..0771ca08f 100644 --- a/source/build/src/voxmodel.cpp +++ b/source/build/src/voxmodel.cpp @@ -842,6 +842,11 @@ void voxfree(voxmodel_t *m) DO_FREE_AND_NULL(m->mytex); DO_FREE_AND_NULL(m->quad); + for (auto& tex : m->texid) + { + if (tex) delete tex; + tex = nullptr; + } Xfree(m); } diff --git a/source/common/gamecontrol.cpp b/source/common/gamecontrol.cpp index 0e7f82727..9fd9a7b0e 100644 --- a/source/common/gamecontrol.cpp +++ b/source/common/gamecontrol.cpp @@ -318,6 +318,7 @@ int GameMain() G_SaveConfig(); C_DeinitConsole(); V_ClearFonts(); + vox_deinit(); TileFiles.ClearTextureCache(); TileFiles.CloseAll(); // do this before shutting down graphics. GLInterface.Deinit(); diff --git a/source/platform/win32/i_main.cpp b/source/platform/win32/i_main.cpp index d339a59ad..6c1063564 100644 --- a/source/platform/win32/i_main.cpp +++ b/source/platform/win32/i_main.cpp @@ -1173,7 +1173,7 @@ int WINAPI wWinMain (HINSTANCE hInstance, HINSTANCE nothing, LPWSTR cmdline, int // Use this to break at a specific allocation number. - //_crtBreakAlloc = 253018; + _crtBreakAlloc = 250894; #endif int ret = DoMain (hInstance);