4
Fork 0

Moved C++ patches to a subdirectory

remove-levelsystem
Eddoursul 4 months ago
parent 85c1cc1b0c
commit 78ad540b93
  1. BIN
      SKSE/Plugins/EnderalSE.dll
  2. 2
      source/Enderal DLL/src/CheckInvalidForms.h
  3. 1
      source/Enderal DLL/src/EventListener.cpp
  4. 3
      source/Enderal DLL/src/EventListener.h
  5. 12
      source/Enderal DLL/src/Main.cpp
  6. 101
      source/Enderal DLL/src/PCH.h
  7. 2
      source/Enderal DLL/src/Papyrus.h
  8. 2
      source/Enderal DLL/src/PapyrusFunctions.h
  9. 6
      source/Enderal DLL/src/Patches/AchievementFix.h
  10. 5
      source/Enderal DLL/src/Patches/BinkInterruptPatch.h
  11. 12
      source/Enderal DLL/src/Patches/DialogueMenuPatch.h
  12. 6
      source/Enderal DLL/src/Patches/FlatMapMarkers.h
  13. 24
      source/Enderal DLL/src/Patches/HeroMenuPatch.cpp
  14. 10
      source/Enderal DLL/src/Patches/MapMarkerPlacement.h
  15. 2
      source/Enderal DLL/src/Patches/StayAtSystemPage.h
  16. 1
      source/Enderal DLL/src/Patches/TweenMenuPatch.h
  17. 8
      source/Enderal DLL/src/Util.h

BIN
SKSE/Plugins/EnderalSE.dll (Stored with Git LFS)

Binary file not shown.

@ -1,5 +1,7 @@
#pragma once
#include <unordered_set>
static bool bMessageShown = false;
static std::unordered_set<std::string> aModNames;

@ -1,5 +1,4 @@
#include "EventListener.h"
#include "Patches/HeroMenuPatch.h"
auto EventListener::GetSingleton() -> EventListener*
{

@ -1,6 +1,7 @@
#pragma once
#include "DialogueMenuPatch.h"
#include "Patches/DialogueMenuPatch.h"
#include "Patches/HeroMenuPatch.h"
#include "Util.h"
#include <shellapi.h>

@ -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"

@ -1,107 +1,10 @@
#pragma once
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfenv>
#include <cfloat>
#include <cinttypes>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdint>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cuchar>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <any>
#include <array>
#include <atomic>
#include <barrier>
#include <bit>
#include <bitset>
#include <charconv>
#include <chrono>
#include <compare>
#include <complex>
#include <concepts>
#include <condition_variable>
#include <deque>
#include <exception>
#include <execution>
#include <filesystem>
#include <format>
#include <forward_list>
#include <fstream>
#include <functional>
#include <future>
#include <initializer_list>
#include <iomanip>
#include <iosfwd>
#include <ios>
#include <iostream>
#include <istream>
#include <iterator>
#include <latch>
#include <limits>
#include <locale>
#include <map>
#include <memory>
#include <memory_resource>
#include <mutex>
#include <new>
#include <numbers>
#include <numeric>
#include <optional>
#include <ostream>
#include <queue>
#include <random>
#include <ranges>
#include <regex>
#include <ratio>
#include <scoped_allocator>
#include <semaphore>
#include <set>
#include <shared_mutex>
#include <source_location>
#include <span>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <string_view>
#include <syncstream>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <typeinfo>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <variant>
#include <vector>
#include <version>
#include <RE/Skyrim.h>
#include <SKSE/SKSE.h>
#include <REL/Relocation.h>
#include <ShlObj_core.h>
#include <Windows.h>
#include <Psapi.h>
#undef cdecl // Workaround for Clang 14 CMake configure error.
#include <spdlog/sinks/basic_file_sink.h>
@ -114,7 +17,3 @@ using namespace std::literals;
using namespace REL::literals;
namespace logger = SKSE::log;
namespace util {
using SKSE::stl::report_and_fail;
}

@ -2,8 +2,6 @@
#define BIND(a_method, ...) a_vm.RegisterFunction(#a_method##sv, script, a_method __VA_OPT__(, ) __VA_ARGS__)
#include <RE/Skyrim.h>
namespace Papyrus {
using VM = RE::BSScript::Internal::VirtualMachine;
using StackID = RE::VMStackID;

@ -2,7 +2,7 @@
#include "Util.h"
#include "PersistentFormManager.h"
#include "DialogueMenuPatch.h"
#include "Patches/DialogueMenuPatch.h"
namespace Papyrus::PapyrusFunctions
{

@ -2,19 +2,19 @@
namespace AchievementFix
{
constexpr std::uint8_t NOP{ 0x90 };
void Install()
{
REL::Relocation<std::uintptr_t> 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));
}
}

@ -35,10 +35,9 @@ namespace BinkInterruptPatch
void Install()
{
// Checked: 1.5.97, 1.6.640, 1.6.659, 1.6.1130
REL::Relocation<std::uintptr_t> 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);
}
}

@ -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_t> func{ REL::RelocationID(52428, 53327) };
func(a_bool);
}
using ProcessMessageFn = decltype(&ProcessMessage);
inline static REL::Relocation<ProcessMessageFn> _ProcessMessageFn;
};

@ -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<std::uintptr_t> 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);
}
}

@ -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<std::uintptr_t> 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<std::uintptr_t> 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<std::uintptr_t> 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<RE::BSScript::IStackCallbackFunctor> 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);
}

@ -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<std::uintptr_t> 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<std::uintptr_t> 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);

@ -54,5 +54,5 @@ public:
static inline REL::Relocation<decltype(&Hook_Accept)> _Accept;
static inline REL::Relocation<decltype(&Hook_ProcessMessage)> _ProcessMessage;
static inline REL::Relocation<Tab*> _savedTabIdx{ RELOCATION_ID(520167, 406697) };
static inline REL::Relocation<Tab*> _savedTabIdx{ REL::RelocationID(520167, 406697) };
};

@ -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_t> func{ REL::RelocationID(51845, 52718) };
return func(tweenMenu, index);
}

@ -162,14 +162,6 @@ inline void LoadINI(std::map<std::string, bool>* 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_t> func{ REL::RelocationID(52428, 53327) };
return func(a_bool);
}
inline void CloseTweenMenu()
{
if (RE::UI::GetSingleton()->IsMenuOpen(RE::TweenMenu::MENU_NAME)) {

Loading…
Cancel
Save