From 8a4e3ef71bb339cc9c39d2d9ccb4271b52d1e967 Mon Sep 17 00:00:00 2001 From: Eddoursul Date: Mon, 11 Dec 2023 01:43:01 +0100 Subject: [PATCH] Added an achievement fix 1.5.97-1.6.1130 --- SKSE/Plugins/EnderalSE.dll | 4 ++-- SKSE/Plugins/EnderalSE.ini | 1 + source/Enderal DLL/src/AchievementFix.h | 20 ++++++++++++++++++++ source/Enderal DLL/src/Main.cpp | 9 ++++++++- 4 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 source/Enderal DLL/src/AchievementFix.h diff --git a/SKSE/Plugins/EnderalSE.dll b/SKSE/Plugins/EnderalSE.dll index 291f51f9..82b84246 100644 --- a/SKSE/Plugins/EnderalSE.dll +++ b/SKSE/Plugins/EnderalSE.dll @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6ab861df47b2f179f3027237b840764dd31fe1cac6d636587698d9a2f28d386f -size 730624 +oid sha256:ece6ce0175d4726a9a3d39a215bf7e9b1b8f82b16a7493872b88a0d08cd1453d +size 731136 diff --git a/SKSE/Plugins/EnderalSE.ini b/SKSE/Plugins/EnderalSE.ini index 0583456b..41d5266f 100644 --- a/SKSE/Plugins/EnderalSE.ini +++ b/SKSE/Plugins/EnderalSE.ini @@ -1,3 +1,4 @@ FlatMapMarkers = true StayAtSystemPage = true MapMarkerPlacementFixes = true +AchievementFix = true diff --git a/source/Enderal DLL/src/AchievementFix.h b/source/Enderal DLL/src/AchievementFix.h new file mode 100644 index 00000000..09d20ce5 --- /dev/null +++ b/source/Enderal DLL/src/AchievementFix.h @@ -0,0 +1,20 @@ +#pragma once + +namespace AchievementFix +{ + constexpr std::uint8_t NOP{ 0x90 }; + + void Install() + { + REL::Relocation target; + + if (GetLoadInterface()->RuntimeVersion().minor() > 6 || GetLoadInterface()->RuntimeVersion().patch() >= 1130) { + target = REL::ID(441528); + } else { + target = REL::RelocationID(13647, 13755); + } + + std::uint8_t code[] = { 0xB0, 0x00, 0xC3, NOP }; + REL::safe_write(target.address(), code, 4); + } +} diff --git a/source/Enderal DLL/src/Main.cpp b/source/Enderal DLL/src/Main.cpp index 45ac83b7..ee9031d8 100644 --- a/source/Enderal DLL/src/Main.cpp +++ b/source/Enderal DLL/src/Main.cpp @@ -4,13 +4,15 @@ #include "FlatMapMarkers.h" #include "StayAtSystemPage.h" #include "MapMarkerPlacement.h" +#include "AchievementFix.h" using namespace SKSE; static std::map g_settings{ { "FlatMapMarkers", true }, { "StayAtSystemPage", true }, - { "MapMarkerPlacementFixes", true } + { "MapMarkerPlacementFixes", true }, + { "AchievementFix", true } }; namespace { @@ -150,6 +152,11 @@ SKSEPluginLoad(const LoadInterface* skse) { GetPapyrusInterface()->Register(Papyrus::Bind); + if (g_settings.at("AchievementFix")) { + logger::info("Patching achievements..."); + AchievementFix::Install(); + } + if (!IsVR()) { if (g_settings.at("FlatMapMarkers")) { logger::info("Initializing Flat Map Markers...");