diff --git a/source/Enderal DLL/src/Main.cpp b/source/Enderal DLL/src/Main.cpp index a80ec20e..469b1501 100644 --- a/source/Enderal DLL/src/Main.cpp +++ b/source/Enderal DLL/src/Main.cpp @@ -64,6 +64,10 @@ namespace { if (message->type == MessagingInterface::kPostLoad) { if (!REL::Module::IsVR()) { + if (g_settings.at("AttachLightHitEffectCrashFix")) { + logger::info("Installing light attach crash fix..."); + AttachLightHitEffectCrash::Install(); + } if (g_settings.at("StayAtSystemPage")) { if (const auto pluginInfo = GetLoadInterface()->GetPluginInfo("StayAtSystemPage"); pluginInfo) { MessageBoxW(NULL, L"Stay At The System Page is already included in Enderal, please, disable it.", L"Enderal SE Error", MB_OK | MB_ICONERROR); @@ -215,10 +219,6 @@ SKSEPluginLoad(const LoadInterface* skse) { logger::info("Initializing Stay At The System Page..."); JournalMenuEx::InstallHooks(); } - if (g_settings.at("AttachLightHitEffectCrashFix")) { - logger::info("Installing light attach crash fix..."); - AttachLightHitEffectCrash::Install(); - } } logger::info("{} has finished loading.", plugin->GetName()); diff --git a/source/Enderal DLL/src/Patches/AttachLightHitEffectCrash.h b/source/Enderal DLL/src/Patches/AttachLightHitEffectCrash.h index ead455a3..47be0562 100644 --- a/source/Enderal DLL/src/Patches/AttachLightHitEffectCrash.h +++ b/source/Enderal DLL/src/Patches/AttachLightHitEffectCrash.h @@ -29,9 +29,26 @@ namespace AttachLightHitEffectCrash void Install() { + if (!GetLoadInterface()->GetPluginInfo("po3_Tweaks")) { + // proceed normally + } else if (std::filesystem::exists("Data/SKSE/Plugins/po3_Tweaks.ini")) { + CSimpleIniA ini; + ini.SetMultiKey(false); + ini.LoadFile("Data/SKSE/Plugins/po3_Tweaks.ini"); + if (!ini.GetBoolValue("Fixes", "Light Attach Crash", false)) { + logger::info("Detected po3's Tweaks with disabled Light Attach Crash Fix"); + // proceed normally + } else { + logger::info("Detected po3's Tweaks with enabled Light Attach Crash Fix"); + return; + } + } + REL::Relocation func{ REL::RelocationID(33610, 34388) }; std::size_t size = REL::Module::get().version() > REL::Version(1, 5, 97, 0) ? 0xEC : 0x86; SKSE::stl::asm_replace(func.address(), size); + + logger::info("Initialized Light Attach Crash Fix"); } }