diff --git a/CommonLibF4/include/F4SE/Interfaces.h b/CommonLibF4/include/F4SE/Interfaces.h index 448e9643..b55fda26 100644 --- a/CommonLibF4/include/F4SE/Interfaces.h +++ b/CommonLibF4/include/F4SE/Interfaces.h @@ -250,10 +250,49 @@ namespace F4SE bool WriteRecord(std::uint32_t a_type, std::uint32_t a_version, const void* a_buf, std::uint32_t a_length) const; bool OpenRecord(std::uint32_t a_type, std::uint32_t a_version) const; bool WriteRecordData(const void* a_buf, std::uint32_t a_length) const; + + template >, int> = 0> + bool WriteRecordData(const T& a_buf) const + { + return WriteRecordData(std::addressof(a_buf), sizeof(T)); + } + + template , int> = 0> + bool WriteRecordData(const T (&a_buf)[N]) const + { + return WriteRecordData(std::addressof(a_buf), sizeof(T) * N); + } + bool GetNextRecordInfo(std::uint32_t& a_type, std::uint32_t& a_version, std::uint32_t& a_length) const; std::uint32_t ReadRecordData(void* a_buf, std::uint32_t a_length) const; + template >, int> = 0> + std::uint32_t ReadRecordData(T& a_buf) const + { + return ReadRecordData(std::addressof(a_buf), sizeof(T)); + } + + template >, int> = 0> + std::uint32_t ReadRecordDataEx(std::uint32_t& a_length, T& a_buf) const + { + a_length -= sizeof(T); + return ReadRecordData(std::addressof(a_buf), sizeof(T)); + } + + template , int> = 0> + std::uint32_t ReadRecordData(T (&a_buf)[N]) const + { + return ReadRecordData(std::addressof(a_buf), sizeof(T) * N); + } + + template , int> = 0> + std::uint32_t ReadRecordDataEx(std::uint32_t& a_length, T (&a_buf)[N]) const + { + a_length -= sizeof(T); + return ReadRecordData(std::addressof(a_buf), sizeof(T) * N); + } + [[nodiscard]] std::optional ResolveHandle(std::uint64_t a_handle) const { std::uint64_t result{ 0 }; diff --git a/CommonLibF4/include/RE/Bethesda/Actor.h b/CommonLibF4/include/RE/Bethesda/Actor.h index efb6f7f6..e03e15c4 100644 --- a/CommonLibF4/include/RE/Bethesda/Actor.h +++ b/CommonLibF4/include/RE/Bethesda/Actor.h @@ -1171,6 +1171,13 @@ namespace RE return func(this); } + bool IsSneaking() + { + using func_t = decltype(&Actor::IsSneaking); + static REL::Relocation func{ REL::ID(2207655) }; + return func(this); + } + bool IsVisible() const { constexpr auto all = std::to_underlying(ACTOR_VISIBILITY_MASK::kAll); diff --git a/CommonLibF4/include/RE/Bethesda/BSScript/Stack.h b/CommonLibF4/include/RE/Bethesda/BSScript/Stack.h index 2c93583b..b96d38db 100644 --- a/CommonLibF4/include/RE/Bethesda/BSScript/Stack.h +++ b/CommonLibF4/include/RE/Bethesda/BSScript/Stack.h @@ -85,7 +85,7 @@ namespace RE [[nodiscard]] Variable& GetStackFrameVariable(const StackFrame* a_frame, std::uint32_t a_index, std::uint32_t a_pageHint) { using func_t = decltype(&Stack::GetStackFrameVariable); - static REL::Relocation func{ REL::ID(897539) }; + static REL::Relocation func{ REL::ID(2314681) }; return func(this, a_frame, a_index, a_pageHint); } diff --git a/CommonLibF4/include/RE/Bethesda/ControlMap.h b/CommonLibF4/include/RE/Bethesda/ControlMap.h index feecfc87..c020121c 100644 --- a/CommonLibF4/include/RE/Bethesda/ControlMap.h +++ b/CommonLibF4/include/RE/Bethesda/ControlMap.h @@ -62,7 +62,7 @@ namespace RE [[nodiscard]] static ControlMap* GetSingleton() { - static REL::Relocation singleton{ REL::ID(325206) }; + static REL::Relocation singleton{ REL::ID(2692014) }; return *singleton; } @@ -87,35 +87,35 @@ namespace RE bool PopInputContext(UserEvents::INPUT_CONTEXT_ID a_context) { using func_t = decltype(&ControlMap::PopInputContext); - static REL::Relocation func{ REL::ID(74587) }; + static REL::Relocation func{ REL::ID(2268336) }; return func(this, a_context); } void PushInputContext(UserEvents::INPUT_CONTEXT_ID a_context) { using func_t = decltype(&ControlMap::PushInputContext); - static REL::Relocation func{ REL::ID(1404410) }; + static REL::Relocation func{ REL::ID(2268335) }; return func(this, a_context); } bool RemapButton(BSFixedString const& a_id, INPUT_DEVICE a_device, std::int32_t a_buttonID) { using func_t = decltype(&ControlMap::RemapButton); - static REL::Relocation func{ REL::ID(11351) }; + static REL::Relocation func{ REL::ID(0) }; return func(this, a_id, a_device, a_buttonID); } void SaveRemappings() { using func_t = decltype(&ControlMap::SaveRemappings); - static REL::Relocation func{ REL::ID(1141541) }; + static REL::Relocation func{ REL::ID(0) }; return func(this); } void SetTextEntryMode(bool a_enable) { using func_t = decltype(&ControlMap::SetTextEntryMode); - static REL::Relocation func{ REL::ID(1270079) }; + static REL::Relocation func{ REL::ID(0) }; return func(this, a_enable); } diff --git a/CommonLibF4/include/RE/Bethesda/Events.h b/CommonLibF4/include/RE/Bethesda/Events.h index 34574635..c4fa90bf 100644 --- a/CommonLibF4/include/RE/Bethesda/Events.h +++ b/CommonLibF4/include/RE/Bethesda/Events.h @@ -593,18 +593,25 @@ namespace RE }; static_assert(sizeof(TESDeathEvent) == 0x18); - struct TESEquipEvent + struct TESEnterSneakingEvent { - public: - [[nodiscard]] static BSTEventSource* GetEventSource() + [[nodiscard]] static BSTEventSource* GetEventSource() { - using func_t = decltype(&TESEquipEvent::GetEventSource); + using func_t = decltype(&TESEnterSneakingEvent::GetEventSource); static REL::Relocation func{ REL::ID(2201837) }; return func(); } // members NiPointer actor; // 00 + }; + static_assert(sizeof(TESEnterSneakingEvent) == 0x8); + + struct TESEquipEvent + { + public: + // members + NiPointer actor; // 00 std::uint32_t baseObject; // 08 std::uint32_t originalRefr; // 0C std::uint16_t uniqueID; // 10 @@ -643,6 +650,9 @@ namespace RE return func(); } + [[nodiscard]] constexpr bool IsEnter() const noexcept { return type.all(FurnitureEventType::kEnter); } + [[nodiscard]] constexpr bool IsExit() const noexcept { return type.all(FurnitureEventType::kExit); } + // members NiPointer actor; // 00 NiPointer targetFurniture; // 08 diff --git a/CommonLibF4/include/RE/Bethesda/TESCamera.h b/CommonLibF4/include/RE/Bethesda/TESCamera.h index 514655e1..b9d1de57 100644 --- a/CommonLibF4/include/RE/Bethesda/TESCamera.h +++ b/CommonLibF4/include/RE/Bethesda/TESCamera.h @@ -174,7 +174,7 @@ namespace RE [[nodiscard]] static PlayerCamera* GetSingleton() { - static REL::Relocation singleton{ REL::ID(1171980) }; + static REL::Relocation singleton{ REL::ID(2688801) }; return *singleton; } @@ -193,52 +193,59 @@ namespace RE TESCameraState* PopState() { using func_t = decltype(&PlayerCamera::PopState); - static REL::Relocation func{ REL::ID(120998) }; + static REL::Relocation func{ REL::ID(2248424) }; return func(this); } TESCameraState* PushState(CameraState a_state) { using func_t = decltype(&PlayerCamera::PushState); - static REL::Relocation func{ REL::ID(746523) }; + static REL::Relocation func{ REL::ID(0) }; return func(this, a_state); } void ToggleFreeCameraMode(bool a_freezeTime) { using func_t = decltype(&PlayerCamera::ToggleFreeCameraMode); - static REL::Relocation func{ REL::ID(224913) }; + static REL::Relocation func{ REL::ID(2248368) }; return func(this, a_freezeTime); } void SetState(TESCameraState* a_newstate) const { using func_t = decltype(&PlayerCamera::SetState); - static REL::Relocation func{ REL::ID(858847) }; + static REL::Relocation func{ REL::ID(2214742) }; return func(this, a_newstate); } void StartFurnitureMode(TESObjectREFR* a_furniture) { using func_t = decltype(&PlayerCamera::StartFurnitureMode); - static REL::Relocation func{ REL::ID(10202) }; + static REL::Relocation func{ REL::ID(0) }; return func(this, a_furniture); } void StartPipboyMode(bool a_forcePipboyModeCamera) { using func_t = decltype(&PlayerCamera::StartPipboyMode); - static REL::Relocation func{ REL::ID(998069) }; + static REL::Relocation func{ REL::ID(2248358) }; return func(this, a_forcePipboyModeCamera); } void StopPipboyMode() { using func_t = decltype(&PlayerCamera::StopPipboyMode); - static REL::Relocation func{ REL::ID(811954) }; + static REL::Relocation func{ REL::ID(2248359) }; return func(this); } + bool QCameraEquals(CameraState a_state) + { + using func_t = decltype(&PlayerCamera::QCameraEquals); + static REL::Relocation func{ REL::ID(2248421) }; + return func(this, a_state); + } + // members ActorHandle cameraTarget; // 064 BSTSmallArray, CameraStates::kTotal> tempReturnStates; // 068 diff --git a/CommonLibF4/src/F4SE/Interfaces.cpp b/CommonLibF4/src/F4SE/Interfaces.cpp index f1f0b7ce..2b4804b5 100644 --- a/CommonLibF4/src/F4SE/Interfaces.cpp +++ b/CommonLibF4/src/F4SE/Interfaces.cpp @@ -122,15 +122,10 @@ namespace F4SE bool SerializationInterface::GetNextRecordInfo(std::uint32_t& a_type, std::uint32_t& a_version, std::uint32_t& a_length) const { - const auto success = - GetProxy().GetNextRecordInfo( + return GetProxy().GetNextRecordInfo( std::addressof(a_type), std::addressof(a_version), std::addressof(a_length)); - if (!success) { - log::warn("failed to get next record info"sv); - } - return success; } std::uint32_t SerializationInterface::ReadRecordData(void* a_buf, std::uint32_t a_length) const