diff --git a/include/RE/B/BSAnimationGraph.h b/include/RE/B/BSAnimationGraph.h index 6993a1a..2aa773a 100644 --- a/include/RE/B/BSAnimationGraph.h +++ b/include/RE/B/BSAnimationGraph.h @@ -1,5 +1,6 @@ #pragma once +#include "RE/B/BGSAnimationPathImplementation.h" #include "RE/B/BSIntrusiveRefCounted.h" #include "RE/B/BSLock.h" #include "RE/B/BSTEvent.h" @@ -7,7 +8,6 @@ namespace RE { - class BGSAnimationPathImplementation; class BSAnimationGraphEvent; class BSFadeNode; struct BSMovementDataChangedEvent; @@ -80,6 +80,11 @@ namespace RE public: virtual ~AnimationManager(); + [[nodiscard]] TESObjectREFR* GetTargetReference() const + { + return animationPath ? animationPath->reference : nullptr; + } + // members std::byte unkA8[0x218]; // A8 BGSAnimationPathImplementation* animationPath; // 2C0 diff --git a/include/RE/B/BSService.h b/include/RE/B/BSService.h new file mode 100644 index 0000000..26218b5 --- /dev/null +++ b/include/RE/B/BSService.h @@ -0,0 +1,109 @@ +#pragma once + +#include "RE/B/BSLock.h" + +namespace RE +{ + namespace BSService + { + class QueuedDelegate + { + public: + virtual ~QueuedDelegate() = default; // 00 + + virtual void RunAndDispose() // 01 + { + Run(); + delete this; + } + + virtual void Unk02() {} // 02 + virtual void Unk03() {} // 03 + virtual void* GetProfilerContext() { return nullptr; } // 04 + virtual void Unk05() {} // 05 + virtual void Unk06() {} // 06 + virtual void Unk07() {} // 07 + + virtual void Run() = 0; + + std::uint32_t IncRef() const + { + REX::TAtomicRef myRefCount{ refCount }; + return ++myRefCount; + } + + void Release() const + { + REX::TAtomicRef myRefCount{ refCount }; + if (--myRefCount == 0) { + const_cast(this)->RunAndDispose(); + } + } + + // members + mutable volatile std::uint32_t refCount{ 1 }; // 08 + std::uint32_t pad0C{ 0 }; // 0C + std::byte pad10[0x18]{}; // 10 + BSReadWriteLock lock; // 28 + const void* profilerCategory{}; // 30 + std::byte pad38[0xE8]{}; // 38 + }; + static_assert(offsetof(QueuedDelegate, refCount) == 0x08); + static_assert(offsetof(QueuedDelegate, lock) == 0x28); + static_assert(offsetof(QueuedDelegate, profilerCategory) == 0x30); + static_assert(sizeof(QueuedDelegate) == 0x120); + + namespace detail + { + template + class QueuedFunctorDelegate : + public QueuedDelegate + { + public: + explicit QueuedFunctorDelegate(Fn a_fn) : + _fn(std::move(a_fn)) + {} + + void Run() override { _fn(); } + + private: + Fn _fn; + }; + } + + class TaskQueue + { + public: + [[nodiscard]] static TaskQueue* GetSingleton() + { + static REL::Relocation singleton{ ID::BSService::TaskQueue::Singleton }; + return *singleton; + } + + void QueueTask(QueuedDelegate*& a_task) + { + using func_t = void (*)(TaskQueue*, QueuedDelegate**); + static REL::Relocation func{ ID::BSService::TaskQueue::QueueTask }; + func(this, std::addressof(a_task)); + } + + void AddTask(QueuedDelegate* a_task) + { + if (!a_task) { + return; + } + QueueTask(a_task); + if (a_task) { + a_task->Release(); + } + } + + template + requires(std::invocable&>) + void AddTask(Fn&& a_fn) + { + AddTask(new detail::QueuedFunctorDelegate>(std::forward(a_fn))); + } + }; + } +} diff --git a/include/RE/IDs.h b/include/RE/IDs.h index 0c42e48..e5f5277 100644 --- a/include/RE/IDs.h +++ b/include/RE/IDs.h @@ -37,9 +37,9 @@ 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 Singleton{ 938503 }; // 879425 + inline constexpr REL::ID EquipObject{ 101949 }; // 151991 + inline constexpr REL::ID UnequipObject{ 101951 }; // 152007 } namespace ActorCellChangeEvent::Event @@ -338,6 +338,12 @@ namespace RE::ID } } + namespace BSService::TaskQueue + { + inline constexpr REL::ID Singleton{ 883606 }; + inline constexpr REL::ID QueueTask{ 100121 }; + } + namespace BSSpinLock { inline constexpr REL::ID Lock{ 123819 }; @@ -1631,7 +1637,7 @@ namespace RE::ID namespace SaveLoadEvent { - inline constexpr REL::ID GetEventSource{ 0 }; // 129747 + inline constexpr REL::ID GetEventSource{ 82710 }; // 129747 } namespace Scaleform @@ -2289,7 +2295,7 @@ namespace RE::ID namespace TESLoadGameEvent { - inline constexpr REL::ID GetEventSource{ 0 }; // 1868757 + inline constexpr REL::ID GetEventSource{ 64149 }; // 1868757 } namespace TESLockChangedEvent diff --git a/include/RE/Starfield.h b/include/RE/Starfield.h index f6762d5..4e5b881 100644 --- a/include/RE/Starfield.h +++ b/include/RE/Starfield.h @@ -210,6 +210,7 @@ #include "RE/B/BSReflection.h" #include "RE/B/BSResourceEnums.h" #include "RE/B/BSScriptUtil.h" +#include "RE/B/BSService.h" #include "RE/B/BSStorage.h" #include "RE/B/BSStringPool.h" #include "RE/B/BSStringT.h" diff --git a/include/RE/T/TESDataHandler.h b/include/RE/T/TESDataHandler.h index ed66809..890ac69 100644 --- a/include/RE/T/TESDataHandler.h +++ b/include/RE/T/TESDataHandler.h @@ -20,10 +20,11 @@ namespace RE { public: // members - BSTArray files; // 00 - BSTArray smallFiles; // 10 + BSTArray files; // 00 + BSTArray smallFiles; // 10 + BSTArray mediumFiles; // 20 }; - static_assert(sizeof(TESFileCollection) == 0x20); + static_assert(sizeof(TESFileCollection) == 0x30); class TESDataHandler : public BSTEventSource // 0000 @@ -67,25 +68,8 @@ namespace RE std::uint64_t unk14E0; // 14E0 std::uint64_t unk14E8; // 14E8 BSSimpleList files; // 14F0 - TESFileCollection compiledFileCollection; // 1500 - std::uint64_t unk1520; // 1520 - std::uint64_t unk1528; // 1528 - std::uint64_t unk1530; // 1530 - std::uint64_t unk1538; // 1538 - std::uint64_t unk1540; // 1540 - std::uint64_t unk1548; // 1548 - std::uint64_t unk1550; // 1550 - std::uint64_t unk1558; // 1558 - std::uint64_t unk1560; // 1560 - std::uint64_t unk1568; // 1568 - std::uint64_t unk1570; // 1570 - std::uint64_t unk1578; // 1578 - std::uint64_t unk1580; // 1580 - std::uint64_t unk1588; // 1588 - std::uint64_t unk1590; // 1590 - std::uint64_t unk1598; // 1598 - std::uint64_t unk15A0; // 15A0 - std::uint64_t unk15A8; // 15A8 + std::byte pad1500[0x80]; // 1500 + TESFileCollection compiledFileCollection; // 1580 std::uint64_t unk15B0; // 15B0 std::uint64_t unk15B8; // 15B8 std::uint64_t unk15C0; // 15C0 diff --git a/include/RE/T/TESFile.h b/include/RE/T/TESFile.h index a4f37a3..d83b768 100644 --- a/include/RE/T/TESFile.h +++ b/include/RE/T/TESFile.h @@ -9,5 +9,7 @@ namespace RE std::uint8_t pad0[0x38]; //0 char fileName[260]; //38 + std::uint8_t pad13C[0x7B]; //13C + std::uint8_t compileIndex; //1B7 }; }