From 14e3ddf528b6f03b2889536b90e56cf9723588e0 Mon Sep 17 00:00:00 2001 From: powerof3 <32599957+powerof3@users.noreply.github.com> Date: Sun, 18 Aug 2024 20:04:38 +0530 Subject: [PATCH] Add `BSResource::RHandleType` helpers --- include/RE/B/BSResourceHandle.h | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/include/RE/B/BSResourceHandle.h b/include/RE/B/BSResourceHandle.h index 703df3767..e85c87e2f 100644 --- a/include/RE/B/BSResourceHandle.h +++ b/include/RE/B/BSResourceHandle.h @@ -21,8 +21,31 @@ namespace RE using U_Entry = T_Entry; using U_EntryDB = T_EntryDB; + [[nodiscard]] constexpr T_Entry* get() const noexcept + { + return _entry; + } + + [[nodiscard]] explicit constexpr operator bool() const noexcept + { + return static_cast(_entry); + } + + [[nodiscard]] constexpr T_Entry& operator*() const noexcept + { + assert(static_cast(*this)); + return *_entry; + } + + [[nodiscard]] constexpr T_Entry* operator->() const noexcept + { + assert(static_cast(*this)); + return _entry; + } + + protected: // members - T_Entry* entry; // 00 + T_Entry* _entry; // 00 }; }