From a8340bf7099ec8f051a0261405298484caa606b5 Mon Sep 17 00:00:00 2001 From: Qudix <17361645+Qudix@users.noreply.github.com> Date: Sun, 29 Sep 2024 09:19:35 -0500 Subject: [PATCH] feat: add `TESObjectREFR::LookupByHandle` --- include/RE/T/TESObjectREFR.h | 3 +++ src/RE/T/TESObjectREFR.cpp | 21 +++++++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/include/RE/T/TESObjectREFR.h b/include/RE/T/TESObjectREFR.h index 4442c8bc..0c8833f3 100644 --- a/include/RE/T/TESObjectREFR.h +++ b/include/RE/T/TESObjectREFR.h @@ -356,6 +356,9 @@ namespace RE virtual void Unk_12E(); // 12E virtual void Unk_12F(); // 12F + static NiPointer LookupByHandle(RefHandle a_refHandle); + static bool LookupByHandle(RefHandle a_refHandle, NiPointer& a_refrOut); + void ForEachEquippedItem(std::function a_callback) const; void ForEachInventoryItem(std::function a_callback) const; diff --git a/src/RE/T/TESObjectREFR.cpp b/src/RE/T/TESObjectREFR.cpp index ffc2969c..90b56756 100644 --- a/src/RE/T/TESObjectREFR.cpp +++ b/src/RE/T/TESObjectREFR.cpp @@ -2,14 +2,20 @@ #include "RE/B/BGSInventoryItem.h" #include "RE/E/ExtraLock.h" +#include "RE/M/Misc.h" namespace RE { - void TESObjectREFR::AddLockChange() + NiPointer TESObjectREFR::LookupByHandle(RefHandle a_refHandle) { - using func_t = decltype(&TESObjectREFR::AddLockChange); - static REL::Relocation func{ ID::TESObjectREFR::AddLockChange }; - return func(this); + NiPointer ref; + LookupReferenceByHandle(a_refHandle, ref); + return ref; + } + + bool TESObjectREFR::LookupByHandle(RefHandle a_refHandle, NiPointer& a_refrOut) + { + return LookupReferenceByHandle(a_refHandle, a_refrOut); } void TESObjectREFR::ForEachEquippedItem(std::function a_callback) const @@ -154,4 +160,11 @@ namespace RE AddLockChange(); } } + + void TESObjectREFR::AddLockChange() + { + using func_t = decltype(&TESObjectREFR::AddLockChange); + static REL::Relocation func{ ID::TESObjectREFR::AddLockChange }; + return func(this); + } }