diff --git a/SKSE/Plugins/EnderalSE.dll b/SKSE/Plugins/EnderalSE.dll index 976944bf..f23149c5 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:368b4dcbf1e1d3a8cd8cf062ba175a1fdcf0d9d0e072f0fcbf0d66810da776f5 +oid sha256:3a5e81937a9e0b16b51b715425bf77bea55e320aa9985ef8ec61bed02eaa6f3e size 751616 diff --git a/source/Enderal DLL/src/CheckInvalidForms.h b/source/Enderal DLL/src/CheckInvalidForms.h index 423a3b80..e22ec665 100644 --- a/source/Enderal DLL/src/CheckInvalidForms.h +++ b/source/Enderal DLL/src/CheckInvalidForms.h @@ -1,5 +1,7 @@ #pragma once +#include + static bool bMessageShown = false; static std::unordered_set aModNames; diff --git a/source/Enderal DLL/src/EventListener.cpp b/source/Enderal DLL/src/EventListener.cpp index bc93217c..f2fe11ee 100644 --- a/source/Enderal DLL/src/EventListener.cpp +++ b/source/Enderal DLL/src/EventListener.cpp @@ -1,5 +1,4 @@ #include "EventListener.h" -#include "Patches/HeroMenuPatch.h" auto EventListener::GetSingleton() -> EventListener* { diff --git a/source/Enderal DLL/src/EventListener.h b/source/Enderal DLL/src/EventListener.h index 6c170628..3edd03bb 100644 --- a/source/Enderal DLL/src/EventListener.h +++ b/source/Enderal DLL/src/EventListener.h @@ -1,6 +1,7 @@ #pragma once -#include "DialogueMenuPatch.h" +#include "Patches/DialogueMenuPatch.h" +#include "Patches/HeroMenuPatch.h" #include "Util.h" #include diff --git a/source/Enderal DLL/src/Main.cpp b/source/Enderal DLL/src/Main.cpp index 4997a5e4..ce9a0cf7 100644 --- a/source/Enderal DLL/src/Main.cpp +++ b/source/Enderal DLL/src/Main.cpp @@ -1,12 +1,12 @@ #include "EventListener.h" #include "Util.h" #include "Papyrus.h" -#include "FlatMapMarkers.h" -#include "StayAtSystemPage.h" -#include "MapMarkerPlacement.h" -#include "AchievementFix.h" -#include "BinkInterruptPatch.h" -#include "DialogueMenuPatch.h" +#include "Patches/FlatMapMarkers.h" +#include "Patches/StayAtSystemPage.h" +#include "Patches/MapMarkerPlacement.h" +#include "Patches/AchievementFix.h" +#include "Patches/BinkInterruptPatch.h" +#include "Patches/DialogueMenuPatch.h" #include "Patches/TweenMenuPatch.h" #include "Patches/HeroMenuPatch.h" #include "Patches/HUDMenuPatch.h" diff --git a/source/Enderal DLL/src/PCH.h b/source/Enderal DLL/src/PCH.h index eed4d90a..98479db5 100644 --- a/source/Enderal DLL/src/PCH.h +++ b/source/Enderal DLL/src/PCH.h @@ -1,107 +1,10 @@ #pragma once -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include #include #include #include -#include -#include #undef cdecl // Workaround for Clang 14 CMake configure error. #include @@ -114,7 +17,3 @@ using namespace std::literals; using namespace REL::literals; namespace logger = SKSE::log; - -namespace util { - using SKSE::stl::report_and_fail; -} diff --git a/source/Enderal DLL/src/Papyrus.h b/source/Enderal DLL/src/Papyrus.h index 73bc20c5..97de513d 100644 --- a/source/Enderal DLL/src/Papyrus.h +++ b/source/Enderal DLL/src/Papyrus.h @@ -2,8 +2,6 @@ #define BIND(a_method, ...) a_vm.RegisterFunction(#a_method##sv, script, a_method __VA_OPT__(, ) __VA_ARGS__) -#include - namespace Papyrus { using VM = RE::BSScript::Internal::VirtualMachine; using StackID = RE::VMStackID; diff --git a/source/Enderal DLL/src/PapyrusFunctions.h b/source/Enderal DLL/src/PapyrusFunctions.h index f36360d5..4dec027c 100644 --- a/source/Enderal DLL/src/PapyrusFunctions.h +++ b/source/Enderal DLL/src/PapyrusFunctions.h @@ -2,7 +2,7 @@ #include "Util.h" #include "PersistentFormManager.h" -#include "DialogueMenuPatch.h" +#include "Patches/DialogueMenuPatch.h" namespace Papyrus::PapyrusFunctions { diff --git a/source/Enderal DLL/src/AchievementFix.h b/source/Enderal DLL/src/Patches/AchievementFix.h similarity index 75% rename from source/Enderal DLL/src/AchievementFix.h rename to source/Enderal DLL/src/Patches/AchievementFix.h index 484fd338..72f7c81f 100644 --- a/source/Enderal DLL/src/AchievementFix.h +++ b/source/Enderal DLL/src/Patches/AchievementFix.h @@ -2,19 +2,19 @@ namespace AchievementFix { - constexpr std::uint8_t NOP{ 0x90 }; - void Install() { REL::Relocation target; if (GetLoadInterface()->RuntimeVersion().minor() > 6 || GetLoadInterface()->RuntimeVersion().patch() >= 1130) { + // Checked: 1.6.1130 target = REL::ID(441528); } else { + // Checked: 1.5.97, 1.6.640, 1.6.659 target = REL::RelocationID(13647, 13755); } - std::uint8_t code[] = { 0xB0, 0x00, 0xC3, NOP }; + std::uint8_t code[] = { 0xB0, 0x00, 0xC3, REL::NOP }; REL::safe_write(target.address(), code, sizeof(code)); } } diff --git a/source/Enderal DLL/src/BinkInterruptPatch.h b/source/Enderal DLL/src/Patches/BinkInterruptPatch.h similarity index 88% rename from source/Enderal DLL/src/BinkInterruptPatch.h rename to source/Enderal DLL/src/Patches/BinkInterruptPatch.h index b775e134..0a6b1ad6 100644 --- a/source/Enderal DLL/src/BinkInterruptPatch.h +++ b/source/Enderal DLL/src/Patches/BinkInterruptPatch.h @@ -35,10 +35,9 @@ namespace BinkInterruptPatch void Install() { + // Checked: 1.5.97, 1.6.640, 1.6.659, 1.6.1130 REL::Relocation target{ REL::RelocationID(87890, 90259), REL::Relocate(0x22, 0x21) }; - auto& trampoline = SKSE::GetTrampoline(); - SKSE::AllocTrampoline(14); - BinkListener::func = trampoline.write_call<5>(target.address(), BinkListener::thunk); + BinkListener::func = SKSE::GetTrampoline().write_call<5>(target.address(), BinkListener::thunk); } } diff --git a/source/Enderal DLL/src/DialogueMenuPatch.h b/source/Enderal DLL/src/Patches/DialogueMenuPatch.h similarity index 77% rename from source/Enderal DLL/src/DialogueMenuPatch.h rename to source/Enderal DLL/src/Patches/DialogueMenuPatch.h index cc309ef2..bb152ab5 100644 --- a/source/Enderal DLL/src/DialogueMenuPatch.h +++ b/source/Enderal DLL/src/Patches/DialogueMenuPatch.h @@ -1,7 +1,5 @@ #pragma once -#include "Util.h" - inline bool bTabBlocked = false; class DialogueMenuPatch final : public RE::DialogueMenu @@ -38,7 +36,15 @@ private: return _ProcessMessageFn(this, a_message); } - using ProcessMessageFn = decltype(&RE::DialogueMenu::ProcessMessage); + // When opening from dialogue menu, a_bool must be false to not break framerate of the UI + void static OpenJournal(bool a_bool) + { + using func_t = decltype(&OpenJournal); + // Checked: 1.5.97, 1.6.640, 1.6.659, 1.6.1130 + REL::Relocation func{ REL::RelocationID(52428, 53327) }; + func(a_bool); + } + using ProcessMessageFn = decltype(&ProcessMessage); inline static REL::Relocation _ProcessMessageFn; }; diff --git a/source/Enderal DLL/src/FlatMapMarkers.h b/source/Enderal DLL/src/Patches/FlatMapMarkers.h similarity index 82% rename from source/Enderal DLL/src/FlatMapMarkers.h rename to source/Enderal DLL/src/Patches/FlatMapMarkers.h index a9889a5a..eb218c41 100644 --- a/source/Enderal DLL/src/FlatMapMarkers.h +++ b/source/Enderal DLL/src/Patches/FlatMapMarkers.h @@ -1,7 +1,5 @@ #pragma once -#include "Util.h" - // Based on Ryan McKenzie's Flat Map Markers // CommonLibSSE-NG update by Eddoursul namespace FlatMapMarkers @@ -14,9 +12,9 @@ namespace FlatMapMarkers inline void Install() { + // Checked: 1.5.97, 1.6.640, 1.6.659, 1.6.1130 REL::Relocation offset{ REL::RelocationID(52224, 53111), REL::Relocate(0x22F, 0x21F) }; SKSE::AllocTrampoline(14); - auto& trampoline = SKSE::GetTrampoline(); - trampoline.write_call<5>(offset.address(), &Hook_WorldPtToScreenPt3); + SKSE::GetTrampoline().write_call<5>(offset.address(), &Hook_WorldPtToScreenPt3); } } diff --git a/source/Enderal DLL/src/Patches/HeroMenuPatch.cpp b/source/Enderal DLL/src/Patches/HeroMenuPatch.cpp index c1f01fab..990ee0f2 100644 --- a/source/Enderal DLL/src/Patches/HeroMenuPatch.cpp +++ b/source/Enderal DLL/src/Patches/HeroMenuPatch.cpp @@ -5,8 +5,10 @@ RE::BSEventNotifyControl HeroMenuPatch::ProcessEvent_Hook(RE::InputEvent** a_eve if (RE::UI::GetSingleton()->GameIsPaused() && a_event && *a_event) { auto buttonEvent = (*a_event)->AsButtonEvent(); if (buttonEvent && buttonEvent->IsDown() && RE::UI::GetSingleton()->IsMenuOpen("CustomMenu")) { + auto& eventName = (*a_event)->QUserEvent(); auto userEvents = RE::UserEvents::GetSingleton(); + if (eventName == userEvents->cancel || eventName == userEvents->quickStats) { auto uiMovie = RE::UI::GetSingleton()->GetMovieView("CustomMenu"); if (uiMovie && std::strstr(uiMovie->GetMovieDef()->GetFileURL(), "00e_heromenu.swf") != NULL) { @@ -21,17 +23,17 @@ RE::BSEventNotifyControl HeroMenuPatch::ProcessEvent_Hook(RE::InputEvent** a_eve void HeroMenuPatch::Install() { - // Patch MenuControls + // Patch MenuControls to close the menu REL::Relocation vTable(RE::VTABLE_MenuControls[0]); _ProcessEvent = vTable.write_vfunc(0x1, &HeroMenuPatch::ProcessEvent_Hook); - // Patch the Quick Stats hotkey + // Patch the Quick Stats hotkey to open the menu + // Checked: 1.5.97, 1.6.640, 1.6.659, 1.6.1130 REL::Relocation target{ REL::RelocationID(51400, 52249), REL::Relocate(0x41E, 0x421) }; REL::safe_fill(target.address(), REL::NOP, 45); - auto& trampoline = SKSE::GetTrampoline(); SKSE::AllocTrampoline(14); - _OpenStats = trampoline.write_call<5>(target.address(), OpenStats); + _OpenStats = SKSE::GetTrampoline().write_call<5>(target.address(), OpenStats); REL::Relocation target2{ REL::RelocationID(51400, 52249), REL::Relocate(0x436, 0x439) }; std::uint8_t code[] = { 0x40, 0xB5, 0x01 }; @@ -60,7 +62,7 @@ void HeroMenuPatch::FillMenuValues() if (a_result.IsString()) { auto uiMovie = RE::UI::GetSingleton()->GetMovieView("CustomMenu"); if (uiMovie) { - uiMovie->SetVariable("_root.heromenu_mc.stats.playerclass.stat_value.text", a_result.GetString()); + uiMovie->SetVariable("heromenu_mc.stats.playerclass.stat_value.text", a_result.GetString(), RE::GFxMovie::SetVarType::kNormal); } } } @@ -69,6 +71,12 @@ void HeroMenuPatch::FillMenuValues() }; auto uiMovie = RE::UI::GetSingleton()->GetMovieView("CustomMenu"); + + if (!uiMovie) { + return; + } + + // Fit the movie into the screen (widescreen support) uiMovie->SetViewScaleMode(RE::BSScaleformManager::ScaleModeType::kShowAll); const auto dataHandler = RE::TESDataHandler::GetSingleton(); @@ -89,7 +97,7 @@ void HeroMenuPatch::FillMenuValues() RE::GFxValue args[2]; args[0].SetString(player->GetDisplayFullName()); args[1].SetString(""); - uiMovie->Invoke("_root.heromenu_mc.SetStringValues", nullptr, args, 2); + uiMovie->Invoke("heromenu_mc.SetStringValues", nullptr, args, 2); RE::BSTSmartPointer stackCallback{ new ScriptClassNameCallback }; RE::BSScript::Internal::VirtualMachine::GetSingleton()->DispatchStaticCall("_00E_AffinityControl", "GetPlayerClassNameGlobal", RE::MakeFunctionArguments(), stackCallback); @@ -129,7 +137,7 @@ void HeroMenuPatch::FillMenuValues() args2[31].SetNumber(playerExp->value - fEXPNeededForCurrentLevel); args2[32].SetNumber(fEXPNeededForNextLevel - fEXPNeededForCurrentLevel); - uiMovie->Invoke("_root.heromenu_mc.SetIntValues", nullptr, args2, 33); + uiMovie->Invoke("heromenu_mc.SetIntValues", nullptr, args2, 33); RE::GFxValue args3[21]; args3[0].SetNumber(0); @@ -153,5 +161,5 @@ void HeroMenuPatch::FillMenuValues() args3[18].SetNumber(playerAV->GetActorValue(RE::ActorValue::kEnchanting) - playerAV->GetBaseActorValue(RE::ActorValue::kEnchanting)); args3[19].SetNumber(playerAV->GetActorValue(RE::ActorValue::kSmithing) - playerAV->GetBaseActorValue(RE::ActorValue::kSmithing)); args3[20].SetNumber(playerAV->GetActorValue(RE::ActorValue::kSpeech) - playerAV->GetBaseActorValue(RE::ActorValue::kSpeech)); - uiMovie->Invoke("_root.heromenu_mc.SetModifier", nullptr, args3, 21); + uiMovie->Invoke("heromenu_mc.SetModifier", nullptr, args3, 21); } diff --git a/source/Enderal DLL/src/MapMarkerPlacement.h b/source/Enderal DLL/src/Patches/MapMarkerPlacement.h similarity index 89% rename from source/Enderal DLL/src/MapMarkerPlacement.h rename to source/Enderal DLL/src/Patches/MapMarkerPlacement.h index 1bf9db0e..100b2589 100644 --- a/source/Enderal DLL/src/MapMarkerPlacement.h +++ b/source/Enderal DLL/src/Patches/MapMarkerPlacement.h @@ -21,12 +21,10 @@ namespace MapMarkerPlacement void InstallPlacementDiscoveredFix() { // Place a marker, if a location has been discovered and fast travel is disabled - + // Checked: 1.5.97, 1.6.640, 1.6.659, 1.6.1130 REL::Relocation target{ REL::RelocationID(52208, 53095), REL::Relocate(0x2C5, 0x328, 0x358) }; - auto& trampoline = SKSE::GetTrampoline(); - SKSE::AllocTrampoline(14); - IsFastTravelEnabled::func = trampoline.write_call<5>(target.address(), IsFastTravelEnabled::thunk); + IsFastTravelEnabled::func = SKSE::GetTrampoline().write_call<5>(target.address(), IsFastTravelEnabled::thunk); logger::info("Applied discovered map marker placement fix"sv); } @@ -34,9 +32,9 @@ namespace MapMarkerPlacement void InstallPlacementUndiscoveredFix() { // Place a marker without asking, if a location isn't discovered yet - + // Checked: 1.5.97, 1.6.640, 1.6.659, 1.6.1130 REL::Relocation target2{ REL::RelocationID(52208, 53095), REL::Relocate(0x17A, 0x183) }; - std::uint8_t code[] = { 0xB0, 0x01, REL::NOP, REL::NOP, REL::NOP }; + std::uint8_t code[] = { 0xB0, 0x01, REL::NOP, REL::NOP, REL::NOP }; // mov al,0x1 REL::safe_write(target2.address(), code, sizeof(code)); logger::info("Applied undiscovered map marker placement fix"sv); diff --git a/source/Enderal DLL/src/StayAtSystemPage.h b/source/Enderal DLL/src/Patches/StayAtSystemPage.h similarity index 94% rename from source/Enderal DLL/src/StayAtSystemPage.h rename to source/Enderal DLL/src/Patches/StayAtSystemPage.h index 38cfd205..21e90e7d 100644 --- a/source/Enderal DLL/src/StayAtSystemPage.h +++ b/source/Enderal DLL/src/Patches/StayAtSystemPage.h @@ -54,5 +54,5 @@ public: static inline REL::Relocation _Accept; static inline REL::Relocation _ProcessMessage; - static inline REL::Relocation _savedTabIdx{ RELOCATION_ID(520167, 406697) }; + static inline REL::Relocation _savedTabIdx{ REL::RelocationID(520167, 406697) }; }; diff --git a/source/Enderal DLL/src/Patches/TweenMenuPatch.h b/source/Enderal DLL/src/Patches/TweenMenuPatch.h index 347a34c2..5399d0b0 100644 --- a/source/Enderal DLL/src/Patches/TweenMenuPatch.h +++ b/source/Enderal DLL/src/Patches/TweenMenuPatch.h @@ -11,6 +11,7 @@ private: static void OpenMenu(RE::IMenu* tweenMenu, std::int32_t index) { using func_t = decltype(&OpenMenu); + // Checked: 1.5.97, 1.6.640, 1.6.659, 1.6.1130 REL::Relocation func{ REL::RelocationID(51845, 52718) }; return func(tweenMenu, index); } diff --git a/source/Enderal DLL/src/Util.h b/source/Enderal DLL/src/Util.h index 83c3e9c1..c852df8d 100644 --- a/source/Enderal DLL/src/Util.h +++ b/source/Enderal DLL/src/Util.h @@ -162,14 +162,6 @@ inline void LoadINI(std::map* settings, const char* iniPath) } } -// When opening from dialogue menu, a_bool must be false to not break framerate of the UI -inline void OpenJournal(bool a_bool) -{ - using func_t = decltype(&OpenJournal); - REL::Relocation func{ REL::RelocationID(52428, 53327) }; - return func(a_bool); -} - inline void CloseTweenMenu() { if (RE::UI::GetSingleton()->IsMenuOpen(RE::TweenMenu::MENU_NAME)) {