Skip to content

Commit

Permalink
Fix menu vtable offsets for different game versions
Browse files Browse the repository at this point in the history
  • Loading branch information
mwilsnd committed Oct 30, 2022
1 parent 7f3b3b5 commit bfa0c0f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 2 additions & 0 deletions SmoothCam/include/offset_ids.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,4 +222,6 @@ class Offsets {
uintptr_t UpdateGPUCameraData = 0;
uintptr_t CBuffer12 = 0;
uintptr_t GBuffer = 0;

uintptr_t menuHookOffset = 0;
};
8 changes: 4 additions & 4 deletions SmoothCam/source/hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ typedef RE::BSEventNotifyControl(__thiscall* MenuOpenCloseHandler)(uintptr_t pTh
static RE::BSEventNotifyControl mMenuOpenCloseHandler(uintptr_t pThis, RE::MenuOpenCloseEvent* ev,
RE::BSTEventSource<RE::MenuOpenCloseEvent>* dispatcher)
{
const auto menuOpenCloseHandler = reinterpret_cast<uintptr_t>(RE::PlayerCharacter::GetSingleton()) + 0x2B0;
const auto menuOpenCloseHandler = reinterpret_cast<uintptr_t>(RE::PlayerCharacter::GetSingleton()) + g_Offsets->menuHookOffset;
if (pThis == menuOpenCloseHandler) {
const auto mdmp = Debug::MiniDumpScope();

Expand Down Expand Up @@ -191,7 +191,7 @@ typedef RE::BSEventNotifyControl(__thiscall* MenuModeChangeHandler)(uintptr_t pT
static RE::BSEventNotifyControl mMenuModeChangeHandler(uintptr_t pThis, MenuModeChangeEvent* ev,
RE::BSTEventSource<MenuModeChangeEvent>* dispatcher)
{
const auto menuModeChangeHandler = reinterpret_cast<uintptr_t>(RE::PlayerCharacter::GetSingleton()) + 0x2B8;
const auto menuModeChangeHandler = reinterpret_cast<uintptr_t>(RE::PlayerCharacter::GetSingleton()) + g_Offsets->menuHookOffset + 8;
if (pThis == menuModeChangeHandler) {
const auto mdmp = Debug::MiniDumpScope();
if (!ev->name.empty())
Expand Down Expand Up @@ -360,7 +360,7 @@ bool Hooks::DeferredAttach() {

menuOpenCloseHook = eastl::make_unique<VTableDetour<PlayerMenuOpenCloseEvent>>(
reinterpret_cast<PlayerMenuOpenCloseEvent*>(
reinterpret_cast<uintptr_t>(RE::PlayerCharacter::GetSingleton()) + 0x2B8
reinterpret_cast<uintptr_t>(RE::PlayerCharacter::GetSingleton()) + g_Offsets->menuHookOffset
)
);
menuOpenCloseHook->Add(1, mMenuOpenCloseHandler);
Expand All @@ -369,7 +369,7 @@ bool Hooks::DeferredAttach() {

menuModeChangeHook = eastl::make_unique<VTableDetour<PlayerMenuModeChangeEvent>>(
reinterpret_cast<PlayerMenuModeChangeEvent*>(
reinterpret_cast<uintptr_t>(RE::PlayerCharacter::GetSingleton()) + 0x2C0
reinterpret_cast<uintptr_t>(RE::PlayerCharacter::GetSingleton()) + g_Offsets->menuHookOffset + 8
)
);
menuModeChangeHook->Add(1, mMenuModeChangeHandler);
Expand Down
6 changes: 6 additions & 0 deletions SmoothCam/source/offset_ids.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ Offsets::Offsets() noexcept {
#else
populateSE();
#endif

#if defined(SKYRIM_SUPPORT_AE) && !defined(SKYRIM_IS_PRE629)
menuHookOffset = 0x2B8;
#else
menuHookOffset = 0x2B0;
#endif
}

#ifdef SKYRIM_SUPPORT_AE
Expand Down

0 comments on commit bfa0c0f

Please sign in to comment.