diff --git a/src/client/component/gui/gui.cpp b/src/client/component/gui/gui.cpp index cb34710b..73b1e0a0 100644 --- a/src/client/component/gui/gui.cpp +++ b/src/client/component/gui/gui.cpp @@ -260,10 +260,23 @@ namespace gui } } + void shutdown_gui() + { + if (initialized) + { + ImGui_ImplWin32_Shutdown(); + ImGui::DestroyContext(); + } + + initialized = false; + } + HRESULT d3d11_create_device_stub(IDXGIAdapter* pAdapter, D3D_DRIVER_TYPE DriverType, HMODULE Software, UINT Flags, const D3D_FEATURE_LEVEL* pFeatureLevels, UINT FeatureLevels, UINT SDKVersion, ID3D11Device** ppDevice, D3D_FEATURE_LEVEL* pFeatureLevel, ID3D11DeviceContext** ppImmediateContext) { + shutdown_gui(); + const auto result = D3D11CreateDevice(pAdapter, DriverType, Software, Flags, pFeatureLevels, FeatureLevels, SDKVersion, ppDevice, pFeatureLevel, ppImmediateContext); @@ -402,11 +415,7 @@ namespace gui void pre_destroy() override { - if (initialized) - { - ImGui_ImplWin32_Shutdown(); - ImGui::DestroyContext(); - } + shutdown_gui(); } }; } diff --git a/src/client/component/mods.cpp b/src/client/component/mods.cpp index 776ca429..02e336cc 100644 --- a/src/client/component/mods.cpp +++ b/src/client/component/mods.cpp @@ -319,11 +319,6 @@ namespace mods utils::io::create_directory(MOD_FOLDER); } - if (!utils::io::directory_exists(MOD_STATS_FOLDER)) - { - utils::io::create_directory(MOD_STATS_FOLDER); - } - db_release_xassets_hook.create(0x140416A80, db_release_xassets_stub); command::add("loadmod", [](const command::params& params) diff --git a/src/client/component/patches.cpp b/src/client/component/patches.cpp index de5add5c..85ebd257 100644 --- a/src/client/component/patches.cpp +++ b/src/client/component/patches.cpp @@ -44,23 +44,16 @@ namespace patches gscr_set_save_dvar_hook.invoke(); } - void free_lui_memory() + void vid_restart_stub() { + // free stuff + *reinterpret_cast(0x141E584D8) = nullptr; // free material + utils::hook::invoke(0x1406926B0); // free scripted viewmodel xanim stuff utils::hook::invoke(0x14032A540); // properly free lui memory - } - void vid_restart_stub_1() - { - free_lui_memory(); utils::hook::invoke(0x1405A6480); } - void vid_restart_stub_2() - { - free_lui_memory(); - utils::hook::invoke(0x1406B5290); - } - void exec_config_stub(void* a1) { dvars::register_string("name", "Unknown Soldier", game::DVAR_FLAG_SAVED, "Player name"); @@ -108,8 +101,7 @@ namespace patches gscr_set_save_dvar_hook.create(0x140504C60, &gscr_set_save_dvar_stub); // fix vid_restart crashing - utils::hook::call(0x1403D7413, vid_restart_stub_1); - utils::hook::jump(0x1403D7402, vid_restart_stub_2); + utils::hook::call(0x1403D7413, vid_restart_stub); // cinematicingameloopresident -> cinematicingameloop (fix ingame cinematics) utils::hook::jump(0x140502140, 0x1405020C0);