diff --git a/include/RE/B/BSScriptUtil.h b/include/RE/B/BSScriptUtil.h index c4e863e6..d05ea8c7 100644 --- a/include/RE/B/BSScriptUtil.h +++ b/include/RE/B/BSScriptUtil.h @@ -1,19 +1,19 @@ #pragma once #include "RE/B/BSFixedString.h" -#include "RE/B/BSTSmartPointer.h" -#include "RE/I/IVirtualMachine.h" -#include "RE/V/VirtualMachine.h" #include "RE/B/BSTScatterTable.h" -#include "RE/T/TESForm.h" +#include "RE/B/BSTSmartPointer.h" #include "RE/G/GameVM.h" -#include "SFSE/Logger.h" -#include "SFSE/SFSE.h" -#include "RE/O/ObjectTypeInfo.h" +#include "RE/I/IVirtualMachine.h" +#include "RE/N/NativeFunctionBase.h" #include "RE/O/Object.h" +#include "RE/O/ObjectTypeInfo.h" #include "RE/S/StackFrame.h" #include "RE/S/Struct.h" -#include "RE/N/NativeFunctionBase.h" +#include "RE/T/TESForm.h" +#include "RE/V/VirtualMachine.h" +#include "SFSE/Logger.h" +#include "SFSE/SFSE.h" namespace RE::BSScript { @@ -83,7 +83,7 @@ namespace RE::BSScript { if (_proxy && _proxy->type) { const auto& mappings = _proxy->type->varNameIndexMap; - const auto it = mappings.find(a_name); + const auto it = mappings.find(a_name); if (it != mappings.end()) { const auto& var = _proxy->variables[it->Value]; return detail::UnpackVariable(var); @@ -104,7 +104,7 @@ namespace RE::BSScript bool insert(std::string_view a_name, T&& a_val) { if (_proxy && _proxy->type) { - auto& mappings = _proxy->type->varNameIndexMap; + auto& mappings = _proxy->type->varNameIndexMap; const auto it = mappings.find(a_name); if (it != mappings.end()) { auto& var = _proxy->variables[it->Value]; @@ -303,13 +303,12 @@ namespace RE::BSScript std::true_type> && std::is_default_constructible_v && ((array || wrapper)) && // - requires(T a_nullable) - { - // clang-format off + requires(T a_nullable) { + // clang-format off static_cast(a_nullable); { *static_cast(a_nullable) } -> decays_to; - // clang-format on - }; + // clang-format on + }; template concept valid_self = @@ -377,8 +376,8 @@ namespace RE::BSScript template [[nodiscard]] std::optional GetTypeInfo() { - const auto game = GameVM::GetSingleton(); - const auto vm = game ? game->GetVM() : nullptr; + const auto game = GameVM::GetSingleton(); + const auto vm = game ? game->GetVM() : nullptr; BSTSmartPointer typeInfo; if (!vm || !vm->GetScriptObjectType(GetVMTypeID(), typeInfo) || @@ -394,10 +393,10 @@ namespace RE::BSScript template [[nodiscard]] std::optional GetTypeInfo() { - const auto game = GameVM::GetSingleton(); - const auto vm = game ? game->GetVM() : nullptr; + const auto game = GameVM::GetSingleton(); + const auto vm = game ? game->GetVM() : nullptr; REL::Relocation baseObjectName{ REL::ID(648543) }; - BSTSmartPointer typeInfo; + BSTSmartPointer typeInfo; if (!vm || !vm->GetScriptObjectType(*baseObjectName, typeInfo) || !typeInfo) { @@ -498,8 +497,8 @@ namespace RE::BSScript } const auto success = [&]() { - const auto game = GameVM::GetSingleton(); - const auto vm = game ? game->GetVM() : nullptr; + const auto game = GameVM::GetSingleton(); + const auto vm = game ? game->GetVM() : nullptr; BSTSmartPointer typeInfo; if (!vm || !vm->GetScriptObjectType(GetVMTypeID(), typeInfo) || @@ -508,10 +507,10 @@ namespace RE::BSScript } const auto& handles = vm->GetObjectHandlePolicy(); - const auto handle = handles.GetHandleForObject( - GetVMTypeID(), - const_cast( - static_cast(a_val))); + const auto handle = handles.GetHandleForObject( + GetVMTypeID(), + const_cast( + static_cast(a_val))); if (handle == handles.EmptyHandle()) { return false; } @@ -594,10 +593,10 @@ namespace RE::BSScript typename std::remove_cvref_t::value_type&&>; const auto success = [&]() { - const auto game = GameVM::GetSingleton(); - const auto vm = game ? game->GetVM() : nullptr; - const auto typeInfo = GetTypeInfo>(); - const auto size = a_val.size(); + const auto game = GameVM::GetSingleton(); + const auto vm = game ? game->GetVM() : nullptr; + const auto typeInfo = GetTypeInfo>(); + const auto size = a_val.size(); BSTSmartPointer out; if (!typeInfo || !vm || @@ -643,7 +642,7 @@ namespace RE::BSScript namespace detail { template - __forceinline void PackVariable(Variable & a_var, T && a_val) + __forceinline void PackVariable(Variable& a_var, T&& a_val) { BSScript::PackVariable(a_var, std::forward(a_val)); } @@ -677,7 +676,7 @@ namespace RE::BSScript } const auto& handles = vm->GetObjectHandlePolicy(); - const auto handle = object->GetHandle(); + const auto handle = object->GetHandle(); if (!handles.IsHandleLoaded(handle)) { return nullptr; } @@ -776,7 +775,7 @@ namespace RE::BSScript using value_type = typename T::value_type; - T out; + T out; const auto in = get(a_var); for (const auto& var : in->elements) { out.push_back(detail::UnpackVariable(var)); @@ -905,12 +904,12 @@ namespace RE::BSScript class F, std::size_t... I> decltype(auto) DispatchHelper( - Variable& a_self, + Variable& a_self, Internal::VirtualMachine& a_vm, - std::uint32_t a_stackID, - const StackFrame& a_stackFrame, - Stack& a_stack, - const std::function& a_callback, + std::uint32_t a_stackID, + const StackFrame& a_stackFrame, + Stack& a_stack, + const std::function& a_callback, std::index_sequence) { const auto self = [&]() -> S { @@ -986,7 +985,8 @@ namespace RE::BSScript template NativeFunction(std::string_view a_object, std::string_view a_function, Fn a_func, bool a_isLatent) // requires(detail::invocable_r || - detail::invocable_r) : + detail::invocable_r) + : super(a_object, a_function, sizeof...(Args), detail::static_tag, a_isLatent), _stub(std::move(a_func)) { @@ -1060,11 +1060,11 @@ namespace RE::BSScript template void IVirtualMachine::BindNativeMethod( - stl::zstring a_object, - stl::zstring a_function, - F a_func, + stl::zstring a_object, + stl::zstring a_function, + F a_func, std::optional a_taskletCallable, - bool a_isLatent) + bool a_isLatent) { NF_util::NativeFunctionBase* func = new NativeFunction( a_object, diff --git a/include/RE/I/IFunction.h b/include/RE/I/IFunction.h index 9ddfd303..3d5d1403 100644 --- a/include/RE/I/IFunction.h +++ b/include/RE/I/IFunction.h @@ -2,9 +2,9 @@ #include "RE/B/BSFixedString.h" #include "RE/B/BSIntrusiveRefCounted.h" -#include "RE/T/TypeInfo.h" -#include "RE/S/StackFrame.h" #include "RE/E/ErrorLogger.h" +#include "RE/S/StackFrame.h" +#include "RE/T/TypeInfo.h" namespace RE::BSScript { diff --git a/include/RE/I/IStackCallbackSaveInterface.h b/include/RE/I/IStackCallbackSaveInterface.h index 30da82d0..d8a63157 100644 --- a/include/RE/I/IStackCallbackSaveInterface.h +++ b/include/RE/I/IStackCallbackSaveInterface.h @@ -1,7 +1,7 @@ #pragma once -#include "RE/B/BSTSmartPointer.h" #include "RE/B/BSIntrusiveRefCounted.h" +#include "RE/B/BSTSmartPointer.h" namespace RE { @@ -18,12 +18,12 @@ namespace RE virtual ~IStackCallbackFunctor(){}; // 00 // add - virtual void CallQueued() = 0; // 01 - virtual void CallCanceled() = 0; // 02 - virtual void StartMultiDispatch() = 0; // 03 - virtual void EndMultiDispatch() = 0; // 04 - virtual void operator()(Variable) = 0; // 05 - virtual bool CanSave() { return false; }; // 06 + virtual void CallQueued() = 0; // 01 + virtual void CallCanceled() = 0; // 02 + virtual void StartMultiDispatch() = 0; // 03 + virtual void EndMultiDispatch() = 0; // 04 + virtual void operator()(Variable) = 0; // 05 + virtual bool CanSave() { return false; }; // 06 }; static_assert(sizeof(IStackCallbackFunctor) == 0x10); diff --git a/include/RE/I/IVirtualMachine.h b/include/RE/I/IVirtualMachine.h index 48c480c1..d811522d 100644 --- a/include/RE/I/IVirtualMachine.h +++ b/include/RE/I/IVirtualMachine.h @@ -135,11 +135,11 @@ namespace RE template void BindNativeMethod( - stl::zstring a_object, - stl::zstring a_function, - F a_func, + stl::zstring a_object, + stl::zstring a_function, + F a_func, std::optional a_taskletCallable, - bool a_isLatent); + bool a_isLatent); void PostError(std::string_view a_msg, std::uint32_t a_stackID, ErrorLogger::Severity a_severity) { diff --git a/include/RE/N/NativeFunctionBase.h b/include/RE/N/NativeFunctionBase.h index 7937e19c..e1e98b36 100644 --- a/include/RE/N/NativeFunctionBase.h +++ b/include/RE/N/NativeFunctionBase.h @@ -1,8 +1,8 @@ #pragma once +#include "RE/B/BSTTuple.h" #include "RE/I/IFunction.h" #include "RE/T/TypeInfo.h" -#include "RE/B/BSTTuple.h" namespace RE::BSScript { @@ -49,9 +49,9 @@ namespace RE::BSScript NativeFunctionBase( std::string_view a_object, std::string_view a_function, - std::uint16_t a_paramCount, - bool a_isStatic, - bool a_isLatent) : + std::uint16_t a_paramCount, + bool a_isStatic, + bool a_isLatent) : _name(a_function), _className(a_object), _params(a_paramCount, 0), @@ -74,7 +74,7 @@ namespace RE::BSScript return a_dst; } - virtual std::uint64_t GetParamCount() override { return _params.paramCount; } + virtual std::uint64_t GetParamCount() override { return _params.paramCount; } virtual TypeInfo* GetParam(std::uint32_t a_idx, BSFixedString* a_nameOut, TypeInfo* a_typeOut) override { diff --git a/include/RE/N/NiAVObject.h b/include/RE/N/NiAVObject.h index 0b20da03..8bbc0506 100644 --- a/include/RE/N/NiAVObject.h +++ b/include/RE/N/NiAVObject.h @@ -1,7 +1,7 @@ #pragma once #include "RE/B/BSFixedString.h" -#include "RE/N/NiTransform.h" #include "RE/N/NiBound.h" +#include "RE/N/NiTransform.h" namespace RE { @@ -130,7 +130,7 @@ namespace RE { _InterlockedExchangeAdd(&refcount, 1); } - + void DecRefCount() { if (_InterlockedExchangeAdd(&refcount, -1) == 1) diff --git a/include/RE/S/StructTypeInfo.h b/include/RE/S/StructTypeInfo.h index 90a2d406..a2d5dcc1 100644 --- a/include/RE/S/StructTypeInfo.h +++ b/include/RE/S/StructTypeInfo.h @@ -2,12 +2,12 @@ #include "RE/B/BSFixedString.h" #include "RE/B/BSTArray.h" +#include "RE/B/BSTScatterTable.h" #include "RE/B/BSTSmartPointer.h" #include "RE/I/IComplexType.h" #include "RE/O/ObjectTypeInfo.h" #include "RE/T/TypeInfo.h" #include "RE/V/Variable.h" -#include "RE/B/BSTScatterTable.h" namespace RE::BSScript { @@ -52,11 +52,11 @@ namespace RE::BSScript virtual TypeInfo::RawType GetRawType() const override { return TypeInfo::RawType::kStruct; } // 01 // members - BSFixedString name; // 10 - BSTSmartPointer containingObjTypeInfo; // 18 - BSTArray variables; // 20 - BSTHashMap varNameIndexMap; // 30 - stl::enumeration linkedValid; // 68 + BSFixedString name; // 10 + BSTSmartPointer containingObjTypeInfo; // 18 + BSTArray variables; // 20 + BSTHashMap varNameIndexMap; // 30 + stl::enumeration linkedValid; // 68 }; static_assert(sizeof(StructTypeInfo) == 0x70); } diff --git a/src/SFSE/API.cpp b/src/SFSE/API.cpp index 68c14946..a1b47636 100644 --- a/src/SFSE/API.cpp +++ b/src/SFSE/API.cpp @@ -164,12 +164,12 @@ namespace SFSE if (!allocated) { trampoline.create(hookSize); } - + // Call to GameVM::BindEverythingToScript(IVirtualMachine**) from GameVM::GameVM() REL::Relocation hookLoc{ REL::ID(169912), 0x514 }; func = reinterpret_cast(trampoline.write_call<5>(hookLoc.address(), &thunk)); } - + static void thunk(RE::BSScript::IVirtualMachine** a_vm) { func(a_vm);