From ae410cb4be3389867800bbdff6ad9c0d0afef414 Mon Sep 17 00:00:00 2001 From: FlenarnTemp <68670981+FlenarnTemp@users.noreply.github.com> Date: Fri, 14 Jun 2024 07:45:58 +0200 Subject: [PATCH 1/4] feat: Misc. (#9) * feat: BSRandom. * feat: Inline function as it should be. * feat: More RE'ing, cheers GELUXRUM. * feat: AimModel RE. * feat: Update IDs. * feat: Missing import --- CommonLibF4/cmake/sourcelist.cmake | 1 + CommonLibF4/include/RE/Bethesda/Actor.h | 18 +++++++++ CommonLibF4/include/RE/Bethesda/BSExtraData.h | 38 ++++++++++++++++++- CommonLibF4/include/RE/Bethesda/BSRandom.h | 14 +++++++ CommonLibF4/include/RE/Fallout.h | 1 + .../include/RE/Scaleform/Kernel/SF_Memory.h | 4 +- 6 files changed, 72 insertions(+), 4 deletions(-) create mode 100644 CommonLibF4/include/RE/Bethesda/BSRandom.h diff --git a/CommonLibF4/cmake/sourcelist.cmake b/CommonLibF4/cmake/sourcelist.cmake index 4d1f3063..77c1ccfc 100644 --- a/CommonLibF4/cmake/sourcelist.cmake +++ b/CommonLibF4/cmake/sourcelist.cmake @@ -58,6 +58,7 @@ set(SOURCES include/RE/Bethesda/BSModelDB.h include/RE/Bethesda/BSPointerHandle.h include/RE/Bethesda/BSPreCulledObjects.h + include/RE/Bethesda/BSRandom.h include/RE/Bethesda/BSResource.h include/RE/Bethesda/BSResource/AsyncStream.h include/RE/Bethesda/BSResource/BSResourceEnums.h diff --git a/CommonLibF4/include/RE/Bethesda/Actor.h b/CommonLibF4/include/RE/Bethesda/Actor.h index e03e15c4..e678e448 100644 --- a/CommonLibF4/include/RE/Bethesda/Actor.h +++ b/CommonLibF4/include/RE/Bethesda/Actor.h @@ -6,6 +6,7 @@ #include "RE/Bethesda/BSLock.h" #include "RE/Bethesda/BSPointerHandle.h" #include "RE/Bethesda/BSSoundHandle.h" +#include "RE/Bethesda/BSSpring.h" #include "RE/Bethesda/BSTArray.h" #include "RE/Bethesda/BSTEvent.h" #include "RE/Bethesda/BSTSingleton.h" @@ -235,6 +236,23 @@ namespace RE }; static_assert(sizeof(SubGraphIdleRootData) == 0x18); + class __declspec(novtable) AimModel + { + public: + BGSAimModel::Data aimModelData; // 00 + BSSpring::SpringState recoilSpring; // 40 + BSSpring::SpringState recoilDiminishSpring; // 54 + NiPoint2 targetRecoilHead; // 68 + NiPoint2 currentRecoilHead; // 70 + NiPoint2 prevRecoilRad; // 78 + NiPoint2 preShotAimRad; // 80 + Actor* actor; // 88 + float fireConeSize; // 90 + float lastShotDeltaMs; // 94 + unsigned int continuousShots; // 98 + }; + static_assert(sizeof(AimModel) == 0xA0); + class __declspec(novtable) EquippedItemData : public NiRefObject // 00 { diff --git a/CommonLibF4/include/RE/Bethesda/BSExtraData.h b/CommonLibF4/include/RE/Bethesda/BSExtraData.h index e7c0127b..c10760b3 100644 --- a/CommonLibF4/include/RE/Bethesda/BSExtraData.h +++ b/CommonLibF4/include/RE/Bethesda/BSExtraData.h @@ -6,6 +6,7 @@ #include "RE/Bethesda/BSTArray.h" #include "RE/Bethesda/BSTSmartPointer.h" #include "RE/Bethesda/BSTTuple.h" +#include "RE/Bethesda/FormComponents.h" #include "RE/Bethesda/MemoryManager.h" #include "RE/NetImmerse/NiPoint.h" @@ -66,7 +67,7 @@ namespace RE kRangeDistOverride, kTimeLeft, kCharge, - kLight, + kLight, // ExtraLight kLock, // ExtraLock kTeleport, // ExtraTeleport kMapMarker, @@ -170,7 +171,7 @@ namespace RE kOutfitItem, kEditorLocation, kLeveledItemBase, - kLightData, + kLightData, // ExtraLightData kScene, kBadPosition, kHeadTrackingWeight, @@ -363,6 +364,39 @@ namespace RE }; static_assert(sizeof(ExtraHealth) == 0x20); + class __declspec(novtable) ExtraCharge : + public BSExtraData // 00 + { + public: + static constexpr auto RTTI{ RTTI::ExtraCharge }; + static constexpr auto VTABLE{ VTABLE::ExtraCharge }; + static constexpr auto TYPE{ EXTRA_DATA_TYPE::kCharge }; + + // members + float charge; // 18 + }; + static_assert(sizeof(ExtraCharge) == 0x20); + + struct __declspec(novtable) MapMarkerData : + public TESFullName // 00 + { + std::uint32_t flags; // 10 + }; + static_assert(sizeof(MapMarkerData) == 0x18); + + class __declspec(novtable) ExtraMapMarker : + public BSExtraData // 00 + { + public: + static constexpr auto RTTI{ RTTI::ExtraMapMarker }; + static constexpr auto VTABLE{ VTABLE::ExtraMapMarker }; + static constexpr auto TYPE{ EXTRA_DATA_TYPE::kMapMarker }; + + // members + MapMarkerData* mapMarkerData; // 18 + }; + static_assert(sizeof(ExtraMapMarker) == 0x20); + class __declspec(novtable) ExtraLock : public BSExtraData // 00 { diff --git a/CommonLibF4/include/RE/Bethesda/BSRandom.h b/CommonLibF4/include/RE/Bethesda/BSRandom.h new file mode 100644 index 00000000..8c7e1e6b --- /dev/null +++ b/CommonLibF4/include/RE/Bethesda/BSRandom.h @@ -0,0 +1,14 @@ +#pragma once + +namespace RE +{ + namespace BSRandom + { + inline std::uint32_t UnsignedInt(unsigned int aMin, unsigned int aMax) + { + using func_t = decltype(&BSRandom::UnsignedInt); + static REL::Relocation func{ REL::ID(2267950) }; + return (aMin, aMax); + } + } +} diff --git a/CommonLibF4/include/RE/Fallout.h b/CommonLibF4/include/RE/Fallout.h index 68fe0371..2cbac517 100644 --- a/CommonLibF4/include/RE/Fallout.h +++ b/CommonLibF4/include/RE/Fallout.h @@ -53,6 +53,7 @@ #include "RE/Bethesda/BSModelDB.h" #include "RE/Bethesda/BSPointerHandle.h" #include "RE/Bethesda/BSPreCulledObjects.h" +#include "RE/Bethesda/BSRandom.h" #include "RE/Bethesda/BSResource.h" #include "RE/Bethesda/BSResource/AsyncStream.h" #include "RE/Bethesda/BSResource/BSResourceEnums.h" diff --git a/CommonLibF4/include/RE/Scaleform/Kernel/SF_Memory.h b/CommonLibF4/include/RE/Scaleform/Kernel/SF_Memory.h index 9ae76f5e..887f614d 100644 --- a/CommonLibF4/include/RE/Scaleform/Kernel/SF_Memory.h +++ b/CommonLibF4/include/RE/Scaleform/Kernel/SF_Memory.h @@ -11,13 +11,13 @@ namespace RE::Scaleform public: static void SetGlobalHeap(MemoryHeap* a_heap) { - static REL::Relocation heap{ REL::ID(939898) }; + static REL::Relocation heap{ REL::ID(2707353) }; *heap = a_heap; } [[nodiscard]] static MemoryHeap* GetGlobalHeap() { - static REL::Relocation heap{ REL::ID(939898) }; + static REL::Relocation heap{ REL::ID(2707353) }; return *heap; } From e0fe768f208ad589a6eab36863e55c90770246c9 Mon Sep 17 00:00:00 2001 From: FalloutCascadia <54562300+FalloutCascadia@users.noreply.github.com> Date: Fri, 14 Jun 2024 07:57:29 +0200 Subject: [PATCH 2/4] Update BSRandom.h to use std::uint32_t --- CommonLibF4/include/RE/Bethesda/BSRandom.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CommonLibF4/include/RE/Bethesda/BSRandom.h b/CommonLibF4/include/RE/Bethesda/BSRandom.h index 8c7e1e6b..fd61f532 100644 --- a/CommonLibF4/include/RE/Bethesda/BSRandom.h +++ b/CommonLibF4/include/RE/Bethesda/BSRandom.h @@ -4,7 +4,7 @@ namespace RE { namespace BSRandom { - inline std::uint32_t UnsignedInt(unsigned int aMin, unsigned int aMax) + inline std::uint32_t UnsignedInt(std::uint32_t aMin, std::uint32_t aMax) { using func_t = decltype(&BSRandom::UnsignedInt); static REL::Relocation func{ REL::ID(2267950) }; From 27cb4ddb0a5f237a0e7f904ee71182b05a2e418c Mon Sep 17 00:00:00 2001 From: FalloutCascadia <54562300+FalloutCascadia@users.noreply.github.com> Date: Fri, 14 Jun 2024 08:45:29 +0200 Subject: [PATCH 3/4] Update CommonLibF4/include/RE/Bethesda/BSRandom.h Co-authored-by: qudix <17361645+qudix@users.noreply.github.com> --- CommonLibF4/include/RE/Bethesda/BSRandom.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CommonLibF4/include/RE/Bethesda/BSRandom.h b/CommonLibF4/include/RE/Bethesda/BSRandom.h index fd61f532..27cd30de 100644 --- a/CommonLibF4/include/RE/Bethesda/BSRandom.h +++ b/CommonLibF4/include/RE/Bethesda/BSRandom.h @@ -4,11 +4,12 @@ namespace RE { namespace BSRandom { - inline std::uint32_t UnsignedInt(std::uint32_t aMin, std::uint32_t aMax) + inline std::uint32_t UnsignedInt(std::uint32_t a_min, std::uint32_t a_max) { using func_t = decltype(&BSRandom::UnsignedInt); static REL::Relocation func{ REL::ID(2267950) }; - return (aMin, aMax); + return func(a_min, a_max); + } } } } From 4a59716635405210e66c4c96ca90111d7575b6ff Mon Sep 17 00:00:00 2001 From: FalloutCascadia <54562300+FalloutCascadia@users.noreply.github.com> Date: Fri, 14 Jun 2024 08:55:52 +0200 Subject: [PATCH 4/4] Update BSRandom.h Extra closing bracket. --- CommonLibF4/include/RE/Bethesda/BSRandom.h | 1 - 1 file changed, 1 deletion(-) diff --git a/CommonLibF4/include/RE/Bethesda/BSRandom.h b/CommonLibF4/include/RE/Bethesda/BSRandom.h index 27cd30de..14f34e32 100644 --- a/CommonLibF4/include/RE/Bethesda/BSRandom.h +++ b/CommonLibF4/include/RE/Bethesda/BSRandom.h @@ -10,6 +10,5 @@ namespace RE static REL::Relocation func{ REL::ID(2267950) }; return func(a_min, a_max); } - } } }