Skip the light attach crash fix when po3's Tweaks are loaded

This commit is contained in:
Eddoursul 2024-08-01 15:08:41 +02:00
parent 3e7d025eb7
commit c3e88fa508
2 changed files with 21 additions and 4 deletions

View File

@ -64,6 +64,10 @@ namespace {
if (message->type == MessagingInterface::kPostLoad) { if (message->type == MessagingInterface::kPostLoad) {
if (!REL::Module::IsVR()) { if (!REL::Module::IsVR()) {
if (g_settings.at("AttachLightHitEffectCrashFix")) {
logger::info("Installing light attach crash fix...");
AttachLightHitEffectCrash::Install();
}
if (g_settings.at("StayAtSystemPage")) { if (g_settings.at("StayAtSystemPage")) {
if (const auto pluginInfo = GetLoadInterface()->GetPluginInfo("StayAtSystemPage"); pluginInfo) { 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); 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..."); logger::info("Initializing Stay At The System Page...");
JournalMenuEx::InstallHooks(); JournalMenuEx::InstallHooks();
} }
if (g_settings.at("AttachLightHitEffectCrashFix")) {
logger::info("Installing light attach crash fix...");
AttachLightHitEffectCrash::Install();
}
} }
logger::info("{} has finished loading.", plugin->GetName()); logger::info("{} has finished loading.", plugin->GetName());

View File

@ -29,9 +29,26 @@ namespace AttachLightHitEffectCrash
void Install() 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<std::uintptr_t> func{ REL::RelocationID(33610, 34388) }; REL::Relocation<std::uintptr_t> func{ REL::RelocationID(33610, 34388) };
std::size_t size = REL::Module::get().version() > REL::Version(1, 5, 97, 0) ? 0xEC : 0x86; std::size_t size = REL::Module::get().version() > REL::Version(1, 5, 97, 0) ? 0xEC : 0x86;
SKSE::stl::asm_replace<AttachLightHitEffectVisitor>(func.address(), size); SKSE::stl::asm_replace<AttachLightHitEffectVisitor>(func.address(), size);
logger::info("Initialized Light Attach Crash Fix");
} }
} }