From b83bbafca44cb200a0f6a41af0f3a1ff4b732fc5 Mon Sep 17 00:00:00 2001 From: RunnerScrab Date: Thu, 6 Nov 2025 21:06:28 -0600 Subject: [PATCH 1/2] Rewrite inscrutable GetInventoryObject function --- include/RE/B/BGSInventoryInterface.h | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/include/RE/B/BGSInventoryInterface.h b/include/RE/B/BGSInventoryInterface.h index 107b49b..1b764d2 100644 --- a/include/RE/B/BGSInventoryInterface.h +++ b/include/RE/B/BGSInventoryInterface.h @@ -56,17 +56,22 @@ namespace RE [[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 }; + struct UnkStruct + { + TESBoundObject** ppObj; + std::uint64_t unk08; + }; 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); + TESBoundObject* pObj = 0; + UnkStruct outstruct = { .ppObj = &pObj, .unk08 = 0 }; + UnkStruct* pOutstruct = &outstruct; + + using func_t = bool (*)(const BGSInventoryInterface*, const std::uint32_t*, UnkStruct**); + static REL::Relocation GetInventoryObjectHelperFn { ID::BGSInventoryInterface::GetInventoryObjectSub }; + GetInventoryObjectHelperFn(this, &handle, &pOutstruct); + + return pObj; } virtual ~BGSInventoryInterface(); // 00 From fd90392e05684b3d304bc32dededc7cd550558a0 Mon Sep 17 00:00:00 2001 From: RunnerScrab <45054749+RunnerScrab@users.noreply.github.com> Date: Fri, 7 Nov 2025 03:12:08 +0000 Subject: [PATCH 2/2] maintenance --- include/RE/B/BGSInventoryInterface.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/RE/B/BGSInventoryInterface.h b/include/RE/B/BGSInventoryInterface.h index 1b764d2..688855b 100644 --- a/include/RE/B/BGSInventoryInterface.h +++ b/include/RE/B/BGSInventoryInterface.h @@ -68,7 +68,7 @@ namespace RE UnkStruct* pOutstruct = &outstruct; using func_t = bool (*)(const BGSInventoryInterface*, const std::uint32_t*, UnkStruct**); - static REL::Relocation GetInventoryObjectHelperFn { ID::BGSInventoryInterface::GetInventoryObjectSub }; + static REL::Relocation GetInventoryObjectHelperFn{ ID::BGSInventoryInterface::GetInventoryObjectSub }; GetInventoryObjectHelperFn(this, &handle, &pOutstruct); return pObj;