From 9404cd85b5e0b1d4523a5f7bb7519b63bd455cd0 Mon Sep 17 00:00:00 2001 From: RunnerScrab Date: Tue, 4 Nov 2025 22:24:45 -0600 Subject: [PATCH 1/2] ActorEquipManager::Singleton ActorValue::GetSingleton BGSInventoryInterface::Singleton BGSInventoryInterface::GetInventoryObject() BGSObjectInstance ctor BSNonReentrantSpinLock::TryLock(), Unlock() Replace typedefs for function object types with usings --- include/RE/B/BGSInventoryInterface.h | 18 ++++++++++++++---- include/RE/IDs.h | 24 +++++++++++++----------- src/RE/B/BSLock.cpp | 10 ++++------ src/RE/O/Object.cpp | 7 ++++--- 4 files changed, 35 insertions(+), 24 deletions(-) diff --git a/include/RE/B/BGSInventoryInterface.h b/include/RE/B/BGSInventoryInterface.h index bee48191..f6dac7f1 100644 --- a/include/RE/B/BGSInventoryInterface.h +++ b/include/RE/B/BGSInventoryInterface.h @@ -54,17 +54,27 @@ namespace RE return *singleton; } + [[nodiscard]] TESBoundObject* GetInventoryObject(const std::uint32_t& a_handleID) const { - using func_t = decltype(&BGSInventoryInterface::GetInventoryObject); - static REL::Relocation func{ ID::BGSInventoryInterface::GetInventoryObject }; - return func(this, a_handleID); + using func_t = bool (*)(const BGSInventoryInterface*, const std::uint32_t*, std::uint64_t***); + static REL::Relocation subfn{ ID::BGSInventoryInterface::GetInventoryObjectSub }; + + std::uint32_t handle = a_handleID; + std::uint64_t out = 0; + std::uint64_t* outarr[2]; + std::uint64_t** pout; + outarr[0] = &out; + pout = (std::uint64_t**) &outarr; + subfn(this, &handle, &pout); + return reinterpret_cast(out); } virtual ~BGSInventoryInterface(); // 00 // members - BSTArray agentArray; // 30 + std::uint64_t unk30; // 30 + BSTArray agentArray; // 38 }; //static_assert(sizeof(BGSInventoryInterface) == 0x48); } diff --git a/include/RE/IDs.h b/include/RE/IDs.h index 32963ac3..10ca944c 100644 --- a/include/RE/IDs.h +++ b/include/RE/IDs.h @@ -32,24 +32,24 @@ namespace RE::ID namespace ActorValue { - inline constexpr REL::ID GetSingleton{ 0 }; // 36266 + inline constexpr REL::ID GetSingleton{ 43134 }; // 36266 } namespace ActorEquipManager { - inline constexpr REL::ID Singleton{ 0 }; // 879425 - inline constexpr REL::ID EquipObject{ 0 }; // 151991 - inline constexpr REL::ID UnequipObject{ 0 }; // 152007 + inline constexpr REL::ID Singleton{ 938503 }; // 879425 + inline constexpr REL::ID EquipObject{ 0 }; // 151991 -> TODO: Verify 101949 in 1.15 + inline constexpr REL::ID UnequipObject{ 0 }; // 152007 -> TODO: Verify 101951 in 1.15 } namespace ActorCellChangeEvent::Event { - inline constexpr REL::ID GetEventSource{ 0 }; // 107081 + inline constexpr REL::ID GetEventSource{ 64106 }; // 107081 } namespace ActorItemEquipped::Event { - inline constexpr REL::ID GetEventSource{ 0 }; // 151162 + inline constexpr REL::ID GetEventSource{ 100427 }; // 151162 } namespace AttachReference::Event @@ -140,13 +140,14 @@ namespace RE::ID namespace BGSInventoryInterface { - inline constexpr REL::ID Singleton{ 0 }; // 825787 - inline constexpr REL::ID GetInventoryObject{ 0 }; // 87520 + inline constexpr REL::ID Singleton{ 883301 }; // 825787 + inline constexpr REL::ID GetInventoryObject{ 0 }; // 87520 - inlined + inline constexpr REL::ID GetInventoryObjectSub{ 63846 }; } namespace BGSObjectInstance { - inline constexpr REL::ID ctor{ 0 }; // 101725 + inline constexpr REL::ID ctor{ 59786 }; // 101725 } namespace BGSPlanet::PlayerKnowledgeFlagSetEvent @@ -247,8 +248,9 @@ namespace RE::ID namespace BSNonReentrantSpinLock { inline constexpr REL::ID Lock{ 37396 }; - inline constexpr REL::ID TryLock{ 0 }; // 74235 - inlined? - inline constexpr REL::ID Unlock{ 0 }; // 73895 - inlined? + inline constexpr REL::ID TryLock{ 0 }; // 74235 - inlined + inline constexpr REL::ID Unlock{ 0 }; // 73895 - inlined + inline constexpr REL::ID UnlockSubroutine{ 37393 }; } namespace BSPointerHandleManagerInterface diff --git a/src/RE/B/BSLock.cpp b/src/RE/B/BSLock.cpp index 8bd0d329..552d18f8 100644 --- a/src/RE/B/BSLock.cpp +++ b/src/RE/B/BSLock.cpp @@ -11,16 +11,14 @@ namespace RE bool BSNonReentrantSpinLock::TryLock() { - using func_t = decltype(&BSNonReentrantSpinLock::TryLock); - static REL::Relocation func{ ID::BSNonReentrantSpinLock::TryLock }; - return func(this); + return _InterlockedOr(reinterpret_cast(&this->m_lock), 1) == 0; } void BSNonReentrantSpinLock::Unlock() { - using func_t = decltype(&BSNonReentrantSpinLock::Unlock); - static REL::Relocation func{ ID::BSNonReentrantSpinLock::Unlock }; - return func(this); + using func_t = int (*)(BSNonReentrantSpinLock*, std::int32_t, std::int8_t); + static REL::Relocation func{ ID::BSNonReentrantSpinLock::UnlockSubroutine }; + func(this, 1, 2); } void BSReadWriteLock::LockRead() diff --git a/src/RE/O/Object.cpp b/src/RE/O/Object.cpp index 995c0e4f..09e75011 100644 --- a/src/RE/O/Object.cpp +++ b/src/RE/O/Object.cpp @@ -4,9 +4,10 @@ namespace RE::BSScript { void Object::dtor() { - static REL::Relocation UnkObjectDtorSubroutine{ ID::BSScript::Object::dtorUnkSub }; - typedef ObjectTypeInfo* (*ObjectTypeInfoDeallocator)(ObjectTypeInfo*, std::uint32_t); - static REL::Relocation ObjectTypeInfoDealloc{ ID::BSScript::ObjectTypeInfo::dtor }; + using func_t = decltype(&Object::dtor); + using func2_t = ObjectTypeInfo* (*)(ObjectTypeInfo*, std::uint32_t); + static REL::Relocation UnkObjectDtorSubroutine{ ID::BSScript::Object::dtorUnkSub }; + static REL::Relocation ObjectTypeInfoDealloc{ ID::BSScript::ObjectTypeInfo::dtor }; this->lockStructure = reinterpret_cast(reinterpret_cast(this->lockStructure) & 0xfffffffffffffffe); From e00162ded4dbbd568469424658e55276554dfd4f Mon Sep 17 00:00:00 2001 From: RunnerScrab <45054749+RunnerScrab@users.noreply.github.com> Date: Thu, 6 Nov 2025 17:17:09 +0000 Subject: [PATCH 2/2] maintenance --- include/RE/B/BGSInventoryInterface.h | 9 ++++----- include/RE/IDs.h | 6 +++--- src/RE/O/Object.cpp | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/include/RE/B/BGSInventoryInterface.h b/include/RE/B/BGSInventoryInterface.h index f6dac7f1..107b49bb 100644 --- a/include/RE/B/BGSInventoryInterface.h +++ b/include/RE/B/BGSInventoryInterface.h @@ -54,18 +54,17 @@ namespace RE return *singleton; } - [[nodiscard]] TESBoundObject* GetInventoryObject(const std::uint32_t& a_handleID) const { using func_t = bool (*)(const BGSInventoryInterface*, const std::uint32_t*, std::uint64_t***); static REL::Relocation subfn{ ID::BGSInventoryInterface::GetInventoryObjectSub }; - std::uint32_t handle = a_handleID; - std::uint64_t out = 0; - std::uint64_t* outarr[2]; + std::uint32_t handle = a_handleID; + std::uint64_t out = 0; + std::uint64_t* outarr[2]; std::uint64_t** pout; outarr[0] = &out; - pout = (std::uint64_t**) &outarr; + pout = (std::uint64_t**)&outarr; subfn(this, &handle, &pout); return reinterpret_cast(out); } diff --git a/include/RE/IDs.h b/include/RE/IDs.h index 10ca944c..105b152b 100644 --- a/include/RE/IDs.h +++ b/include/RE/IDs.h @@ -38,8 +38,8 @@ namespace RE::ID namespace ActorEquipManager { inline constexpr REL::ID Singleton{ 938503 }; // 879425 - inline constexpr REL::ID EquipObject{ 0 }; // 151991 -> TODO: Verify 101949 in 1.15 - inline constexpr REL::ID UnequipObject{ 0 }; // 152007 -> TODO: Verify 101951 in 1.15 + inline constexpr REL::ID EquipObject{ 0 }; // 151991 -> TODO: Verify 101949 in 1.15 + inline constexpr REL::ID UnequipObject{ 0 }; // 152007 -> TODO: Verify 101951 in 1.15 } namespace ActorCellChangeEvent::Event @@ -249,7 +249,7 @@ namespace RE::ID { inline constexpr REL::ID Lock{ 37396 }; inline constexpr REL::ID TryLock{ 0 }; // 74235 - inlined - inline constexpr REL::ID Unlock{ 0 }; // 73895 - inlined + inline constexpr REL::ID Unlock{ 0 }; // 73895 - inlined inline constexpr REL::ID UnlockSubroutine{ 37393 }; } diff --git a/src/RE/O/Object.cpp b/src/RE/O/Object.cpp index 09e75011..833765a6 100644 --- a/src/RE/O/Object.cpp +++ b/src/RE/O/Object.cpp @@ -6,7 +6,7 @@ namespace RE::BSScript { using func_t = decltype(&Object::dtor); using func2_t = ObjectTypeInfo* (*)(ObjectTypeInfo*, std::uint32_t); - static REL::Relocation UnkObjectDtorSubroutine{ ID::BSScript::Object::dtorUnkSub }; + static REL::Relocation UnkObjectDtorSubroutine{ ID::BSScript::Object::dtorUnkSub }; static REL::Relocation ObjectTypeInfoDealloc{ ID::BSScript::ObjectTypeInfo::dtor }; this->lockStructure =