From 6b3ff8fd008b5b6872f62af55f8bf7476149ad37 Mon Sep 17 00:00:00 2001 From: Maurice Heumann Date: Thu, 26 Dec 2019 13:24:48 +0100 Subject: [PATCH] [FileSystem] Correctly free iwds --- src/Components/Modules/FileSystem.cpp | 12 ++++++++++++ src/Components/Modules/FileSystem.hpp | 1 + 2 files changed, 13 insertions(+) diff --git a/src/Components/Modules/FileSystem.cpp b/src/Components/Modules/FileSystem.cpp index d96af79b..2d5e21f6 100644 --- a/src/Components/Modules/FileSystem.cpp +++ b/src/Components/Modules/FileSystem.cpp @@ -263,10 +263,18 @@ namespace Components void FileSystem::FsRestartSync(int a1, int a2) { std::lock_guard _(FileSystem::FSMutex); + Maps::GetUserMap()->freeIwd(); Utils::Hook::Call(0x461A50)(a1, a2); // FS_Restart Maps::GetUserMap()->reloadIwd(); } + void FileSystem::FsShutdownSync(int a1) + { + std::lock_guard _(FileSystem::FSMutex); + Maps::GetUserMap()->freeIwd(); + Utils::Hook::Call(0x4A46C0)(a1); // FS_Shutdown + } + void FileSystem::DelayLoadImagesSync() { std::lock_guard _(FileSystem::FSMutex); @@ -322,6 +330,10 @@ namespace Components Utils::Hook(0x4C8609, FileSystem::FsRestartSync, HOOK_CALL).install()->quick(); // FS_ConditionalRestart Utils::Hook(0x5AC68E, FileSystem::FsRestartSync, HOOK_CALL).install()->quick(); // CL_ParseServerMessage + // Synchronize filesystem stops + Utils::Hook(0x461A55, FileSystem::FsShutdownSync, HOOK_CALL).install()->quick(); // FS_Restart + Utils::Hook(0x4D40DB, FileSystem::FsShutdownSync, HOOK_CALL).install()->quick(); // Com_Quitf + // Synchronize db image loading Utils::Hook(0x415AB8, FileSystem::DelayLoadImagesSync, HOOK_CALL).install()->quick(); Utils::Hook(0x4D32BC, FileSystem::LoadTextureSync, HOOK_CALL).install()->quick(); diff --git a/src/Components/Modules/FileSystem.hpp b/src/Components/Modules/FileSystem.hpp index e40f3f59..9cb26967 100644 --- a/src/Components/Modules/FileSystem.hpp +++ b/src/Components/Modules/FileSystem.hpp @@ -109,6 +109,7 @@ namespace Components static void FsStartupSync(const char* a1); static void FsRestartSync(int a1, int a2); + static void FsShutdownSync(int a1); static void DelayLoadImagesSync(); static int LoadTextureSync(Game::GfxImageLoadDef **loadDef, Game::GfxImage *image);