More vid_restart fixes

This commit is contained in:
fed 2023-08-18 02:28:01 +02:00
parent 6f613a9249
commit 2768d1360e
3 changed files with 19 additions and 23 deletions

View File

@ -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, HRESULT d3d11_create_device_stub(IDXGIAdapter* pAdapter, D3D_DRIVER_TYPE DriverType, HMODULE Software,
UINT Flags, const D3D_FEATURE_LEVEL* pFeatureLevels, UINT FeatureLevels, UINT SDKVersion, UINT Flags, const D3D_FEATURE_LEVEL* pFeatureLevels, UINT FeatureLevels, UINT SDKVersion,
ID3D11Device** ppDevice, D3D_FEATURE_LEVEL* pFeatureLevel, ID3D11DeviceContext** ppImmediateContext) ID3D11Device** ppDevice, D3D_FEATURE_LEVEL* pFeatureLevel, ID3D11DeviceContext** ppImmediateContext)
{ {
shutdown_gui();
const auto result = D3D11CreateDevice(pAdapter, DriverType, Software, Flags, pFeatureLevels, const auto result = D3D11CreateDevice(pAdapter, DriverType, Software, Flags, pFeatureLevels,
FeatureLevels, SDKVersion, ppDevice, pFeatureLevel, ppImmediateContext); FeatureLevels, SDKVersion, ppDevice, pFeatureLevel, ppImmediateContext);
@ -402,11 +415,7 @@ namespace gui
void pre_destroy() override void pre_destroy() override
{ {
if (initialized) shutdown_gui();
{
ImGui_ImplWin32_Shutdown();
ImGui::DestroyContext();
}
} }
}; };
} }

View File

@ -319,11 +319,6 @@ namespace mods
utils::io::create_directory(MOD_FOLDER); 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); db_release_xassets_hook.create(0x140416A80, db_release_xassets_stub);
command::add("loadmod", [](const command::params& params) command::add("loadmod", [](const command::params& params)

View File

@ -44,23 +44,16 @@ namespace patches
gscr_set_save_dvar_hook.invoke<void>(); gscr_set_save_dvar_hook.invoke<void>();
} }
void free_lui_memory() void vid_restart_stub()
{ {
// free stuff
*reinterpret_cast<void**>(0x141E584D8) = nullptr; // free material
utils::hook::invoke<void>(0x1406926B0); // free scripted viewmodel xanim stuff
utils::hook::invoke<void>(0x14032A540); // properly free lui memory utils::hook::invoke<void>(0x14032A540); // properly free lui memory
}
void vid_restart_stub_1()
{
free_lui_memory();
utils::hook::invoke<void>(0x1405A6480); utils::hook::invoke<void>(0x1405A6480);
} }
void vid_restart_stub_2()
{
free_lui_memory();
utils::hook::invoke<void>(0x1406B5290);
}
void exec_config_stub(void* a1) void exec_config_stub(void* a1)
{ {
dvars::register_string("name", "Unknown Soldier", game::DVAR_FLAG_SAVED, "Player name"); 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); gscr_set_save_dvar_hook.create(0x140504C60, &gscr_set_save_dvar_stub);
// fix vid_restart crashing // fix vid_restart crashing
utils::hook::call(0x1403D7413, vid_restart_stub_1); utils::hook::call(0x1403D7413, vid_restart_stub);
utils::hook::jump(0x1403D7402, vid_restart_stub_2);
// cinematicingameloopresident -> cinematicingameloop (fix ingame cinematics) // cinematicingameloopresident -> cinematicingameloop (fix ingame cinematics)
utils::hook::jump(0x140502140, 0x1405020C0); utils::hook::jump(0x140502140, 0x1405020C0);