diff --git a/CommonLibF4/cmake/sourcelist.cmake b/CommonLibF4/cmake/sourcelist.cmake index ec2d0666..73dcfae8 100644 --- a/CommonLibF4/cmake/sourcelist.cmake +++ b/CommonLibF4/cmake/sourcelist.cmake @@ -340,7 +340,6 @@ set(SOURCES include/RE/Scaleform/Render/Render_Types2D.h include/RE/Scaleform/Render/Render_Viewport.h include/RE/VTABLE_IDs.h - include/RE/msvc/functional.h include/RE/msvc/memory.h include/RE/msvc/typeinfo.h include/REL/Relocation.h diff --git a/CommonLibF4/include/RE/Bethesda/ActorValueInfo.h b/CommonLibF4/include/RE/Bethesda/ActorValueInfo.h index 488be333..a85b5847 100644 --- a/CommonLibF4/include/RE/Bethesda/ActorValueInfo.h +++ b/CommonLibF4/include/RE/Bethesda/ActorValueInfo.h @@ -215,21 +215,21 @@ namespace RE using DerivationFunction_t = float(const ActorValueOwner* a_actor, const ActorValueInfo& a_info); // members - msvc::function modifiedCallback; // 048 - BSStringT formEditorID; // 068 - ActorValueInfo* dependentActorValues[15]; // 078 - msvc::function derivationFunction; // 0F0 - const char* enumNames[10]; // 110 - BGSLocalizedString abbreviation; // 160 - std::int32_t oldActorValue; // 168 - stl::enumeration flags; // 16C - stl::enumeration avType; // 170 - std::uint32_t numDependentActorValues; // 174 - std::uint32_t enumCount; // 178 - std::int32_t fullCacheIndex; // 17C - std::int32_t permanentCacheIndex; // 180 - float defaultValue; // 184 - std::uint32_t sortIndex; // 188 + std::function modifiedCallback; // 048 + BSStringT formEditorID; // 088 + ActorValueInfo* dependentActorValues[15]; // 098 + std::function derivationFunction; // 110 + const char* enumNames[10]; // 150 + BGSLocalizedString abbreviation; // 1A0 + std::int32_t oldActorValue; // 1A8 + stl::enumeration flags; // 1AC + stl::enumeration avType; // 1B0 + std::uint32_t numDependentActorValues; // 1B4 + std::uint32_t enumCount; // 1B8 + std::int32_t fullCacheIndex; // 1BC + std::int32_t permanentCacheIndex; // 1C0 + float defaultValue; // 1C4 + std::uint32_t sortIndex; // 1C8 }; - static_assert(sizeof(ActorValueInfo) == 0x190); + static_assert(sizeof(ActorValueInfo) == 0x1D0); } diff --git a/CommonLibF4/include/RE/Bethesda/BSScript/IVirtualMachine.h b/CommonLibF4/include/RE/Bethesda/BSScript/IVirtualMachine.h index 90e69bf5..ad9a0320 100644 --- a/CommonLibF4/include/RE/Bethesda/BSScript/IVirtualMachine.h +++ b/CommonLibF4/include/RE/Bethesda/BSScript/IVirtualMachine.h @@ -29,7 +29,7 @@ namespace RE { template - using BSTThreadScrapFunction = msvc::function; + using BSTThreadScrapFunction = std::function; namespace BSScript { @@ -140,6 +140,13 @@ namespace RE std::optional a_taskletCallable = std::nullopt, bool a_isLatent = false); + template + bool DispatchStaticCall( + const BSFixedString& a_objName, + const BSFixedString& a_funcName, + const BSTSmartPointer& a_callback, + Args... a_args); + template bool DispatchMethodCall( std::uint64_t a_objHandle, diff --git a/CommonLibF4/include/RE/Bethesda/BSScriptUtil.h b/CommonLibF4/include/RE/Bethesda/BSScriptUtil.h index b5ccf353..da4fa65e 100644 --- a/CommonLibF4/include/RE/Bethesda/BSScriptUtil.h +++ b/CommonLibF4/include/RE/Bethesda/BSScriptUtil.h @@ -1255,48 +1255,23 @@ namespace RE::BSScript (std::make_index_sequence{}); return result; } + } - class FunctionArgsBase - { - public: - FunctionArgsBase() = delete; - FunctionArgsBase(IVirtualMachine* a_vm) : - vm(a_vm) - {} - - bool operator()(BSScrapArray& a_args) - { - args->ReplaceArray(a_args, *vm); + template + bool IVirtualMachine::DispatchStaticCall( + const BSFixedString& a_objName, + const BSFixedString& a_funcName, + const BSTSmartPointer& a_callback, + Args... a_args) + { + return DispatchStaticCall( + a_objName, + a_funcName, + [&](BSScrapArray& a_out) { + a_out = detail::PackVariables(a_args...); return true; - } - - protected: - ArrayWrapper* args; // 00 - IVirtualMachine* vm; // 08 - }; - static_assert(sizeof(FunctionArgsBase) == 0x10); - - inline BSTThreadScrapFunction&)> - CreateThreadScrapFunction(FunctionArgsBase& a_args) - { - using func_t = decltype(&detail::CreateThreadScrapFunction); - REL::Relocation func{ REL::ID(69733) }; - return func(a_args); - } - - template - class FunctionArgs : - public FunctionArgsBase - { - public: - FunctionArgs() = delete; - FunctionArgs(IVirtualMachine* a_vm, Args... a_args) : - FunctionArgsBase(a_vm) - { - auto scrap = PackVariables(a_args...); - args = new ArrayWrapper(scrap, *vm); - } - }; + }, + a_callback); } template @@ -1307,12 +1282,14 @@ namespace RE::BSScript const BSTSmartPointer& a_callback, Args... a_args) { - auto args = detail::FunctionArgs{ this, a_args... }; return DispatchMethodCall( a_objHandle, a_objName, a_funcName, - detail::CreateThreadScrapFunction(args), + [&](BSScrapArray& a_out) { + a_out = detail::PackVariables(a_args...); + return true; + }, a_callback); } } diff --git a/CommonLibF4/include/RE/Bethesda/GameScript.h b/CommonLibF4/include/RE/Bethesda/GameScript.h index 88b59117..fa4ba018 100644 --- a/CommonLibF4/include/RE/Bethesda/GameScript.h +++ b/CommonLibF4/include/RE/Bethesda/GameScript.h @@ -20,7 +20,7 @@ namespace RE { template - using BSTThreadScrapFunction = msvc::function; + using BSTThreadScrapFunction = std::function; namespace BSScript { diff --git a/CommonLibF4/include/RE/msvc/functional.h b/CommonLibF4/include/RE/msvc/functional.h deleted file mode 100644 index b9d249ba..00000000 --- a/CommonLibF4/include/RE/msvc/functional.h +++ /dev/null @@ -1,45 +0,0 @@ -#pragma once - -namespace RE::msvc -{ - class type_info; - - template - class function; - - // class std::_Func_class - template - class function - { - public: - using result_type = R; - - [[nodiscard]] explicit operator bool() const noexcept { return good(); } - - result_type operator()(Args&&... a_args) const - { - assert(good()); - return _fn->do_call(std::forward(a_args)...); - } - - private: - // class std::_Func_base - class __declspec(novtable) proxy_t - { - public: - // add - virtual proxy_t* copy(void*) = 0; // 00 - virtual proxy_t* move(void*) = 0; // 01 - virtual result_type do_call(Args&&...) = 0; // 02 - virtual const type_info& target_type() const = 0; // 03 - virtual void delete_this(bool) = 0; // 04 - virtual ~proxy_t() = default; // 05 - virtual const void* get() const = 0; // 06 - }; - - [[nodiscard]] bool good() const noexcept { return _fn != nullptr; } - - std::aligned_storage_t<3 * sizeof(void*), alignof(long double)> _storage; // 00 - proxy_t* _fn; // 18 - }; -}